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/app_list/app_list_view_delegate_factory.h" | 7 #include "ash/app_list/app_list_view_delegate_factory.h" |
8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return Shelf::ForWindow(window)->SelectValueForShelfAlignment( | 44 return Shelf::ForWindow(window)->SelectValueForShelfAlignment( |
45 views::BubbleBorder::BOTTOM_CENTER, views::BubbleBorder::LEFT_CENTER, | 45 views::BubbleBorder::BOTTOM_CENTER, views::BubbleBorder::LEFT_CENTER, |
46 views::BubbleBorder::RIGHT_CENTER); | 46 views::BubbleBorder::RIGHT_CENTER); |
47 } | 47 } |
48 | 48 |
49 // Using |button_bounds|, determine the anchor offset so that the bubble gets | 49 // Using |button_bounds|, determine the anchor offset so that the bubble gets |
50 // shown above the shelf (used for the alternate shelf theme). | 50 // shown above the shelf (used for the alternate shelf theme). |
51 gfx::Vector2d GetAnchorPositionOffsetToShelf(const gfx::Rect& button_bounds, | 51 gfx::Vector2d GetAnchorPositionOffsetToShelf(const gfx::Rect& button_bounds, |
52 views::Widget* widget) { | 52 views::Widget* widget) { |
53 DCHECK(Shell::HasInstance()); | 53 DCHECK(Shell::HasInstance()); |
54 ShelfAlignment shelf_alignment = | 54 wm::ShelfAlignment shelf_alignment = |
55 Shelf::ForWindow(widget->GetNativeView()->GetRootWindow())->alignment(); | 55 Shelf::ForWindow(widget->GetNativeView()->GetRootWindow())->alignment(); |
56 gfx::Point anchor(button_bounds.CenterPoint()); | 56 gfx::Point anchor(button_bounds.CenterPoint()); |
57 switch (shelf_alignment) { | 57 switch (shelf_alignment) { |
58 case SHELF_ALIGNMENT_BOTTOM: | 58 case wm::SHELF_ALIGNMENT_BOTTOM: |
59 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 59 case wm::SHELF_ALIGNMENT_BOTTOM_LOCKED: |
60 if (base::i18n::IsRTL()) { | 60 if (base::i18n::IsRTL()) { |
61 int screen_width = widget->GetWorkAreaBoundsInScreen().width(); | 61 int screen_width = widget->GetWorkAreaBoundsInScreen().width(); |
62 return gfx::Vector2d( | 62 return gfx::Vector2d( |
63 std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(), | 63 std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(), |
64 0), | 64 0), |
65 0); | 65 0); |
66 } | 66 } |
67 return gfx::Vector2d( | 67 return gfx::Vector2d( |
68 std::max(kMinimalAnchorPositionOffset - anchor.x(), 0), 0); | 68 std::max(kMinimalAnchorPositionOffset - anchor.x(), 0), 0); |
69 case SHELF_ALIGNMENT_LEFT: | 69 case wm::SHELF_ALIGNMENT_LEFT: |
70 return gfx::Vector2d( | 70 return gfx::Vector2d( |
71 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); | 71 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); |
72 case SHELF_ALIGNMENT_RIGHT: | 72 case wm::SHELF_ALIGNMENT_RIGHT: |
73 return gfx::Vector2d( | 73 return gfx::Vector2d( |
74 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); | 74 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); |
75 } | 75 } |
76 NOTREACHED(); | 76 NOTREACHED(); |
77 return gfx::Vector2d(); | 77 return gfx::Vector2d(); |
78 } | 78 } |
79 | 79 |
80 // Gets the point at the center of the display that a particular view is on. | 80 // Gets the point at the center of the display that a particular view is on. |
81 // This calculation excludes the virtual keyboard area. If the height of the | 81 // This calculation excludes the virtual keyboard area. If the height of the |
82 // display area is less than |minimum_height|, its bottom will be extended to | 82 // display area is less than |minimum_height|, its bottom will be extended to |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 339 } |
340 | 340 |
341 //////////////////////////////////////////////////////////////////////////////// | 341 //////////////////////////////////////////////////////////////////////////////// |
342 // AppListPresenterDelegate, ShelfIconObserver implementation: | 342 // AppListPresenterDelegate, ShelfIconObserver implementation: |
343 | 343 |
344 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { | 344 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { |
345 UpdateBounds(); | 345 UpdateBounds(); |
346 } | 346 } |
347 | 347 |
348 } // namespace ash | 348 } // namespace ash |
OLD | NEW |