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

Side by Side Diff: ash/app_list/app_list.cc

Issue 10381018: ash: First pass of Applist v2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 7 months 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 | « ash/app_list/app_list.h ('k') | ash/app_list/app_list_bubble_border.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/app_list/app_list.h" 5 #include "ash/app_list/app_list.h"
6 6
7 #include "ash/app_list/app_list_view.h" 7 #include "ash/app_list/app_list_view.h"
8 #include "ash/app_list/icon_cache.h" 8 #include "ash/app_list/icon_cache.h"
9 #include "ash/ash_switches.h"
9 #include "ash/shell.h" 10 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 11 #include "ash/shell_delegate.h"
11 #include "ash/shell_window_ids.h" 12 #include "ash/shell_window_ids.h"
12 #include "ash/wm/shelf_layout_manager.h" 13 #include "ash/wm/shelf_layout_manager.h"
13 #include "ash/wm/window_util.h" 14 #include "ash/wm/window_util.h"
15 #include "base/command_line.h"
14 #include "ui/aura/event.h" 16 #include "ui/aura/event.h"
15 #include "ui/aura/root_window.h" 17 #include "ui/aura/root_window.h"
16 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
17 #include "ui/compositor/layer.h" 19 #include "ui/compositor/layer.h"
18 #include "ui/compositor/scoped_layer_animation_settings.h" 20 #include "ui/compositor/scoped_layer_animation_settings.h"
19 #include "ui/gfx/screen.h"
20 #include "ui/gfx/transform_util.h" 21 #include "ui/gfx/transform_util.h"
21 22
22 namespace ash { 23 namespace ash {
23 namespace internal { 24 namespace internal {
24 25
25 namespace { 26 namespace {
26 27
27 const float kContainerAnimationScaleFactor = 1.05f; 28 const float kContainerAnimationScaleFactor = 1.05f;
28 29
29 // Duration for both default container and app list animation in milliseconds. 30 // Duration for both default container and app list animation in milliseconds.
30 const int kAnimationDurationMs = 130; 31 const int kAnimationDurationMs = 130;
31 32
32 // Delayed time of 2nd animation in milliseconds. 33 // Delayed time of 2nd animation in milliseconds.
33 const int kSecondAnimationStartDelay = kAnimationDurationMs - 20; 34 const int kSecondAnimationStartDelay = kAnimationDurationMs - 20;
34 35
35 // Gets preferred bounds of app list window.
36 gfx::Rect GetPreferredBounds() {
37 gfx::Point cursor = gfx::Screen::GetCursorScreenPoint();
38 // Use full monitor rect so that the app list shade goes behind the launcher.
39 return gfx::Screen::GetMonitorNearestPoint(cursor).bounds();
40 }
41
42 ui::Layer* GetLayer(views::Widget* widget) { 36 ui::Layer* GetLayer(views::Widget* widget) {
43 return widget->GetNativeView()->layer(); 37 return widget->GetNativeView()->layer();
44 } 38 }
45 39
46 } // namespace 40 } // namespace
47 41
48 //////////////////////////////////////////////////////////////////////////////// 42 ////////////////////////////////////////////////////////////////////////////////
49 // AppList, public: 43 // AppList, public:
50 44
51 AppList::AppList() : is_visible_(false), view_(NULL) { 45 AppList::AppList() : is_visible_(false), view_(NULL) {
52 IconCache::CreateInstance(); 46 IconCache::CreateInstance();
53 } 47 }
54 48
55 AppList::~AppList() { 49 AppList::~AppList() {
56 ResetView(); 50 ResetView();
57 IconCache::DeleteInstance(); 51 IconCache::DeleteInstance();
58 } 52 }
59 53
54 // static
55 bool AppList::UseAppListV2() {
56 return CommandLine::ForCurrentProcess()->HasSwitch(
57 switches::kEnableAppListV2);
58 }
59
60 void AppList::SetVisible(bool visible) { 60 void AppList::SetVisible(bool visible) {
61 if (visible == is_visible_) 61 if (visible == is_visible_)
62 return; 62 return;
63 63
64 is_visible_ = visible; 64 is_visible_ = visible;
65 65
66 // App list needs to know the new shelf layout in order to calculate its 66 // App list needs to know the new shelf layout in order to calculate its
67 // UI layout when AppListView visibility changes. 67 // UI layout when AppListView visibility changes.
68 Shell::GetInstance()->shelf()->UpdateAutoHideState(); 68 Shell::GetInstance()->shelf()->UpdateAutoHideState();
69 69
70 if (view_) { 70 if (view_) {
71 ScheduleAnimation(); 71 ScheduleAnimation();
72 } else if (is_visible_) { 72 } else if (is_visible_) {
73 // AppListModel and AppListViewDelegate are owned by AppListView. They 73 // AppListModel and AppListViewDelegate are owned by AppListView. They
74 // will be released with AppListView on close. 74 // will be released with AppListView on close.
75 SetView(new AppListView( 75 SetView(new AppListView(
76 Shell::GetInstance()->delegate()->CreateAppListViewDelegate(), 76 Shell::GetInstance()->delegate()->CreateAppListViewDelegate()));
77 GetPreferredBounds()));
78 } 77 }
79 } 78 }
80 79
81 bool AppList::IsVisible() { 80 bool AppList::IsVisible() {
82 return view_ && view_->GetWidget()->IsVisible(); 81 return view_ && view_->GetWidget()->IsVisible();
83 } 82 }
84 83
85 aura::Window* AppList::GetWindow() { 84 aura::Window* AppList::GetWindow() {
86 return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL; 85 return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL;
87 } 86 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 124 }
126 125
127 void AppList::ScheduleAnimation() { 126 void AppList::ScheduleAnimation() {
128 second_animation_timer_.Stop(); 127 second_animation_timer_.Stop();
129 128
130 // Stop observing previous animation. 129 // Stop observing previous animation.
131 StopObservingImplicitAnimations(); 130 StopObservingImplicitAnimations();
132 131
133 ScheduleDimmingAnimation(); 132 ScheduleDimmingAnimation();
134 133
134 // No browser window fading and app list secondary animation for v2.
135 if (UseAppListV2())
136 return;
137
135 if (is_visible_) { 138 if (is_visible_) {
136 ScheduleBrowserWindowsAnimation(); 139 ScheduleBrowserWindowsAnimation();
137 second_animation_timer_.Start( 140 second_animation_timer_.Start(
138 FROM_HERE, 141 FROM_HERE,
139 base::TimeDelta::FromMilliseconds(kSecondAnimationStartDelay), 142 base::TimeDelta::FromMilliseconds(kSecondAnimationStartDelay),
140 this, 143 this,
141 &AppList::ScheduleAppListAnimation); 144 &AppList::ScheduleAppListAnimation);
142 } else { 145 } else {
143 ScheduleAppListAnimation(); 146 ScheduleAppListAnimation();
144 second_animation_timer_.Start( 147 second_animation_timer_.Start(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 aura::Window* always_on_top_container = Shell::GetInstance()->GetContainer( 183 aura::Window* always_on_top_container = Shell::GetInstance()->GetContainer(
181 internal::kShellWindowId_AlwaysOnTopContainer); 184 internal::kShellWindowId_AlwaysOnTopContainer);
182 if (always_on_top_container) 185 if (always_on_top_container)
183 ScheduleBrowserWindowsAnimationForContainer(always_on_top_container); 186 ScheduleBrowserWindowsAnimationForContainer(always_on_top_container);
184 } 187 }
185 188
186 void AppList::ScheduleDimmingAnimation() { 189 void AppList::ScheduleDimmingAnimation() {
187 ui::Layer* layer = GetLayer(view_->GetWidget()); 190 ui::Layer* layer = GetLayer(view_->GetWidget());
188 layer->GetAnimator()->StopAnimating(); 191 layer->GetAnimator()->StopAnimating();
189 192
193 int duration = UseAppListV2() ?
194 kAnimationDurationMs : 2 * kAnimationDurationMs;
195
190 ui::ScopedLayerAnimationSettings animation(layer->GetAnimator()); 196 ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
191 animation.SetTransitionDuration( 197 animation.SetTransitionDuration(
192 base::TimeDelta::FromMilliseconds(2 * kAnimationDurationMs)); 198 base::TimeDelta::FromMilliseconds(duration));
193 animation.AddObserver(this); 199 animation.AddObserver(this);
194 200
195 layer->SetOpacity(is_visible_ ? 1.0 : 0.0); 201 layer->SetOpacity(is_visible_ ? 1.0 : 0.0);
196 } 202 }
197 203
198 void AppList::ScheduleAppListAnimation() { 204 void AppList::ScheduleAppListAnimation() {
199 if (is_visible_) 205 if (is_visible_)
200 view_->AnimateShow(kAnimationDurationMs); 206 view_->AnimateShow(kAnimationDurationMs);
201 else 207 else
202 view_->AnimateHide(kAnimationDurationMs); 208 view_->AnimateHide(kAnimationDurationMs);
(...skipping 26 matching lines...) Expand all
229 ui::GestureStatus AppList::PreHandleGestureEvent( 235 ui::GestureStatus AppList::PreHandleGestureEvent(
230 aura::Window* target, 236 aura::Window* target,
231 aura::GestureEvent* event) { 237 aura::GestureEvent* event) {
232 return ui::GESTURE_STATUS_UNKNOWN; 238 return ui::GESTURE_STATUS_UNKNOWN;
233 } 239 }
234 240
235 //////////////////////////////////////////////////////////////////////////////// 241 ////////////////////////////////////////////////////////////////////////////////
236 // AppList, ura::RootWindowObserver implementation: 242 // AppList, ura::RootWindowObserver implementation:
237 void AppList::OnRootWindowResized(const aura::RootWindow* root, 243 void AppList::OnRootWindowResized(const aura::RootWindow* root,
238 const gfx::Size& old_size) { 244 const gfx::Size& old_size) {
239 if (view_&& is_visible_) 245 if (view_ && is_visible_)
240 view_->GetWidget()->SetBounds(gfx::Rect(root->bounds().size())); 246 view_->UpdateBounds();
241 } 247 }
242 248
243 void AppList::OnWindowFocused(aura::Window* window) { 249 void AppList::OnWindowFocused(aura::Window* window) {
244 if (view_ && is_visible_) { 250 if (view_ && is_visible_) {
245 aura::Window* applist_container = Shell::GetInstance()->GetContainer( 251 aura::Window* applist_container = Shell::GetInstance()->GetContainer(
246 internal::kShellWindowId_AppListContainer); 252 internal::kShellWindowId_AppListContainer);
247 aura::Window* bubble_container = Shell::GetInstance()->GetContainer( 253 aura::Window* bubble_container = Shell::GetInstance()->GetContainer(
248 internal::kShellWindowId_SettingBubbleContainer); 254 internal::kShellWindowId_SettingBubbleContainer);
249 if (window->parent() != applist_container && 255 if (window->parent() != applist_container &&
250 window->parent() != bubble_container) { 256 window->parent() != bubble_container) {
(...skipping 17 matching lines...) Expand all
268 274
269 void AppList::OnWidgetClosing(views::Widget* widget) { 275 void AppList::OnWidgetClosing(views::Widget* widget) {
270 DCHECK(view_->GetWidget() == widget); 276 DCHECK(view_->GetWidget() == widget);
271 if (is_visible_) 277 if (is_visible_)
272 SetVisible(false); 278 SetVisible(false);
273 ResetView(); 279 ResetView();
274 } 280 }
275 281
276 } // namespace internal 282 } // namespace internal
277 } // namespace ash 283 } // namespace ash
OLDNEW
« no previous file with comments | « ash/app_list/app_list.h ('k') | ash/app_list/app_list_bubble_border.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698