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

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

Issue 2228713003: mash: Convert ShelfView to wm common types, clean up Shelf access (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix control reaches end of non-void function warnings Created 4 years, 4 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
« no previous file with comments | « ash/app_list/app_list_presenter_delegate.h ('k') | ash/ash.gyp » ('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_presenter_delegate.h" 5 #include "ash/app_list/app_list_presenter_delegate.h"
6 6
7 #include "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/shelf/app_list_button.h" 8 #include "ash/common/shelf/app_list_button.h"
9 #include "ash/common/shelf/shelf_types.h" 9 #include "ash/common/shelf/shelf_types.h"
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
(...skipping 23 matching lines...) Expand all
34 namespace { 34 namespace {
35 35
36 // The minimal anchor position offset to make sure that the bubble is still on 36 // The minimal anchor position offset to make sure that the bubble is still on
37 // the screen with 8 pixels spacing on the left / right. This constant is a 37 // the screen with 8 pixels spacing on the left / right. This constant is a
38 // result of minimal bubble arrow sizes and offsets. 38 // result of minimal bubble arrow sizes and offsets.
39 const int kMinimalAnchorPositionOffset = 57; 39 const int kMinimalAnchorPositionOffset = 57;
40 40
41 // Gets arrow location based on shelf alignment. 41 // Gets arrow location based on shelf alignment.
42 views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) { 42 views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) {
43 DCHECK(Shell::HasInstance()); 43 DCHECK(Shell::HasInstance());
44 return Shelf::ForWindow(window)->SelectValueForShelfAlignment( 44 switch (Shelf::ForWindow(window)->alignment()) {
45 views::BubbleBorder::BOTTOM_CENTER, views::BubbleBorder::LEFT_CENTER, 45 case SHELF_ALIGNMENT_BOTTOM:
46 views::BubbleBorder::RIGHT_CENTER); 46 case SHELF_ALIGNMENT_BOTTOM_LOCKED:
47 return views::BubbleBorder::BOTTOM_CENTER;
48 case SHELF_ALIGNMENT_LEFT:
49 return views::BubbleBorder::LEFT_CENTER;
50 case SHELF_ALIGNMENT_RIGHT:
51 return views::BubbleBorder::RIGHT_CENTER;
52 }
53 NOTREACHED();
54 return views::BubbleBorder::BOTTOM_CENTER;
47 } 55 }
48 56
49 // Using |button_bounds|, determine the anchor offset so that the bubble gets 57 // Using |button_bounds|, determine the anchor offset so that the bubble gets
50 // shown above the shelf (used for the alternate shelf theme). 58 // shown above the shelf (used for the alternate shelf theme).
51 gfx::Vector2d GetAnchorPositionOffsetToShelf(const gfx::Rect& button_bounds, 59 gfx::Vector2d GetAnchorPositionOffsetToShelf(const gfx::Rect& button_bounds,
52 views::Widget* widget) { 60 views::Widget* widget) {
53 DCHECK(Shell::HasInstance()); 61 DCHECK(Shell::HasInstance());
54 ShelfAlignment shelf_alignment = 62 ShelfAlignment shelf_alignment =
55 Shelf::ForWindow(widget->GetNativeView()->GetRootWindow())->alignment(); 63 Shelf::ForWindow(widget->GetNativeView()->GetRootWindow())->alignment();
56 gfx::Point anchor(button_bounds.CenterPoint()); 64 gfx::Point anchor(button_bounds.CenterPoint());
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( 255 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset(
248 aura::Window* root_window) { 256 aura::Window* root_window) {
249 DCHECK(Shell::HasInstance()); 257 DCHECK(Shell::HasInstance());
250 258
251 // App list needs to know the new shelf layout in order to calculate its 259 // App list needs to know the new shelf layout in order to calculate its
252 // UI layout when AppListView visibility changes. 260 // UI layout when AppListView visibility changes.
253 Shell::GetPrimaryRootWindowController() 261 Shell::GetPrimaryRootWindowController()
254 ->GetShelfLayoutManager() 262 ->GetShelfLayoutManager()
255 ->UpdateAutoHideState(); 263 ->UpdateAutoHideState();
256 264
257 return Shelf::ForWindow(root_window) 265 switch (Shelf::ForWindow(root_window)->alignment()) {
258 ->SelectValueForShelfAlignment(gfx::Vector2d(0, kAnimationOffset), 266 case SHELF_ALIGNMENT_BOTTOM:
259 gfx::Vector2d(-kAnimationOffset, 0), 267 case SHELF_ALIGNMENT_BOTTOM_LOCKED:
260 gfx::Vector2d(kAnimationOffset, 0)); 268 return gfx::Vector2d(0, kAnimationOffset);
269 case SHELF_ALIGNMENT_LEFT:
270 return gfx::Vector2d(-kAnimationOffset, 0);
271 case SHELF_ALIGNMENT_RIGHT:
272 return gfx::Vector2d(kAnimationOffset, 0);
273 }
274 NOTREACHED();
275 return gfx::Vector2d();
261 } 276 }
262 277
263 //////////////////////////////////////////////////////////////////////////////// 278 ////////////////////////////////////////////////////////////////////////////////
264 // AppListPresenterDelegate, private: 279 // AppListPresenterDelegate, private:
265 280
266 void AppListPresenterDelegate::ProcessLocatedEvent(ui::LocatedEvent* event) { 281 void AppListPresenterDelegate::ProcessLocatedEvent(ui::LocatedEvent* event) {
267 if (!view_ || !is_visible_) 282 if (!view_ || !is_visible_)
268 return; 283 return;
269 284
270 // If the event happened on a menu, then the event should not close the app 285 // If the event happened on a menu, then the event should not close the app
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 353 }
339 354
340 //////////////////////////////////////////////////////////////////////////////// 355 ////////////////////////////////////////////////////////////////////////////////
341 // AppListPresenterDelegate, ShelfIconObserver implementation: 356 // AppListPresenterDelegate, ShelfIconObserver implementation:
342 357
343 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { 358 void AppListPresenterDelegate::OnShelfIconPositionsChanged() {
344 UpdateBounds(); 359 UpdateBounds();
345 } 360 }
346 361
347 } // namespace ash 362 } // namespace ash
OLDNEW
« no previous file with comments | « ash/app_list/app_list_presenter_delegate.h ('k') | ash/ash.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698