OLD | NEW |
---|---|
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/wm/app_list_controller.h" | 5 #include "ash/wm/app_list_controller.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); | 106 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); |
107 case SHELF_ALIGNMENT_RIGHT: | 107 case SHELF_ALIGNMENT_RIGHT: |
108 return gfx::Vector2d( | 108 return gfx::Vector2d( |
109 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); | 109 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); |
110 default: | 110 default: |
111 NOTREACHED(); | 111 NOTREACHED(); |
112 return gfx::Vector2d(); | 112 return gfx::Vector2d(); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 // Gets the point at the center of the screen. | |
117 gfx::Point GetScreenCenter() { | |
118 return Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint(); | |
119 } | |
120 | |
116 } // namespace | 121 } // namespace |
117 | 122 |
118 //////////////////////////////////////////////////////////////////////////////// | 123 //////////////////////////////////////////////////////////////////////////////// |
119 // AppListController, public: | 124 // AppListController, public: |
120 | 125 |
121 AppListController::AppListController() | 126 AppListController::AppListController() |
122 : pagination_model_(new app_list::PaginationModel), | 127 : pagination_model_(new app_list::PaginationModel), |
123 is_visible_(false), | 128 is_visible_(false), |
129 is_centered_(false), | |
124 view_(NULL), | 130 view_(NULL), |
125 should_snap_back_(false) { | 131 should_snap_back_(false) { |
126 Shell::GetInstance()->AddShellObserver(this); | 132 Shell::GetInstance()->AddShellObserver(this); |
127 pagination_model_->AddObserver(this); | 133 pagination_model_->AddObserver(this); |
128 } | 134 } |
129 | 135 |
130 AppListController::~AppListController() { | 136 AppListController::~AppListController() { |
131 // Ensures app list view goes before the controller since pagination model | 137 // Ensures app list view goes before the controller since pagination model |
132 // lives in the controller and app list view would access it on destruction. | 138 // lives in the controller and app list view would access it on destruction. |
133 if (view_ && view_->GetWidget()) | 139 if (view_ && view_->GetWidget()) |
(...skipping 24 matching lines...) Expand all Loading... | |
158 view_->GetWidget()->Deactivate(); | 164 view_->GetWidget()->Deactivate(); |
159 ScheduleAnimation(); | 165 ScheduleAnimation(); |
160 } else if (is_visible_) { | 166 } else if (is_visible_) { |
161 // AppListModel and AppListViewDelegate are owned by AppListView. They | 167 // AppListModel and AppListViewDelegate are owned by AppListView. They |
162 // will be released with AppListView on close. | 168 // will be released with AppListView on close. |
163 app_list::AppListView* view = new app_list::AppListView( | 169 app_list::AppListView* view = new app_list::AppListView( |
164 Shell::GetInstance()->delegate()->CreateAppListViewDelegate()); | 170 Shell::GetInstance()->delegate()->CreateAppListViewDelegate()); |
165 aura::Window* root_window = window->GetRootWindow(); | 171 aura::Window* root_window = window->GetRootWindow(); |
166 aura::Window* container = GetRootWindowController(root_window)-> | 172 aura::Window* container = GetRootWindowController(root_window)-> |
167 GetContainer(kShellWindowId_AppListContainer); | 173 GetContainer(kShellWindowId_AppListContainer); |
168 if (app_list::switches::IsExperimentalAppListPositionEnabled()) { | 174 if (app_list::switches::IsExperimentalAppListPositionEnabled()) { |
varkha
2014/04/30 16:37:38
nit: maybe:
is_centered_ = app_list::switches::IsE
Matt Giuca
2014/05/01 03:54:32
Done. (Nice)
| |
169 // The experimental app list is centered over the primary display. | 175 // The experimental app list is centered over the primary display. |
170 view->InitAsBubbleCenteredOnPrimaryDisplay( | 176 is_centered_ = true; |
177 view->InitAsBubbleAtFixedLocation( | |
171 NULL, | 178 NULL, |
172 pagination_model_.get(), | 179 pagination_model_.get(), |
173 Shell::GetScreen(), | 180 Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint(), |
varkha
2014/04/30 16:37:38
Could use GetScreenCenter().
Matt Giuca
2014/05/01 03:54:32
I can't find anything called GetScreenCenter or Sc
varkha
2014/05/01 03:57:21
It's a new method in this file's anonymous namespa
Matt Giuca
2014/05/01 04:02:43
/me hits self over head with hammer.
Sorry, I mus
varkha
2014/05/01 04:04:50
Great, you got it in time.
| |
174 views::BubbleBorder::FLOAT, | 181 views::BubbleBorder::FLOAT, |
175 true /* border_accepts_events */); | 182 true /* border_accepts_events */); |
176 } else { | 183 } else { |
184 is_centered_ = false; | |
177 gfx::Rect applist_button_bounds = Shelf::ForWindow(container)-> | 185 gfx::Rect applist_button_bounds = Shelf::ForWindow(container)-> |
178 GetAppListButtonView()->GetBoundsInScreen(); | 186 GetAppListButtonView()->GetBoundsInScreen(); |
179 // We need the location of the button within the local screen. | 187 // We need the location of the button within the local screen. |
180 applist_button_bounds = ScreenUtil::ConvertRectFromScreen( | 188 applist_button_bounds = ScreenUtil::ConvertRectFromScreen( |
181 root_window, | 189 root_window, |
182 applist_button_bounds); | 190 applist_button_bounds); |
183 view->InitAsBubbleAttachedToAnchor( | 191 view->InitAsBubbleAttachedToAnchor( |
184 container, | 192 container, |
185 pagination_model_.get(), | 193 pagination_model_.get(), |
186 Shelf::ForWindow(container)->GetAppListButtonView(), | 194 Shelf::ForWindow(container)->GetAppListButtonView(), |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 return; | 303 return; |
296 } | 304 } |
297 } | 305 } |
298 | 306 |
299 aura::Window* window = view_->GetWidget()->GetNativeView()->parent(); | 307 aura::Window* window = view_->GetWidget()->GetNativeView()->parent(); |
300 if (!window->Contains(target)) | 308 if (!window->Contains(target)) |
301 SetVisible(false, window); | 309 SetVisible(false, window); |
302 } | 310 } |
303 | 311 |
304 void AppListController::UpdateBounds() { | 312 void AppListController::UpdateBounds() { |
305 if (view_ && is_visible_) | 313 if (!view_ || !is_visible_) |
306 view_->UpdateBounds(); | 314 return; |
315 | |
316 view_->UpdateBounds(); | |
317 | |
318 if (is_centered_) | |
319 view_->SetAnchorPoint(GetScreenCenter()); | |
307 } | 320 } |
308 | 321 |
309 //////////////////////////////////////////////////////////////////////////////// | 322 //////////////////////////////////////////////////////////////////////////////// |
310 // AppListController, aura::EventFilter implementation: | 323 // AppListController, aura::EventFilter implementation: |
311 | 324 |
312 void AppListController::OnMouseEvent(ui::MouseEvent* event) { | 325 void AppListController::OnMouseEvent(ui::MouseEvent* event) { |
313 if (event->type() == ui::ET_MOUSE_PRESSED) | 326 if (event->type() == ui::ET_MOUSE_PRESSED) |
314 ProcessLocatedEvent(event); | 327 ProcessLocatedEvent(event); |
315 } | 328 } |
316 | 329 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 } else if (should_snap_back_) { | 434 } else if (should_snap_back_) { |
422 should_snap_back_ = false; | 435 should_snap_back_ = false; |
423 ui::ScopedLayerAnimationSettings animation(widget_animator); | 436 ui::ScopedLayerAnimationSettings animation(widget_animator); |
424 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 437 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
425 app_list::kOverscrollPageTransitionDurationMs)); | 438 app_list::kOverscrollPageTransitionDurationMs)); |
426 widget->SetBounds(view_bounds_); | 439 widget->SetBounds(view_bounds_); |
427 } | 440 } |
428 } | 441 } |
429 | 442 |
430 } // namespace ash | 443 } // namespace ash |
OLD | NEW |