Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Side by Side Diff: ash/app_list/app_list_presenter_delegate.cc

Issue 1877543002: Revise the shelf alignment locking mechanism. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update and cleanup tests. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/ash.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = Shell::GetInstance()->GetShelfAlignment( 54 ShelfAlignment shelf_alignment =
55 widget->GetNativeView()->GetRootWindow()); 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 SHELF_ALIGNMENT_BOTTOM:
59 case SHELF_ALIGNMENT_BOTTOM_LOCKED:
59 if (base::i18n::IsRTL()) { 60 if (base::i18n::IsRTL()) {
60 int screen_width = widget->GetWorkAreaBoundsInScreen().width(); 61 int screen_width = widget->GetWorkAreaBoundsInScreen().width();
61 return gfx::Vector2d( 62 return gfx::Vector2d(
62 std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(), 63 std::min(screen_width - kMinimalAnchorPositionOffset - anchor.x(),
63 0), 64 0),
64 0); 65 0);
65 } 66 }
66 return gfx::Vector2d( 67 return gfx::Vector2d(
67 std::max(kMinimalAnchorPositionOffset - anchor.x(), 0), 0); 68 std::max(kMinimalAnchorPositionOffset - anchor.x(), 0), 0);
68 case SHELF_ALIGNMENT_LEFT: 69 case SHELF_ALIGNMENT_LEFT:
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( 247 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset(
247 aura::Window* root_window) { 248 aura::Window* root_window) {
248 DCHECK(Shell::HasInstance()); 249 DCHECK(Shell::HasInstance());
249 250
250 // App list needs to know the new shelf layout in order to calculate its 251 // App list needs to know the new shelf layout in order to calculate its
251 // UI layout when AppListView visibility changes. 252 // UI layout when AppListView visibility changes.
252 Shell::GetPrimaryRootWindowController() 253 Shell::GetPrimaryRootWindowController()
253 ->GetShelfLayoutManager() 254 ->GetShelfLayoutManager()
254 ->UpdateAutoHideState(); 255 ->UpdateAutoHideState();
255 256
256 ShelfAlignment shelf_alignment = 257 return Shelf::ForWindow(root_window)
257 Shell::GetInstance()->GetShelfAlignment(root_window); 258 ->SelectValueForShelfAlignment(gfx::Vector2d(0, kAnimationOffset),
258 switch (shelf_alignment) { 259 gfx::Vector2d(-kAnimationOffset, 0),
259 case SHELF_ALIGNMENT_BOTTOM: 260 gfx::Vector2d(kAnimationOffset, 0));
260 return gfx::Vector2d(0, kAnimationOffset);
261 case SHELF_ALIGNMENT_LEFT:
262 return gfx::Vector2d(-kAnimationOffset, 0);
263 case SHELF_ALIGNMENT_RIGHT:
264 return gfx::Vector2d(kAnimationOffset, 0);
265 }
266 NOTREACHED();
267 return gfx::Vector2d();
268 } 261 }
269 262
270 //////////////////////////////////////////////////////////////////////////////// 263 ////////////////////////////////////////////////////////////////////////////////
271 // AppListPresenterDelegate, private: 264 // AppListPresenterDelegate, private:
272 265
273 void AppListPresenterDelegate::ProcessLocatedEvent(ui::LocatedEvent* event) { 266 void AppListPresenterDelegate::ProcessLocatedEvent(ui::LocatedEvent* event) {
274 if (!view_ || !is_visible_) 267 if (!view_ || !is_visible_)
275 return; 268 return;
276 269
277 // If the event happened on a menu, then the event should not close the app 270 // If the event happened on a menu, then the event should not close the app
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 339 }
347 340
348 //////////////////////////////////////////////////////////////////////////////// 341 ////////////////////////////////////////////////////////////////////////////////
349 // AppListPresenterDelegate, ShelfIconObserver implementation: 342 // AppListPresenterDelegate, ShelfIconObserver implementation:
350 343
351 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { 344 void AppListPresenterDelegate::OnShelfIconPositionsChanged() {
352 UpdateBounds(); 345 UpdateBounds();
353 } 346 }
354 347
355 } // namespace ash 348 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/ash.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698