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

Side by Side Diff: ash/common/shelf/app_list_button.cc

Issue 2598223002: [ash-md] Fix layout of launcher and overflow buttons in Ash MD shelf (Closed)
Patch Set: Merge branch 'master' into launcher_layout_in_shelf Created 3 years, 11 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/common/shelf/overflow_button.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/shelf/app_list_button.h" 5 #include "ash/common/shelf/app_list_button.h"
6 6
7 #include "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/shelf/ink_drop_button_listener.h" 9 #include "ash/common/shelf/ink_drop_button_listener.h"
10 #include "ash/common/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 281 }
282 282
283 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) { 283 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) {
284 if (draw_background_as_active_ == draw_background_as_active) 284 if (draw_background_as_active_ == draw_background_as_active)
285 return; 285 return;
286 draw_background_as_active_ = draw_background_as_active; 286 draw_background_as_active_ = draw_background_as_active;
287 SchedulePaint(); 287 SchedulePaint();
288 } 288 }
289 289
290 gfx::Point AppListButton::GetCenterPoint() const { 290 gfx::Point AppListButton::GetCenterPoint() const {
291 // During shelf hide/show animations, width and height may not be equal. Take 291 // For a bottom-aligned shelf, the button bounds could have a larger height
292 // the greater of the two as the one that represents the normal size of the 292 // than width (in the case of touch-dragging the shelf updwards) or a larger
293 // button. 293 // width than height (in the case of a shelf hide/show animation), so adjust
294 int center = std::max(width(), height()) / 2.f; 294 // the y-position of the circle's center to ensure correct layout. Similarly
295 gfx::Point centroid(center, center); 295 // adjust the x-position for a left- or right-aligned shelf.
296 // For the left shelf alignment, we need to right-justify. For other shelf 296 const int x_mid = width() / 2.f;
297 // alignments, left/top justification (i.e. no adjustments are necessary). 297 const int y_mid = height() / 2.f;
298 if (SHELF_ALIGNMENT_LEFT == wm_shelf_->GetAlignment()) 298 ShelfAlignment alignment = wm_shelf_->GetAlignment();
299 centroid.set_x(width() - center); 299 if (alignment == SHELF_ALIGNMENT_BOTTOM ||
300 return centroid; 300 alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) {
oshima 2017/01/06 20:00:43 This is for lock screen state, correct?
bruthig 2017/01/06 20:28:07 Yup
301 return gfx::Point(x_mid, x_mid);
302 } else if (alignment == SHELF_ALIGNMENT_RIGHT) {
303 return gfx::Point(y_mid, y_mid);
304 } else {
305 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT);
306 return gfx::Point(width() - y_mid, y_mid);
307 }
301 } 308 }
302 309
303 } // namespace ash 310 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/shelf/overflow_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698