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

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: fix win_aura 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
« no previous file with comments | « ui/aura_shell/app_list/app_list_view.h ('k') | ui/aura_shell/app_list/app_list_view_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_groups_view.h"
8 #include "ui/aura_shell/app_list/app_list_item_view.h"
9 #include "ui/aura_shell/app_list/app_list_model.h"
10 #include "ui/aura_shell/app_list/app_list_view_delegate.h"
11 #include "ui/aura_shell/shell.h"
12 #include "ui/views/layout/fill_layout.h"
13 #include "ui/views/widget/widget.h"
14
15 namespace aura_shell {
16
17 AppListView::AppListView(
18 AppListModel* model,
19 AppListViewDelegate* delegate,
20 const gfx::Rect& bounds,
21 const aura_shell::ShellDelegate::SetWidgetCallback& callback)
22 : model_(model),
23 delegate_(delegate) {
24 Init(bounds, callback);
25 }
26
27 AppListView::~AppListView() {
28 }
29
30 void AppListView::Close() {
31 if (GetWidget()->IsVisible())
32 Shell::GetInstance()->ToggleAppList();
33 }
34
35 void AppListView::Init(const gfx::Rect& bounds,
36 const ShellDelegate::SetWidgetCallback& callback) {
37 SetLayoutManager(new views::FillLayout);
38 AppListGroupsView* groups_view = new AppListGroupsView(model_.get(), this);
39 AddChildView(groups_view);
40
41 views::Widget::InitParams widget_params(
42 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
43 widget_params.bounds = bounds;
44 widget_params.delegate = this;
45 widget_params.keep_on_top = true;
46 widget_params.transparent = true;
47
48 views::Widget* widget = new views::Widget;
49 widget->Init(widget_params);
50 widget->SetContentsView(this);
51
52 callback.Run(widget);
53 if (groups_view->GetFocusedTile())
54 groups_view->GetFocusedTile()->RequestFocus();
55 }
56
57 bool AppListView::OnKeyPressed(const views::KeyEvent& event) {
58 if (event.key_code() == ui::VKEY_ESCAPE) {
59 Close();
60 return true;
61 }
62
63 return false;
64 }
65
66 bool AppListView::OnMousePressed(const views::MouseEvent& event) {
67 // If mouse click reaches us, this means user clicks on blank area. So close.
68 Close();
69
70 return true;
71 }
72
73 void AppListView::AppListItemActivated(AppListItemView* sender,
74 int event_flags) {
75 if (delegate_.get())
76 delegate_->OnAppListItemActivated(sender->model(), event_flags);
77 Close();
78 }
79
80 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/app_list/app_list_view.h ('k') | ui/aura_shell/app_list/app_list_view_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698