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

Side by Side Diff: ui/views/controls/menu/menu_item_view.cc

Issue 553233002: Dynamically calculate the number of extension icons to show per row in overflow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test fix Created 6 years, 3 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
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 "ui/views/controls/menu/menu_item_view.h" 5 #include "ui/views/controls/menu/menu_item_view.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 void MenuItemView::OnPaint(gfx::Canvas* canvas) { 403 void MenuItemView::OnPaint(gfx::Canvas* canvas) {
404 PaintButton(canvas, PB_NORMAL); 404 PaintButton(canvas, PB_NORMAL);
405 } 405 }
406 406
407 gfx::Size MenuItemView::GetPreferredSize() const { 407 gfx::Size MenuItemView::GetPreferredSize() const {
408 const MenuItemDimensions& dimensions(GetDimensions()); 408 const MenuItemDimensions& dimensions(GetDimensions());
409 return gfx::Size(dimensions.standard_width + dimensions.children_width, 409 return gfx::Size(dimensions.standard_width + dimensions.children_width,
410 dimensions.height); 410 dimensions.height);
411 } 411 }
412 412
413 int MenuItemView::GetHeightForWidth(int width) const {
414 // If this isn't a container, we can just use the preferred size's height.
415 if (!IsContainer())
416 return GetPreferredSize().height();
417
418 int height = child_at(0)->GetHeightForWidth(width);
419 if (!icon_view_ && GetRootMenuItem()->has_icons())
420 height = std::max(height, GetMenuConfig().check_height);
421 height += GetBottomMargin() + GetTopMargin();
422
423 // There's a chance our dimensions changed as a result of this. If so,
424 // invalidate them so they get recalculated as needed.
425 if (is_dimensions_valid() && height != GetDimensions().height)
426 invalidate_dimensions();
427
428 return height;
429 }
430
413 const MenuItemView::MenuItemDimensions& MenuItemView::GetDimensions() const { 431 const MenuItemView::MenuItemDimensions& MenuItemView::GetDimensions() const {
414 if (!is_dimensions_valid()) 432 if (!is_dimensions_valid())
415 dimensions_ = CalculateDimensions(); 433 dimensions_ = CalculateDimensions();
416 DCHECK(is_dimensions_valid()); 434 DCHECK(is_dimensions_valid());
417 return dimensions_; 435 return dimensions_;
418 } 436 }
419 437
420 MenuController* MenuItemView::GetMenuController() { 438 MenuController* MenuItemView::GetMenuController() {
421 return GetRootMenuItem()->controller_; 439 return GetRootMenuItem()->controller_;
422 } 440 }
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 } else { 1082 } else {
1065 const Type& type = menu_item->GetType(); 1083 const Type& type = menu_item->GetType();
1066 if (type == CHECKBOX || type == RADIO) 1084 if (type == CHECKBOX || type == RADIO)
1067 return true; 1085 return true;
1068 } 1086 }
1069 } 1087 }
1070 return false; 1088 return false;
1071 } 1089 }
1072 1090
1073 } // namespace views 1091 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698