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

Side by Side Diff: ash/wm/app_list_controller.cc

Issue 198063003: Revert of Shelf Cleanup (- binary files) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ash/test/shelf_view_test_api.cc ('k') | chrome/browser/about_flags.cc » ('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/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
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
43 ui::Layer* GetLayer(views::Widget* widget) { 48 ui::Layer* GetLayer(views::Widget* widget) {
44 return widget->GetNativeView()->layer(); 49 return widget->GetNativeView()->layer();
45 } 50 }
46 51
47 // Gets arrow location based on shelf alignment. 52 // Gets arrow location based on shelf alignment.
48 views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) { 53 views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) {
49 DCHECK(Shell::HasInstance()); 54 DCHECK(Shell::HasInstance());
50 return ShelfLayoutManager::ForShelf(window)-> 55 return ShelfLayoutManager::ForShelf(window)->
51 SelectValueForShelfAlignment( 56 SelectValueForShelfAlignment(
52 views::BubbleBorder::BOTTOM_CENTER, 57 views::BubbleBorder::BOTTOM_CENTER,
(...skipping 19 matching lines...) Expand all
72 offseted.Offset(kAnimationOffset, 0); 77 offseted.Offset(kAnimationOffset, 0);
73 break; 78 break;
74 case SHELF_ALIGNMENT_TOP: 79 case SHELF_ALIGNMENT_TOP:
75 offseted.Offset(0, -kAnimationOffset); 80 offseted.Offset(0, -kAnimationOffset);
76 break; 81 break;
77 } 82 }
78 83
79 return offseted; 84 return offseted;
80 } 85 }
81 86
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
82 } // namespace 118 } // namespace
83 119
84 //////////////////////////////////////////////////////////////////////////////// 120 ////////////////////////////////////////////////////////////////////////////////
85 // AppListController, public: 121 // AppListController, public:
86 122
87 AppListController::AppListController() 123 AppListController::AppListController()
88 : pagination_model_(new app_list::PaginationModel), 124 : pagination_model_(new app_list::PaginationModel),
89 is_visible_(false), 125 is_visible_(false),
90 view_(NULL), 126 view_(NULL),
91 should_snap_back_(false) { 127 should_snap_back_(false) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 GetContainer(kShellWindowId_AppListContainer); 169 GetContainer(kShellWindowId_AppListContainer);
134 if (CommandLine::ForCurrentProcess()->HasSwitch( 170 if (CommandLine::ForCurrentProcess()->HasSwitch(
135 app_list::switches::kEnableExperimentalAppList)) { 171 app_list::switches::kEnableExperimentalAppList)) {
136 // The experimental app list is centered over the primary display. 172 // The experimental app list is centered over the primary display.
137 view->InitAsBubbleAtFixedLocation( 173 view->InitAsBubbleAtFixedLocation(
138 NULL, 174 NULL,
139 pagination_model_.get(), 175 pagination_model_.get(),
140 Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint(), 176 Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint(),
141 views::BubbleBorder::FLOAT, 177 views::BubbleBorder::FLOAT,
142 true /* border_accepts_events */); 178 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);
143 } else { 196 } else {
144 view->InitAsBubbleAttachedToAnchor( 197 view->InitAsBubbleAttachedToAnchor(
145 container, 198 container,
146 pagination_model_.get(), 199 pagination_model_.get(),
147 Shelf::ForWindow(container)->GetAppListButtonView(), 200 Shelf::ForWindow(container)->GetAppListButtonView(),
148 gfx::Vector2d(), 201 gfx::Vector2d(),
149 GetBubbleArrow(container), 202 GetBubbleArrow(container),
150 true /* border_accepts_events */); 203 true /* border_accepts_events */);
151 } 204 }
152 SetView(view); 205 SetView(view);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 should_snap_back_ = false; 433 should_snap_back_ = false;
381 ui::ScopedLayerAnimationSettings animation(widget_animator); 434 ui::ScopedLayerAnimationSettings animation(widget_animator);
382 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 435 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
383 app_list::kOverscrollPageTransitionDurationMs)); 436 app_list::kOverscrollPageTransitionDurationMs));
384 widget->SetBounds(view_bounds_); 437 widget->SetBounds(view_bounds_);
385 } 438 }
386 } 439 }
387 440
388 } // namespace internal 441 } // namespace internal
389 } // namespace ash 442 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/shelf_view_test_api.cc ('k') | chrome/browser/about_flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698