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 is_centered_ = app_list::switches::IsExperimentalAppListPositionEnabled(); |
| 175 if (is_centered_) { |
169 // The experimental app list is centered over the primary display. | 176 // The experimental app list is centered over the primary display. |
170 view->InitAsBubbleCenteredOnPrimaryDisplay( | 177 view->InitAsBubbleAtFixedLocation( |
171 NULL, | 178 NULL, |
172 pagination_model_.get(), | 179 pagination_model_.get(), |
173 Shell::GetScreen(), | 180 GetScreenCenter(), |
174 views::BubbleBorder::FLOAT, | 181 views::BubbleBorder::FLOAT, |
175 true /* border_accepts_events */); | 182 true /* border_accepts_events */); |
176 } else { | 183 } else { |
177 gfx::Rect applist_button_bounds = Shelf::ForWindow(container)-> | 184 gfx::Rect applist_button_bounds = Shelf::ForWindow(container)-> |
178 GetAppListButtonView()->GetBoundsInScreen(); | 185 GetAppListButtonView()->GetBoundsInScreen(); |
179 // We need the location of the button within the local screen. | 186 // We need the location of the button within the local screen. |
180 applist_button_bounds = ScreenUtil::ConvertRectFromScreen( | 187 applist_button_bounds = ScreenUtil::ConvertRectFromScreen( |
181 root_window, | 188 root_window, |
182 applist_button_bounds); | 189 applist_button_bounds); |
183 view->InitAsBubbleAttachedToAnchor( | 190 view->InitAsBubbleAttachedToAnchor( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 return; | 302 return; |
296 } | 303 } |
297 } | 304 } |
298 | 305 |
299 aura::Window* window = view_->GetWidget()->GetNativeView()->parent(); | 306 aura::Window* window = view_->GetWidget()->GetNativeView()->parent(); |
300 if (!window->Contains(target)) | 307 if (!window->Contains(target)) |
301 SetVisible(false, window); | 308 SetVisible(false, window); |
302 } | 309 } |
303 | 310 |
304 void AppListController::UpdateBounds() { | 311 void AppListController::UpdateBounds() { |
305 if (view_ && is_visible_) | 312 if (!view_ || !is_visible_) |
306 view_->UpdateBounds(); | 313 return; |
| 314 |
| 315 view_->UpdateBounds(); |
| 316 |
| 317 if (is_centered_) |
| 318 view_->SetAnchorPoint(GetScreenCenter()); |
307 } | 319 } |
308 | 320 |
309 //////////////////////////////////////////////////////////////////////////////// | 321 //////////////////////////////////////////////////////////////////////////////// |
310 // AppListController, aura::EventFilter implementation: | 322 // AppListController, aura::EventFilter implementation: |
311 | 323 |
312 void AppListController::OnMouseEvent(ui::MouseEvent* event) { | 324 void AppListController::OnMouseEvent(ui::MouseEvent* event) { |
313 if (event->type() == ui::ET_MOUSE_PRESSED) | 325 if (event->type() == ui::ET_MOUSE_PRESSED) |
314 ProcessLocatedEvent(event); | 326 ProcessLocatedEvent(event); |
315 } | 327 } |
316 | 328 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 } else if (should_snap_back_) { | 433 } else if (should_snap_back_) { |
422 should_snap_back_ = false; | 434 should_snap_back_ = false; |
423 ui::ScopedLayerAnimationSettings animation(widget_animator); | 435 ui::ScopedLayerAnimationSettings animation(widget_animator); |
424 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 436 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
425 app_list::kOverscrollPageTransitionDurationMs)); | 437 app_list::kOverscrollPageTransitionDurationMs)); |
426 widget->SetBounds(view_bounds_); | 438 widget->SetBounds(view_bounds_); |
427 } | 439 } |
428 } | 440 } |
429 | 441 |
430 } // namespace ash | 442 } // namespace ash |
OLD | NEW |