| 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/app_list/app_list_presenter_delegate.h" | 5 #include "ash/app_list/app_list_presenter_delegate.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/public/cpp/shelf_types.h" | 8 #include "ash/public/cpp/shelf_types.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // UI layout when AppListView visibility changes. | 92 // UI layout when AppListView visibility changes. |
| 93 ash::Shell::GetPrimaryRootWindowController() | 93 ash::Shell::GetPrimaryRootWindowController() |
| 94 ->GetShelfLayoutManager() | 94 ->GetShelfLayoutManager() |
| 95 ->UpdateAutoHideState(); | 95 ->UpdateAutoHideState(); |
| 96 view_ = view; | 96 view_ = view; |
| 97 WmWindow* wm_root_window = | 97 WmWindow* wm_root_window = |
| 98 ShellPort::Get()->GetRootWindowForDisplayId(display_id); | 98 ShellPort::Get()->GetRootWindowForDisplayId(display_id); |
| 99 aura::Window* root_window = wm_root_window->aura_window(); | 99 aura::Window* root_window = wm_root_window->aura_window(); |
| 100 aura::Window* container = GetRootWindowController(root_window) | 100 aura::Window* container = GetRootWindowController(root_window) |
| 101 ->GetContainer(kShellWindowId_AppListContainer); | 101 ->GetContainer(kShellWindowId_AppListContainer); |
| 102 view->InitAsBubble(container, current_apps_page); |
| 103 // The app list is centered over the display. |
| 104 view->SetAnchorPoint(GetCenterOfDisplayForWindow( |
| 105 wm_root_window, GetMinimumBoundsHeightForAppList(view))); |
| 102 | 106 |
| 103 view->Initialize(container, current_apps_page); | |
| 104 | |
| 105 if (!app_list::switches::IsFullscreenAppListEnabled()) { | |
| 106 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( | |
| 107 wm_root_window, GetMinimumBoundsHeightForAppList(view))); | |
| 108 } | |
| 109 keyboard::KeyboardController* keyboard_controller = | 107 keyboard::KeyboardController* keyboard_controller = |
| 110 keyboard::KeyboardController::GetInstance(); | 108 keyboard::KeyboardController::GetInstance(); |
| 111 if (keyboard_controller) | 109 if (keyboard_controller) |
| 112 keyboard_controller->AddObserver(this); | 110 keyboard_controller->AddObserver(this); |
| 113 Shell::Get()->AddPreTargetHandler(this); | 111 Shell::Get()->AddPreTargetHandler(this); |
| 114 WmShelf* shelf = WmShelf::ForWindow(wm_root_window); | 112 WmShelf* shelf = WmShelf::ForWindow(wm_root_window); |
| 115 shelf->AddObserver(this); | 113 shelf->AddObserver(this); |
| 116 | 114 |
| 117 // By setting us as DnD recipient, the app list knows that we can | 115 // By setting us as DnD recipient, the app list knows that we can |
| 118 // handle items. | 116 // handle items. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 143 WmShelf::ForWindow(window)->shelf_widget()->GetAppListButton(); | 141 WmShelf::ForWindow(window)->shelf_widget()->GetAppListButton(); |
| 144 if (app_list_button) | 142 if (app_list_button) |
| 145 app_list_button->OnAppListDismissed(); | 143 app_list_button->OnAppListDismissed(); |
| 146 } | 144 } |
| 147 | 145 |
| 148 void AppListPresenterDelegate::UpdateBounds() { | 146 void AppListPresenterDelegate::UpdateBounds() { |
| 149 if (!view_ || !is_visible_) | 147 if (!view_ || !is_visible_) |
| 150 return; | 148 return; |
| 151 | 149 |
| 152 view_->UpdateBounds(); | 150 view_->UpdateBounds(); |
| 153 view_->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( | 151 view_->SetAnchorPoint(GetCenterOfDisplayForWindow( |
| 154 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), | 152 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), |
| 155 GetMinimumBoundsHeightForAppList(view_))); | 153 GetMinimumBoundsHeightForAppList(view_))); |
| 156 } | 154 } |
| 157 | 155 |
| 158 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( | 156 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( |
| 159 aura::Window* root_window) { | 157 aura::Window* root_window) { |
| 160 DCHECK(Shell::HasInstance()); | 158 DCHECK(Shell::HasInstance()); |
| 161 | 159 |
| 162 // App list needs to know the new shelf layout in order to calculate its | 160 // App list needs to know the new shelf layout in order to calculate its |
| 163 // UI layout when AppListView visibility changes. | 161 // UI layout when AppListView visibility changes. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 239 } |
| 242 | 240 |
| 243 //////////////////////////////////////////////////////////////////////////////// | 241 //////////////////////////////////////////////////////////////////////////////// |
| 244 // AppListPresenterDelegate, WmShelfObserver implementation: | 242 // AppListPresenterDelegate, WmShelfObserver implementation: |
| 245 | 243 |
| 246 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { | 244 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { |
| 247 UpdateBounds(); | 245 UpdateBounds(); |
| 248 } | 246 } |
| 249 | 247 |
| 250 } // namespace ash | 248 } // namespace ash |
| OLD | NEW |