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

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: 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 return height;
424 }
425
413 const MenuItemView::MenuItemDimensions& MenuItemView::GetDimensions() const { 426 const MenuItemView::MenuItemDimensions& MenuItemView::GetDimensions() const {
414 if (!is_dimensions_valid()) 427 if (!is_dimensions_valid())
415 dimensions_ = CalculateDimensions(); 428 dimensions_ = CalculateDimensions();
416 DCHECK(is_dimensions_valid()); 429 DCHECK(is_dimensions_valid());
417 return dimensions_; 430 return dimensions_;
418 } 431 }
419 432
420 MenuController* MenuItemView::GetMenuController() { 433 MenuController* MenuItemView::GetMenuController() {
421 return GetRootMenuItem()->controller_; 434 return GetRootMenuItem()->controller_;
422 } 435 }
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 } else { 1077 } else {
1065 const Type& type = menu_item->GetType(); 1078 const Type& type = menu_item->GetType();
1066 if (type == CHECKBOX || type == RADIO) 1079 if (type == CHECKBOX || type == RADIO)
1067 return true; 1080 return true;
1068 } 1081 }
1069 } 1082 }
1070 return false; 1083 return false;
1071 } 1084 }
1072 1085
1073 } // namespace views 1086 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_item_view.h ('k') | ui/views/controls/menu/menu_item_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698