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