OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/aura_shell/app_list.h" | 5 #include "ui/aura_shell/app_list/app_list.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" |
8 #include "ui/aura/event.h" | 9 #include "ui/aura/event.h" |
9 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 11 #include "ui/aura_shell/app_list/app_list_model.h" |
| 12 #include "ui/aura_shell/app_list/app_list_view.h" |
| 13 #include "ui/aura_shell/aura_shell_switches.h" |
| 14 #include "ui/aura_shell/shell_delegate.h" |
10 #include "ui/aura_shell/shell.h" | 15 #include "ui/aura_shell/shell.h" |
11 #include "ui/aura_shell/shell_delegate.h" | |
12 #include "ui/aura_shell/shell_window_ids.h" | 16 #include "ui/aura_shell/shell_window_ids.h" |
13 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
14 | 18 |
15 namespace aura_shell { | 19 namespace aura_shell { |
16 namespace internal { | 20 namespace internal { |
17 | 21 |
18 namespace { | 22 namespace { |
19 | 23 |
20 // Gets preferred bounds of app list window in show/hide state. | 24 // Gets preferred bounds of app list window in show/hide state. |
21 gfx::Rect GetPreferredBounds(bool show) { | 25 gfx::Rect GetPreferredBounds(bool show) { |
22 // The y-axis offset used at the beginning of showing animation. | 26 // The y-axis offset used at the beginning of showing animation. |
23 static const int kMoveUpAnimationOffset = 50; | 27 static const int kMoveUpAnimationOffset = 50; |
24 | 28 |
25 gfx::Point cursor = gfx::Screen::GetCursorScreenPoint(); | 29 gfx::Point cursor = gfx::Screen::GetCursorScreenPoint(); |
26 gfx::Rect work_area = gfx::Screen::GetMonitorWorkAreaNearestPoint(cursor); | 30 gfx::Rect work_area = gfx::Screen::GetMonitorWorkAreaNearestPoint(cursor); |
27 gfx::Rect widget_bounds(work_area); | 31 gfx::Rect widget_bounds(work_area); |
28 widget_bounds.Inset(150, 100); | 32 widget_bounds.Inset(100, 100); |
29 if (!show) | 33 if (!show) |
30 widget_bounds.Offset(0, kMoveUpAnimationOffset); | 34 widget_bounds.Offset(0, kMoveUpAnimationOffset); |
31 | 35 |
32 return widget_bounds; | 36 return widget_bounds; |
33 } | 37 } |
34 | 38 |
35 ui::Layer* GetLayer(views::Widget* widget) { | 39 ui::Layer* GetLayer(views::Widget* widget) { |
36 return widget->GetNativeView()->layer(); | 40 return widget->GetNativeView()->layer(); |
37 } | 41 } |
38 | 42 |
(...skipping 15 matching lines...) Expand all Loading... |
54 | 58 |
55 void AppList::SetVisible(bool visible) { | 59 void AppList::SetVisible(bool visible) { |
56 if (visible == is_visible_) | 60 if (visible == is_visible_) |
57 return; | 61 return; |
58 | 62 |
59 is_visible_ = visible; | 63 is_visible_ = visible; |
60 | 64 |
61 if (widget_) { | 65 if (widget_) { |
62 ScheduleAnimation(); | 66 ScheduleAnimation(); |
63 } else if (is_visible_ && !set_widget_factory_.HasWeakPtrs()) { | 67 } else if (is_visible_ && !set_widget_factory_.HasWeakPtrs()) { |
64 Shell::GetInstance()->delegate()->RequestAppListWidget( | 68 if (CommandLine::ForCurrentProcess()->HasSwitch( |
65 GetPreferredBounds(false), | 69 switches::kAuraViewsAppList)) { |
66 base::Bind(&AppList::SetWidget, set_widget_factory_.GetWeakPtr())); | 70 scoped_ptr<AppListModel> model(new AppListModel); |
| 71 Shell::GetInstance()->delegate()->BuildAppListModel(model.get()); |
| 72 |
| 73 // AppListModel and AppListViewDelegate are owned by AppListView. They |
| 74 // will be released with AppListView on close. |
| 75 new AppListView( |
| 76 model.release(), |
| 77 Shell::GetInstance()->delegate()->CreateAppListViewDelegate(), |
| 78 GetPreferredBounds(false), |
| 79 base::Bind(&AppList::SetWidget, set_widget_factory_.GetWeakPtr())); |
| 80 } else { |
| 81 Shell::GetInstance()->delegate()->RequestAppListWidget( |
| 82 GetPreferredBounds(false), |
| 83 base::Bind(&AppList::SetWidget, set_widget_factory_.GetWeakPtr())); |
| 84 } |
67 } | 85 } |
68 } | 86 } |
69 | 87 |
70 bool AppList::IsVisible() { | 88 bool AppList::IsVisible() { |
71 return widget_ && widget_->IsVisible(); | 89 return widget_ && widget_->IsVisible(); |
72 } | 90 } |
73 | 91 |
74 //////////////////////////////////////////////////////////////////////////////// | 92 //////////////////////////////////////////////////////////////////////////////// |
75 // AppList, private: | 93 // AppList, private: |
76 | 94 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 186 } |
169 | 187 |
170 void AppList::OnWidgetActivationChanged(views::Widget* widget, bool active) { | 188 void AppList::OnWidgetActivationChanged(views::Widget* widget, bool active) { |
171 DCHECK(widget_ == widget); | 189 DCHECK(widget_ == widget); |
172 if (widget_ && is_visible_ && !active) | 190 if (widget_ && is_visible_ && !active) |
173 SetVisible(false); | 191 SetVisible(false); |
174 } | 192 } |
175 | 193 |
176 } // namespace internal | 194 } // namespace internal |
177 } // namespace aura_shell | 195 } // namespace aura_shell |
OLD | NEW |