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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/aura_shell/app_list/app_list_view.h"
6
7 #include "ui/aura_shell/app_list/app_list_model.h"
8 #include "ui/aura_shell/app_list/results_view.h"
9 #include "ui/aura_shell/shell.h"
10 #include "ui/views/layout/fill_layout.h"
11 #include "ui/views/widget/widget.h"
12
13 namespace aura_shell {
14
15 AppListView::AppListView(
16 AppListModel* model,
17 const gfx::Rect& bounds,
18 const aura_shell::ShellDelegate::SetWidgetCallback& callback)
19 : model_(model),
20 results_view_(new ResultsView(model)) {
21 Init(bounds, callback);
22 }
23
24 AppListView::~AppListView() {
25 }
26
27 void AppListView::Close() {
28 if (GetWidget()->IsVisible())
29 Shell::GetInstance()->ToggleAppList();
30 }
31
32 void AppListView::Init(const gfx::Rect& bounds,
33 const ShellDelegate::SetWidgetCallback& callback) {
34 SetLayoutManager(new views::FillLayout);
35 AddChildView(results_view_);
36
37 views::Widget::InitParams widget_params(
38 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
39 widget_params.bounds = bounds;
40 widget_params.delegate = this;
41 widget_params.keep_on_top = true;
42 widget_params.transparent = true;
43
44 views::Widget* widget = new views::Widget;
45 widget->Init(widget_params);
46 widget->SetContentsView(this);
47
48 callback.Run(widget);
49 if (results_view_->GetFocusedTile())
50 results_view_->GetFocusedTile()->RequestFocus();
51 }
52
53 bool AppListView::OnKeyPressed(const views::KeyEvent& event) {
54 if (event.key_code() == ui::VKEY_ESCAPE) {
55 Close();
56 return true;
57 }
58
59 return false;
60 }
61
62 bool AppListView::OnMousePressed(const views::MouseEvent& event) {
63 // If mouse click reaches us, this means user clicks on blank area. So close.
64 Close();
65
66 return true;
67 }
68
69 } // namespace aura_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698