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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 // Duration for show/hide animation in milliseconds. | 34 // Duration for show/hide animation in milliseconds. |
35 const int kAnimationDurationMs = 200; | 35 const int kAnimationDurationMs = 200; |
36 | 36 |
37 // Offset in pixels to animation away/towards the shelf. | 37 // Offset in pixels to animation away/towards the shelf. |
38 const int kAnimationOffset = 8; | 38 const int kAnimationOffset = 8; |
39 | 39 |
40 // The maximum shift in pixels when over-scroll happens. | 40 // The maximum shift in pixels when over-scroll happens. |
41 const int kMaxOverScrollShift = 48; | 41 const int kMaxOverScrollShift = 48; |
42 | 42 |
43 // The minimal anchor position offset to make sure that the bubble is still on | |
44 // the screen with 8 pixels spacing on the left / right. This constant is a | |
45 // result of minimal bubble arrow sizes and offsets. | |
46 const int kMinimalAnchorPositionOffset = 57; | |
47 | |
48 ui::Layer* GetLayer(views::Widget* widget) { | 43 ui::Layer* GetLayer(views::Widget* widget) { |
49 return widget->GetNativeView()->layer(); | 44 return widget->GetNativeView()->layer(); |
50 } | 45 } |
51 | 46 |
52 // Gets arrow location based on shelf alignment. | 47 // Gets arrow location based on shelf alignment. |
53 views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) { | 48 views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) { |
54 DCHECK(Shell::HasInstance()); | 49 DCHECK(Shell::HasInstance()); |
55 return ShelfLayoutManager::ForShelf(window)-> | 50 return ShelfLayoutManager::ForShelf(window)-> |
56 SelectValueForShelfAlignment( | 51 SelectValueForShelfAlignment( |
57 views::BubbleBorder::BOTTOM_CENTER, | 52 views::BubbleBorder::BOTTOM_CENTER, |
(...skipping 19 matching lines...) Expand all Loading... |
77 offseted.Offset(kAnimationOffset, 0); | 72 offseted.Offset(kAnimationOffset, 0); |
78 break; | 73 break; |
79 case SHELF_ALIGNMENT_TOP: | 74 case SHELF_ALIGNMENT_TOP: |
80 offseted.Offset(0, -kAnimationOffset); | 75 offseted.Offset(0, -kAnimationOffset); |
81 break; | 76 break; |
82 } | 77 } |
83 | 78 |
84 return offseted; | 79 return offseted; |
85 } | 80 } |
86 | 81 |
87 // Using |button_bounds|, determine the anchor offset so that the bubble gets | |
88 // shown above the shelf (used for the alternate shelf theme). | |
89 gfx::Vector2d GetAnchorPositionOffsetToShelf( | |
90 const gfx::Rect& button_bounds, views::Widget* widget) { | |
91 DCHECK(Shell::HasInstance()); | |
92 ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( | |
93 widget->GetNativeView()->GetRootWindow()); | |
94 gfx::Point anchor(button_bounds.CenterPoint()); | |
95 switch (shelf_alignment) { | |
96 case SHELF_ALIGNMENT_TOP: | |
97 case SHELF_ALIGNMENT_BOTTOM: | |
98 if (base::i18n::IsRTL()) { | |
99 int screen_width = widget->GetWorkAreaBoundsInScreen().width(); | |
100 return gfx::Vector2d( | |
101 std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(), | |
102 0), 0); | |
103 } | |
104 return gfx::Vector2d( | |
105 std::max(kMinimalAnchorPositionOffset - anchor.x(), 0), 0); | |
106 case SHELF_ALIGNMENT_LEFT: | |
107 return gfx::Vector2d( | |
108 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); | |
109 case SHELF_ALIGNMENT_RIGHT: | |
110 return gfx::Vector2d( | |
111 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); | |
112 default: | |
113 NOTREACHED(); | |
114 return gfx::Vector2d(); | |
115 } | |
116 } | |
117 | |
118 } // namespace | 82 } // namespace |
119 | 83 |
120 //////////////////////////////////////////////////////////////////////////////// | 84 //////////////////////////////////////////////////////////////////////////////// |
121 // AppListController, public: | 85 // AppListController, public: |
122 | 86 |
123 AppListController::AppListController() | 87 AppListController::AppListController() |
124 : pagination_model_(new app_list::PaginationModel), | 88 : pagination_model_(new app_list::PaginationModel), |
125 is_visible_(false), | 89 is_visible_(false), |
126 view_(NULL), | 90 view_(NULL), |
127 should_snap_back_(false) { | 91 should_snap_back_(false) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 GetContainer(kShellWindowId_AppListContainer); | 133 GetContainer(kShellWindowId_AppListContainer); |
170 if (CommandLine::ForCurrentProcess()->HasSwitch( | 134 if (CommandLine::ForCurrentProcess()->HasSwitch( |
171 app_list::switches::kEnableExperimentalAppList)) { | 135 app_list::switches::kEnableExperimentalAppList)) { |
172 // The experimental app list is centered over the primary display. | 136 // The experimental app list is centered over the primary display. |
173 view->InitAsBubbleAtFixedLocation( | 137 view->InitAsBubbleAtFixedLocation( |
174 NULL, | 138 NULL, |
175 pagination_model_.get(), | 139 pagination_model_.get(), |
176 Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint(), | 140 Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint(), |
177 views::BubbleBorder::FLOAT, | 141 views::BubbleBorder::FLOAT, |
178 true /* border_accepts_events */); | 142 true /* border_accepts_events */); |
179 } else if (ash::switches::UseAlternateShelfLayout()) { | |
180 gfx::Rect applist_button_bounds = Shelf::ForWindow(container)-> | |
181 GetAppListButtonView()->GetBoundsInScreen(); | |
182 // We need the location of the button within the local screen. | |
183 applist_button_bounds = ScreenUtil::ConvertRectFromScreen( | |
184 root_window, | |
185 applist_button_bounds); | |
186 view->InitAsBubbleAttachedToAnchor( | |
187 container, | |
188 pagination_model_.get(), | |
189 Shelf::ForWindow(container)->GetAppListButtonView(), | |
190 GetAnchorPositionOffsetToShelf(applist_button_bounds, | |
191 Shelf::ForWindow(container)->GetAppListButtonView()-> | |
192 GetWidget()), | |
193 GetBubbleArrow(container), | |
194 true /* border_accepts_events */); | |
195 view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | |
196 } else { | 143 } else { |
197 view->InitAsBubbleAttachedToAnchor( | 144 view->InitAsBubbleAttachedToAnchor( |
198 container, | 145 container, |
199 pagination_model_.get(), | 146 pagination_model_.get(), |
200 Shelf::ForWindow(container)->GetAppListButtonView(), | 147 Shelf::ForWindow(container)->GetAppListButtonView(), |
201 gfx::Vector2d(), | 148 gfx::Vector2d(), |
202 GetBubbleArrow(container), | 149 GetBubbleArrow(container), |
203 true /* border_accepts_events */); | 150 true /* border_accepts_events */); |
204 } | 151 } |
205 SetView(view); | 152 SetView(view); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 should_snap_back_ = false; | 380 should_snap_back_ = false; |
434 ui::ScopedLayerAnimationSettings animation(widget_animator); | 381 ui::ScopedLayerAnimationSettings animation(widget_animator); |
435 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 382 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
436 app_list::kOverscrollPageTransitionDurationMs)); | 383 app_list::kOverscrollPageTransitionDurationMs)); |
437 widget->SetBounds(view_bounds_); | 384 widget->SetBounds(view_bounds_); |
438 } | 385 } |
439 } | 386 } |
440 | 387 |
441 } // namespace internal | 388 } // namespace internal |
442 } // namespace ash | 389 } // namespace ash |
OLD | NEW |