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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
9 #include "ash/common/shelf/app_list_button.h" | 9 #include "ash/common/shelf/app_list_button.h" |
10 #include "ash/common/shelf/shelf.h" | 10 #include "ash/common/shelf/shelf.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 namespace { | 37 namespace { |
38 | 38 |
39 // The minimal anchor position offset to make sure that the bubble is still on | 39 // The minimal anchor position offset to make sure that the bubble is still on |
40 // the screen with 8 pixels spacing on the left / right. This constant is a | 40 // the screen with 8 pixels spacing on the left / right. This constant is a |
41 // result of minimal bubble arrow sizes and offsets. | 41 // result of minimal bubble arrow sizes and offsets. |
42 const int kMinimalAnchorPositionOffset = 57; | 42 const int kMinimalAnchorPositionOffset = 57; |
43 | 43 |
44 // Gets arrow location based on shelf alignment. | 44 // Gets arrow location based on shelf alignment. |
45 views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) { | 45 views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) { |
46 DCHECK(Shell::HasInstance()); | 46 DCHECK(Shell::HasInstance()); |
47 switch (Shelf::ForWindow(WmWindowAura::Get(window))->alignment()) { | 47 WmShelf* shelf = Shelf::ForWindow(WmWindowAura::Get(window))->wm_shelf(); |
| 48 switch (shelf->alignment()) { |
48 case SHELF_ALIGNMENT_BOTTOM: | 49 case SHELF_ALIGNMENT_BOTTOM: |
49 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 50 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
50 return views::BubbleBorder::BOTTOM_CENTER; | 51 return views::BubbleBorder::BOTTOM_CENTER; |
51 case SHELF_ALIGNMENT_LEFT: | 52 case SHELF_ALIGNMENT_LEFT: |
52 return views::BubbleBorder::LEFT_CENTER; | 53 return views::BubbleBorder::LEFT_CENTER; |
53 case SHELF_ALIGNMENT_RIGHT: | 54 case SHELF_ALIGNMENT_RIGHT: |
54 return views::BubbleBorder::RIGHT_CENTER; | 55 return views::BubbleBorder::RIGHT_CENTER; |
55 } | 56 } |
56 NOTREACHED(); | 57 NOTREACHED(); |
57 return views::BubbleBorder::BOTTOM_CENTER; | 58 return views::BubbleBorder::BOTTOM_CENTER; |
58 } | 59 } |
59 | 60 |
60 // Using |button_bounds|, determine the anchor offset so that the bubble gets | 61 // Using |button_bounds|, determine the anchor offset so that the bubble gets |
61 // shown above the shelf (used for the alternate shelf theme). | 62 // shown above the shelf (used for the alternate shelf theme). |
62 gfx::Vector2d GetAnchorPositionOffsetToShelf(const gfx::Rect& button_bounds, | 63 gfx::Vector2d GetAnchorPositionOffsetToShelf(const gfx::Rect& button_bounds, |
63 views::Widget* widget) { | 64 views::Widget* widget) { |
64 DCHECK(Shell::HasInstance()); | 65 DCHECK(Shell::HasInstance()); |
65 ShelfAlignment shelf_alignment = | 66 ShelfAlignment shelf_alignment = |
66 Shelf::ForWindow(WmLookup::Get()->GetWindowForWidget(widget)) | 67 Shelf::ForWindow(WmLookup::Get()->GetWindowForWidget(widget)) |
| 68 ->wm_shelf() |
67 ->alignment(); | 69 ->alignment(); |
68 gfx::Point anchor(button_bounds.CenterPoint()); | 70 gfx::Point anchor(button_bounds.CenterPoint()); |
69 switch (shelf_alignment) { | 71 switch (shelf_alignment) { |
70 case SHELF_ALIGNMENT_BOTTOM: | 72 case SHELF_ALIGNMENT_BOTTOM: |
71 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 73 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
72 if (base::i18n::IsRTL()) { | 74 if (base::i18n::IsRTL()) { |
73 int screen_width = widget->GetWorkAreaBoundsInScreen().width(); | 75 int screen_width = widget->GetWorkAreaBoundsInScreen().width(); |
74 return gfx::Vector2d( | 76 return gfx::Vector2d( |
75 std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(), | 77 std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(), |
76 0), | 78 0), |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 254 |
253 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( | 255 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( |
254 aura::Window* root_window) { | 256 aura::Window* root_window) { |
255 DCHECK(Shell::HasInstance()); | 257 DCHECK(Shell::HasInstance()); |
256 | 258 |
257 // 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 |
258 // UI layout when AppListView visibility changes. | 260 // UI layout when AppListView visibility changes. |
259 Shelf* shelf = Shelf::ForWindow(WmWindowAura::Get(root_window)); | 261 Shelf* shelf = Shelf::ForWindow(WmWindowAura::Get(root_window)); |
260 shelf->shelf_layout_manager()->UpdateAutoHideState(); | 262 shelf->shelf_layout_manager()->UpdateAutoHideState(); |
261 | 263 |
262 switch (shelf->alignment()) { | 264 switch (shelf->wm_shelf()->alignment()) { |
263 case SHELF_ALIGNMENT_BOTTOM: | 265 case SHELF_ALIGNMENT_BOTTOM: |
264 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 266 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
265 return gfx::Vector2d(0, kAnimationOffset); | 267 return gfx::Vector2d(0, kAnimationOffset); |
266 case SHELF_ALIGNMENT_LEFT: | 268 case SHELF_ALIGNMENT_LEFT: |
267 return gfx::Vector2d(-kAnimationOffset, 0); | 269 return gfx::Vector2d(-kAnimationOffset, 0); |
268 case SHELF_ALIGNMENT_RIGHT: | 270 case SHELF_ALIGNMENT_RIGHT: |
269 return gfx::Vector2d(kAnimationOffset, 0); | 271 return gfx::Vector2d(kAnimationOffset, 0); |
270 } | 272 } |
271 NOTREACHED(); | 273 NOTREACHED(); |
272 return gfx::Vector2d(); | 274 return gfx::Vector2d(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 357 } |
356 | 358 |
357 //////////////////////////////////////////////////////////////////////////////// | 359 //////////////////////////////////////////////////////////////////////////////// |
358 // AppListPresenterDelegate, WmShelfObserver implementation: | 360 // AppListPresenterDelegate, WmShelfObserver implementation: |
359 | 361 |
360 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { | 362 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { |
361 UpdateBounds(); | 363 UpdateBounds(); |
362 } | 364 } |
363 | 365 |
364 } // namespace ash | 366 } // namespace ash |
OLD | NEW |