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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 void AppListPresenterDelegate::Init(app_list::AppListView* view, | 89 void AppListPresenterDelegate::Init(app_list::AppListView* view, |
90 int64_t display_id, | 90 int64_t display_id, |
91 int current_apps_page) { | 91 int current_apps_page) { |
92 // App list needs to know the new shelf layout in order to calculate its | 92 // App list needs to know the new shelf layout in order to calculate its |
93 // UI layout when AppListView visibility changes. | 93 // UI layout when AppListView visibility changes. |
94 ash::Shell::GetPrimaryRootWindowController() | 94 ash::Shell::GetPrimaryRootWindowController() |
95 ->GetShelfLayoutManager() | 95 ->GetShelfLayoutManager() |
96 ->UpdateAutoHideState(); | 96 ->UpdateAutoHideState(); |
97 view_ = view; | 97 view_ = view; |
98 WmWindow* wm_root_window = | 98 aura::Window* root_window = |
99 ShellPort::Get()->GetRootWindowForDisplayId(display_id); | 99 ShellPort::Get()->GetRootWindowForDisplayId(display_id); |
100 aura::Window* root_window = wm_root_window->aura_window(); | |
101 aura::Window* container = GetRootWindowController(root_window) | 100 aura::Window* container = GetRootWindowController(root_window) |
102 ->GetContainer(kShellWindowId_AppListContainer); | 101 ->GetContainer(kShellWindowId_AppListContainer); |
103 | 102 |
104 view->Initialize(container, current_apps_page); | 103 view->Initialize(container, current_apps_page); |
105 | 104 |
106 if (!app_list::features::IsFullscreenAppListEnabled()) { | 105 if (!app_list::features::IsFullscreenAppListEnabled()) { |
107 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( | 106 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( |
108 wm_root_window, GetMinimumBoundsHeightForAppList(view))); | 107 WmWindow::Get(root_window), GetMinimumBoundsHeightForAppList(view))); |
109 } | 108 } |
110 keyboard::KeyboardController* keyboard_controller = | 109 keyboard::KeyboardController* keyboard_controller = |
111 keyboard::KeyboardController::GetInstance(); | 110 keyboard::KeyboardController::GetInstance(); |
112 if (keyboard_controller) | 111 if (keyboard_controller) |
113 keyboard_controller->AddObserver(this); | 112 keyboard_controller->AddObserver(this); |
114 Shell::Get()->AddPreTargetHandler(this); | 113 Shell::Get()->AddPreTargetHandler(this); |
115 WmShelf* shelf = WmShelf::ForWindow(wm_root_window); | 114 WmShelf* shelf = WmShelf::ForWindow(root_window); |
116 shelf->AddObserver(this); | 115 shelf->AddObserver(this); |
117 | 116 |
118 // By setting us as DnD recipient, the app list knows that we can | 117 // By setting us as DnD recipient, the app list knows that we can |
119 // handle items. | 118 // handle items. |
120 view->SetDragAndDropHostOfCurrentAppList( | 119 view->SetDragAndDropHostOfCurrentAppList( |
121 shelf->shelf_widget()->GetDragAndDropHostForAppList()); | 120 shelf->shelf_widget()->GetDragAndDropHostForAppList()); |
122 } | 121 } |
123 | 122 |
124 void AppListPresenterDelegate::OnShown(int64_t display_id) { | 123 void AppListPresenterDelegate::OnShown(int64_t display_id) { |
125 is_visible_ = true; | 124 is_visible_ = true; |
126 // Update applist button status when app list visibility is changed. | 125 // Update applist button status when app list visibility is changed. |
127 WmWindow* root_window = | 126 aura::Window* root_window = |
128 ShellPort::Get()->GetRootWindowForDisplayId(display_id); | 127 ShellPort::Get()->GetRootWindowForDisplayId(display_id); |
129 AppListButton* app_list_button = | 128 AppListButton* app_list_button = |
130 WmShelf::ForWindow(root_window)->shelf_widget()->GetAppListButton(); | 129 WmShelf::ForWindow(root_window)->shelf_widget()->GetAppListButton(); |
131 if (app_list_button) | 130 if (app_list_button) |
132 app_list_button->OnAppListShown(); | 131 app_list_button->OnAppListShown(); |
133 } | 132 } |
134 | 133 |
135 void AppListPresenterDelegate::OnDismissed() { | 134 void AppListPresenterDelegate::OnDismissed() { |
136 DCHECK(is_visible_); | 135 DCHECK(is_visible_); |
137 DCHECK(view_); | 136 DCHECK(view_); |
138 | 137 |
139 is_visible_ = false; | 138 is_visible_ = false; |
140 | 139 |
141 // Update applist button status when app list visibility is changed. | 140 // Update applist button status when app list visibility is changed. |
142 WmWindow* window = WmWindow::Get(view_->GetWidget()->GetNativeWindow()); | 141 WmShelf* shelf = WmShelf::ForWindow(view_->GetWidget()->GetNativeWindow()); |
143 AppListButton* app_list_button = | 142 AppListButton* app_list_button = shelf->shelf_widget()->GetAppListButton(); |
144 WmShelf::ForWindow(window)->shelf_widget()->GetAppListButton(); | |
145 if (app_list_button) | 143 if (app_list_button) |
146 app_list_button->OnAppListDismissed(); | 144 app_list_button->OnAppListDismissed(); |
147 } | 145 } |
148 | 146 |
149 void AppListPresenterDelegate::UpdateBounds() { | 147 void AppListPresenterDelegate::UpdateBounds() { |
150 if (!view_ || !is_visible_) | 148 if (!view_ || !is_visible_) |
151 return; | 149 return; |
152 | 150 |
153 view_->UpdateBounds(); | 151 view_->UpdateBounds(); |
154 view_->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( | 152 view_->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( |
155 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), | 153 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), |
156 GetMinimumBoundsHeightForAppList(view_))); | 154 GetMinimumBoundsHeightForAppList(view_))); |
157 } | 155 } |
158 | 156 |
159 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( | 157 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( |
160 aura::Window* root_window) { | 158 aura::Window* root_window) { |
161 DCHECK(Shell::HasInstance()); | 159 DCHECK(Shell::HasInstance()); |
162 | 160 |
163 // App list needs to know the new shelf layout in order to calculate its | 161 // App list needs to know the new shelf layout in order to calculate its |
164 // UI layout when AppListView visibility changes. | 162 // UI layout when AppListView visibility changes. |
165 WmShelf* shelf = WmShelf::ForWindow(WmWindow::Get(root_window)); | 163 WmShelf* shelf = WmShelf::ForWindow(root_window); |
166 shelf->UpdateAutoHideState(); | 164 shelf->UpdateAutoHideState(); |
167 | 165 |
168 switch (shelf->alignment()) { | 166 switch (shelf->alignment()) { |
169 case SHELF_ALIGNMENT_BOTTOM: | 167 case SHELF_ALIGNMENT_BOTTOM: |
170 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 168 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
171 return gfx::Vector2d(0, kAnimationOffset); | 169 return gfx::Vector2d(0, kAnimationOffset); |
172 case SHELF_ALIGNMENT_LEFT: | 170 case SHELF_ALIGNMENT_LEFT: |
173 return gfx::Vector2d(-kAnimationOffset, 0); | 171 return gfx::Vector2d(-kAnimationOffset, 0); |
174 case SHELF_ALIGNMENT_RIGHT: | 172 case SHELF_ALIGNMENT_RIGHT: |
175 return gfx::Vector2d(kAnimationOffset, 0); | 173 return gfx::Vector2d(kAnimationOffset, 0); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 240 } |
243 | 241 |
244 //////////////////////////////////////////////////////////////////////////////// | 242 //////////////////////////////////////////////////////////////////////////////// |
245 // AppListPresenterDelegate, WmShelfObserver implementation: | 243 // AppListPresenterDelegate, WmShelfObserver implementation: |
246 | 244 |
247 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { | 245 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { |
248 UpdateBounds(); | 246 UpdateBounds(); |
249 } | 247 } |
250 | 248 |
251 } // namespace ash | 249 } // namespace ash |
OLD | NEW |