Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: ui/aura_shell/app_list/app_list_view.cc

Issue 8890049: [Aura] Implement views-based applist. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased and refactored Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/aura_shell/app_list/app_list_view.cc
diff --git a/ui/aura_shell/app_list/app_list_view.cc b/ui/aura_shell/app_list/app_list_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..662962e680934a0bcfd83b856600e3c914505d5c
--- /dev/null
+++ b/ui/aura_shell/app_list/app_list_view.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura_shell/app_list/app_list_view.h"
+
+#include "ui/aura_shell/app_list/app_list_model.h"
+#include "ui/aura_shell/app_list/results_view.h"
+#include "ui/aura_shell/shell.h"
+#include "ui/views/layout/fill_layout.h"
+#include "ui/views/widget/widget.h"
+
+namespace aura_shell {
+
+AppListView::AppListView(
+ AppListModel* model,
+ const gfx::Rect& bounds,
+ const aura_shell::ShellDelegate::SetWidgetCallback& callback)
+ : model_(model),
+ results_view_(new ResultsView(model)) {
+ Init(bounds, callback);
+}
+
+AppListView::~AppListView() {
+}
+
+void AppListView::Close() {
+ if (GetWidget()->IsVisible())
+ Shell::GetInstance()->ToggleAppList();
+}
+
+void AppListView::Init(const gfx::Rect& bounds,
+ const ShellDelegate::SetWidgetCallback& callback) {
+ SetLayoutManager(new views::FillLayout);
+ AddChildView(results_view_);
+
+ views::Widget::InitParams widget_params(
+ views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ widget_params.bounds = bounds;
+ widget_params.delegate = this;
+ widget_params.keep_on_top = true;
+ widget_params.transparent = true;
+
+ views::Widget* widget = new views::Widget;
+ widget->Init(widget_params);
+ widget->SetContentsView(this);
+
+ callback.Run(widget);
+ if (results_view_->GetFocusedTile())
+ results_view_->GetFocusedTile()->RequestFocus();
+}
+
+bool AppListView::OnKeyPressed(const views::KeyEvent& event) {
+ if (event.key_code() == ui::VKEY_ESCAPE) {
+ Close();
+ return true;
+ }
+
+ return false;
+}
+
+bool AppListView::OnMousePressed(const views::MouseEvent& event) {
+ // If mouse click reaches us, this means user clicks on blank area. So close.
+ Close();
+
+ return true;
+}
+
+} // namespace aura_shell

Powered by Google App Engine
This is Rietveld 408576698