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/wm/app_list_controller.h" | 5 #include "ash/wm/app_list_controller.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 ui::Layer* GetLayer(views::Widget* widget) { | 51 ui::Layer* GetLayer(views::Widget* widget) { |
52 return widget->GetNativeView()->layer(); | 52 return widget->GetNativeView()->layer(); |
53 } | 53 } |
54 | 54 |
55 // Gets arrow location based on shelf alignment. | 55 // Gets arrow location based on shelf alignment. |
56 views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) { | 56 views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) { |
57 DCHECK(Shell::HasInstance()); | 57 DCHECK(Shell::HasInstance()); |
58 return Shelf::ForWindow(window)->SelectValueForShelfAlignment( | 58 return Shelf::ForWindow(window)->SelectValueForShelfAlignment( |
59 views::BubbleBorder::BOTTOM_CENTER, views::BubbleBorder::LEFT_CENTER, | 59 views::BubbleBorder::BOTTOM_CENTER, views::BubbleBorder::LEFT_CENTER, |
60 views::BubbleBorder::RIGHT_CENTER, views::BubbleBorder::TOP_CENTER); | 60 views::BubbleBorder::RIGHT_CENTER); |
61 } | 61 } |
62 | 62 |
63 // Offset given |rect| towards shelf. | 63 // Offset given |rect| towards shelf. |
64 gfx::Rect OffsetTowardsShelf(const gfx::Rect& rect, views::Widget* widget) { | 64 gfx::Rect OffsetTowardsShelf(const gfx::Rect& rect, views::Widget* widget) { |
65 DCHECK(Shell::HasInstance()); | 65 DCHECK(Shell::HasInstance()); |
66 ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( | 66 ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( |
67 widget->GetNativeView()->GetRootWindow()); | 67 widget->GetNativeView()->GetRootWindow()); |
68 gfx::Rect offseted(rect); | 68 gfx::Rect offseted(rect); |
69 switch (shelf_alignment) { | 69 switch (shelf_alignment) { |
70 case SHELF_ALIGNMENT_BOTTOM: | 70 case SHELF_ALIGNMENT_BOTTOM: |
71 offseted.Offset(0, kAnimationOffset); | 71 offseted.Offset(0, kAnimationOffset); |
72 break; | 72 break; |
73 case SHELF_ALIGNMENT_LEFT: | 73 case SHELF_ALIGNMENT_LEFT: |
74 offseted.Offset(-kAnimationOffset, 0); | 74 offseted.Offset(-kAnimationOffset, 0); |
75 break; | 75 break; |
76 case SHELF_ALIGNMENT_RIGHT: | 76 case SHELF_ALIGNMENT_RIGHT: |
77 offseted.Offset(kAnimationOffset, 0); | 77 offseted.Offset(kAnimationOffset, 0); |
78 break; | 78 break; |
79 case SHELF_ALIGNMENT_TOP: | |
80 offseted.Offset(0, -kAnimationOffset); | |
81 break; | |
82 } | 79 } |
83 | 80 |
84 return offseted; | 81 return offseted; |
85 } | 82 } |
86 | 83 |
87 // Using |button_bounds|, determine the anchor offset so that the bubble gets | 84 // Using |button_bounds|, determine the anchor offset so that the bubble gets |
88 // shown above the shelf (used for the alternate shelf theme). | 85 // shown above the shelf (used for the alternate shelf theme). |
89 gfx::Vector2d GetAnchorPositionOffsetToShelf( | 86 gfx::Vector2d GetAnchorPositionOffsetToShelf( |
90 const gfx::Rect& button_bounds, views::Widget* widget) { | 87 const gfx::Rect& button_bounds, views::Widget* widget) { |
91 DCHECK(Shell::HasInstance()); | 88 DCHECK(Shell::HasInstance()); |
92 ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( | 89 ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( |
93 widget->GetNativeView()->GetRootWindow()); | 90 widget->GetNativeView()->GetRootWindow()); |
94 gfx::Point anchor(button_bounds.CenterPoint()); | 91 gfx::Point anchor(button_bounds.CenterPoint()); |
95 switch (shelf_alignment) { | 92 switch (shelf_alignment) { |
96 case SHELF_ALIGNMENT_TOP: | |
97 case SHELF_ALIGNMENT_BOTTOM: | 93 case SHELF_ALIGNMENT_BOTTOM: |
98 if (base::i18n::IsRTL()) { | 94 if (base::i18n::IsRTL()) { |
99 int screen_width = widget->GetWorkAreaBoundsInScreen().width(); | 95 int screen_width = widget->GetWorkAreaBoundsInScreen().width(); |
100 return gfx::Vector2d( | 96 return gfx::Vector2d( |
101 std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(), | 97 std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(), |
102 0), 0); | 98 0), 0); |
103 } | 99 } |
104 return gfx::Vector2d( | 100 return gfx::Vector2d( |
105 std::max(kMinimalAnchorPositionOffset - anchor.x(), 0), 0); | 101 std::max(kMinimalAnchorPositionOffset - anchor.x(), 0), 0); |
106 case SHELF_ALIGNMENT_LEFT: | 102 case SHELF_ALIGNMENT_LEFT: |
107 return gfx::Vector2d( | 103 return gfx::Vector2d( |
108 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); | 104 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); |
109 case SHELF_ALIGNMENT_RIGHT: | 105 case SHELF_ALIGNMENT_RIGHT: |
110 return gfx::Vector2d( | 106 return gfx::Vector2d( |
111 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); | 107 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); |
112 default: | |
113 NOTREACHED(); | |
114 return gfx::Vector2d(); | |
115 } | 108 } |
| 109 NOTREACHED(); |
| 110 return gfx::Vector2d(); |
116 } | 111 } |
117 | 112 |
118 // Gets the point at the center of the display that a particular view is on. | 113 // Gets the point at the center of the display that a particular view is on. |
119 // This calculation excludes the virtual keyboard area. If the height of the | 114 // This calculation excludes the virtual keyboard area. If the height of the |
120 // display area is less than |minimum_height|, its bottom will be extended to | 115 // display area is less than |minimum_height|, its bottom will be extended to |
121 // that height (so that the app list never starts above the top of the screen). | 116 // that height (so that the app list never starts above the top of the screen). |
122 gfx::Point GetCenterOfDisplayForView(const views::View* view, | 117 gfx::Point GetCenterOfDisplayForView(const views::View* view, |
123 int minimum_height) { | 118 int minimum_height) { |
124 aura::Window* window = view->GetWidget()->GetNativeView(); | 119 aura::Window* window = view->GetWidget()->GetNativeView(); |
125 gfx::Rect bounds = ScreenUtil::GetShelfDisplayBoundsInRoot(window); | 120 gfx::Rect bounds = ScreenUtil::GetShelfDisplayBoundsInRoot(window); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 } else if (should_snap_back_) { | 548 } else if (should_snap_back_) { |
554 should_snap_back_ = false; | 549 should_snap_back_ = false; |
555 ui::ScopedLayerAnimationSettings animation(widget_animator); | 550 ui::ScopedLayerAnimationSettings animation(widget_animator); |
556 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 551 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
557 app_list::kOverscrollPageTransitionDurationMs)); | 552 app_list::kOverscrollPageTransitionDurationMs)); |
558 widget->SetBounds(view_bounds_); | 553 widget->SetBounds(view_bounds_); |
559 } | 554 } |
560 } | 555 } |
561 | 556 |
562 } // namespace ash | 557 } // namespace ash |
OLD | NEW |