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/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 | 32 |
33 // Duration for show/hide animation in milliseconds. | 33 // Duration for show/hide animation in milliseconds. |
34 const int kAnimationDurationMs = 200; | 34 const int kAnimationDurationMs = 200; |
35 | 35 |
36 // Offset in pixels to animation away/towards the launcher. | 36 // Offset in pixels to animation away/towards the launcher. |
37 const int kAnimationOffset = 8; | 37 const int kAnimationOffset = 8; |
38 | 38 |
39 // The maximum shift in pixels when over-scroll happens. | 39 // The maximum shift in pixels when over-scroll happens. |
40 const int kMaxOverScrollShift = 48; | 40 const int kMaxOverScrollShift = 48; |
41 | 41 |
42 // The alternate shelf style adjusts the bubble to be flush with the shelf | |
43 // when there is no bubble-tip. This is the tip height which needs to be | |
44 // offsetted. | |
45 const int kArrowTipHeight = 10; | |
James Cook
2013/09/05 20:05:17
Nice that you found this thing to clean up.
Mr4D (OOO till 08-26)
2013/09/05 20:52:00
Sure thing!
| |
46 | |
47 // The minimal anchor position offset to make sure that the bubble is still on | 42 // The minimal anchor position offset to make sure that the bubble is still on |
48 // the screen with 8 pixels spacing on the left / right. This constant is a | 43 // the screen with 8 pixels spacing on the left / right. This constant is a |
49 // result of minimal bubble arrow sizes and offsets. | 44 // result of minimal bubble arrow sizes and offsets. |
50 const int kMinimalAnchorPositionOffset = 57; | 45 const int kMinimalAnchorPositionOffset = 57; |
51 | 46 |
52 ui::Layer* GetLayer(views::Widget* widget) { | 47 ui::Layer* GetLayer(views::Widget* widget) { |
53 return widget->GetNativeView()->layer(); | 48 return widget->GetNativeView()->layer(); |
54 } | 49 } |
55 | 50 |
56 // Gets arrow location based on shelf alignment. | 51 // Gets arrow location based on shelf alignment. |
(...skipping 24 matching lines...) Expand all Loading... | |
81 offseted.Offset(kAnimationOffset, 0); | 76 offseted.Offset(kAnimationOffset, 0); |
82 break; | 77 break; |
83 case SHELF_ALIGNMENT_TOP: | 78 case SHELF_ALIGNMENT_TOP: |
84 offseted.Offset(0, -kAnimationOffset); | 79 offseted.Offset(0, -kAnimationOffset); |
85 break; | 80 break; |
86 } | 81 } |
87 | 82 |
88 return offseted; | 83 return offseted; |
89 } | 84 } |
90 | 85 |
91 // Using |button_bounds|, determine the anchor so that the bubble gets shown | 86 // Using |button_bounds|, determine the anchor offset so that the bubble gets |
92 // above the shelf (used for the alternate shelf theme). | 87 // shown above the shelf (used for the alternate shelf theme). |
93 gfx::Point GetAdjustAnchorPositionToShelf( | 88 gfx::Point GetAnchorPositionOffsetToShelf( |
94 const gfx::Rect& button_bounds, views::Widget* widget) { | 89 const gfx::Rect& button_bounds, views::Widget* widget) { |
95 DCHECK(Shell::HasInstance()); | 90 DCHECK(Shell::HasInstance()); |
96 ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( | 91 ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( |
97 widget->GetNativeView()->GetRootWindow()); | 92 widget->GetNativeView()->GetRootWindow()); |
98 gfx::Point anchor(button_bounds.CenterPoint()); | 93 gfx::Point anchor(button_bounds.CenterPoint()); |
99 switch (shelf_alignment) { | 94 switch (shelf_alignment) { |
100 case SHELF_ALIGNMENT_TOP: | 95 case SHELF_ALIGNMENT_TOP: |
101 case SHELF_ALIGNMENT_BOTTOM: | 96 case SHELF_ALIGNMENT_BOTTOM: |
102 { | 97 { |
103 if (base::i18n::IsRTL()) { | 98 if (base::i18n::IsRTL()) { |
104 int screen_width = widget->GetWorkAreaBoundsInScreen().width(); | 99 int screen_width = widget->GetWorkAreaBoundsInScreen().width(); |
105 anchor.set_x(std::min(screen_width - kMinimalAnchorPositionOffset, | 100 anchor.set_x( |
106 anchor.x())); | 101 std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(), |
102 0)); | |
107 } else { | 103 } else { |
108 anchor.set_x(std::max(kMinimalAnchorPositionOffset, anchor.x())); | 104 anchor.set_x(std::max(kMinimalAnchorPositionOffset - anchor.x(), 0)); |
109 } | 105 } |
110 int offset = button_bounds.height() / 2 - kArrowTipHeight; | 106 anchor.set_y(0); |
111 if (shelf_alignment == SHELF_ALIGNMENT_TOP) | |
112 offset = -offset; | |
113 anchor.set_y(anchor.y() - offset); | |
114 } | 107 } |
115 break; | 108 break; |
116 case SHELF_ALIGNMENT_LEFT: | 109 case SHELF_ALIGNMENT_LEFT: |
117 anchor.set_x(button_bounds.right() - kArrowTipHeight); | 110 anchor.set_x(0); |
118 anchor.set_y(std::max(kMinimalAnchorPositionOffset, anchor.y())); | 111 anchor.set_y(std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); |
119 break; | 112 break; |
120 case SHELF_ALIGNMENT_RIGHT: | 113 case SHELF_ALIGNMENT_RIGHT: |
121 anchor.set_x(button_bounds.x() + kArrowTipHeight); | 114 anchor.set_x(0); |
122 anchor.set_y(std::max(kMinimalAnchorPositionOffset, anchor.y())); | 115 anchor.set_y(std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); |
123 break; | 116 break; |
124 } | 117 } |
125 | 118 |
126 return anchor; | 119 return anchor; |
127 } | 120 } |
128 | 121 |
129 } // namespace | 122 } // namespace |
130 | 123 |
131 //////////////////////////////////////////////////////////////////////////////// | 124 //////////////////////////////////////////////////////////////////////////////// |
132 // AppListController, public: | 125 // AppListController, public: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 app_list::AppListView* view = new app_list::AppListView( | 162 app_list::AppListView* view = new app_list::AppListView( |
170 Shell::GetInstance()->delegate()->CreateAppListViewDelegate()); | 163 Shell::GetInstance()->delegate()->CreateAppListViewDelegate()); |
171 aura::Window* container = GetRootWindowController(window->GetRootWindow())-> | 164 aura::Window* container = GetRootWindowController(window->GetRootWindow())-> |
172 GetContainer(kShellWindowId_AppListContainer); | 165 GetContainer(kShellWindowId_AppListContainer); |
173 if (ash::switches::UseAlternateShelfLayout()) { | 166 if (ash::switches::UseAlternateShelfLayout()) { |
174 gfx::Rect applist_button_bounds = Launcher::ForWindow(container)-> | 167 gfx::Rect applist_button_bounds = Launcher::ForWindow(container)-> |
175 GetAppListButtonView()->GetBoundsInScreen(); | 168 GetAppListButtonView()->GetBoundsInScreen(); |
176 view->InitAsBubble( | 169 view->InitAsBubble( |
177 container, | 170 container, |
178 pagination_model_.get(), | 171 pagination_model_.get(), |
179 NULL, | 172 Launcher::ForWindow(container)->GetAppListButtonView(), |
180 GetAdjustAnchorPositionToShelf(applist_button_bounds, | 173 GetAnchorPositionOffsetToShelf(applist_button_bounds, |
181 Launcher::ForWindow(container)->GetAppListButtonView()-> | 174 Launcher::ForWindow(container)->GetAppListButtonView()-> |
182 GetWidget()), | 175 GetWidget()), |
183 GetBubbleArrow(container), | 176 GetBubbleArrow(container), |
184 true /* border_accepts_events */); | 177 true /* border_accepts_events */); |
185 view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 178 view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
186 } else { | 179 } else { |
187 view->InitAsBubble( | 180 view->InitAsBubble( |
188 container, | 181 container, |
189 pagination_model_.get(), | 182 pagination_model_.get(), |
190 Launcher::ForWindow(container)->GetAppListButtonView(), | 183 Launcher::ForWindow(container)->GetAppListButtonView(), |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 should_snap_back_ = false; | 415 should_snap_back_ = false; |
423 ui::ScopedLayerAnimationSettings animation(widget_animator); | 416 ui::ScopedLayerAnimationSettings animation(widget_animator); |
424 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 417 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
425 app_list::kOverscrollPageTransitionDurationMs)); | 418 app_list::kOverscrollPageTransitionDurationMs)); |
426 widget->SetBounds(view_bounds_); | 419 widget->SetBounds(view_bounds_); |
427 } | 420 } |
428 } | 421 } |
429 | 422 |
430 } // namespace internal | 423 } // namespace internal |
431 } // namespace ash | 424 } // namespace ash |
OLD | NEW |