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

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

Issue 2579463002: Fix layout of launcher and overflow buttons in Ash MD shelf (Closed)
Patch Set: Created 4 years 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') | ash/common/shelf/overflow_button.cc » ('J')
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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 280 }
281 281
282 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) { 282 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) {
283 if (draw_background_as_active_ == draw_background_as_active) 283 if (draw_background_as_active_ == draw_background_as_active)
284 return; 284 return;
285 draw_background_as_active_ = draw_background_as_active; 285 draw_background_as_active_ = draw_background_as_active;
286 SchedulePaint(); 286 SchedulePaint();
287 } 287 }
288 288
289 gfx::Point AppListButton::GetCenterPoint() const { 289 gfx::Point AppListButton::GetCenterPoint() const {
290 // During shelf hide/show animations, width and height may not be equal. Take 290 const int x_mid = width() / 2.f;
291 // the greater of the two as the one that represents the normal size of the 291 const int y_mid = height() / 2.f;
292 // button. 292 gfx::Point center(x_mid, y_mid);
293 int center = std::max(width(), height()) / 2.f; 293
294 gfx::Point centroid(center, center); 294 // For a bottom-aligned shelf, the button bounds could have a larger height
295 // For the left shelf alignment, we need to right-justify. For other shelf 295 // than width (in the case of touch-dragging the shelf updwards) or a larger
296 // alignments, left/top justification (i.e. no adjustments are necessary). 296 // width than height (in the case of a shelf hide/show animation), so adjust
297 if (SHELF_ALIGNMENT_LEFT == wm_shelf_->GetAlignment()) 297 // the y-position of the circle's center to ensure correct layout. Similarly
298 centroid.set_x(width() - center); 298 // adjust the x-position for a left- or right-aligned shelf.
oshima 2016/12/14 21:28:41 am I correct that we assume the button is square?
tdanderson 2016/12/14 21:45:07 The app list button is actually a circle
oshima 2016/12/14 21:52:37 I meant the logical bounds of the button is square
tdanderson 2016/12/14 22:18:04 Thanks, I like that much better. Changed.
299 return centroid; 299 if (wm_shelf_->GetAlignment() == SHELF_ALIGNMENT_BOTTOM)
300 center.set_y(x_mid);
301 else if (wm_shelf_->GetAlignment() == SHELF_ALIGNMENT_RIGHT)
302 center.set_x(y_mid);
303 else if (wm_shelf_->GetAlignment() == SHELF_ALIGNMENT_LEFT)
304 center.set_x(width() - y_mid);
305
306 return center;
300 } 307 }
301 308
302 } // namespace ash 309 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/shelf/overflow_button.cc » ('j') | ash/common/shelf/overflow_button.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698