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

Unified Diff: views/controls/menu/menu_item_view.cc

Issue 7331017: Multi-Profiles: Add icon chooser to profiles menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Multi-Profiles: Add icon chooser to profiles menu Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/menu/menu_item_view.h ('k') | views/controls/menu/menu_item_view_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/menu/menu_item_view.cc
===================================================================
--- views/controls/menu/menu_item_view.cc (revision 91956)
+++ views/controls/menu/menu_item_view.cc (working copy)
@@ -484,14 +484,22 @@
if (!has_children())
return;
- // Child views are laid out right aligned and given the full height. To right
- // align start with the last view and progress to the first.
- for (int i = child_count() - 1, x = width() - item_right_margin_; i >= 0;
- --i) {
- View* child = GetChildViewAt(i);
- int width = child->GetPreferredSize().width();
- child->SetBounds(x - width, 0, width, height());
- x -= width - kChildXPadding;
+ if (child_count() == 1 && GetTitle().size() == 0) {
+ // We only have one child and no title so let the view take over all the
+ // space.
+ View* child = GetChildViewAt(0);
+ gfx::Size size = child->GetPreferredSize();
+ child->SetBounds(label_start_, GetTopMargin(), size.width(), size.height());
+ } else {
+ // Child views are laid out right aligned and given the full height. To
+ // right align start with the last view and progress to the first.
+ for (int i = child_count() - 1, x = width() - item_right_margin_; i >= 0;
+ --i) {
+ View* child = GetChildViewAt(i);
+ int width = child->GetPreferredSize().width();
+ child->SetBounds(x - width, 0, width, height());
+ x -= width - kChildXPadding;
+ }
}
}
@@ -732,17 +740,24 @@
MenuConfig::instance().item_no_icon_bottom_margin;
}
-int MenuItemView::GetChildPreferredWidth() {
+gfx::Size MenuItemView::GetChildPreferredSize() {
if (!has_children())
- return 0;
+ return gfx::Size();
+ if (GetTitle().size() == 0 && child_count() == 1) {
+ View* child = GetChildViewAt(0);
+ return child->GetPreferredSize();
+ }
+
int width = 0;
for (int i = 0; i < child_count(); ++i) {
if (i)
width += kChildXPadding;
width += GetChildViewAt(i)->GetPreferredSize().width();
}
- return width;
+ // Return a height of 0 to indicate that we should use the title height
+ // instead.
+ return gfx::Size(width, 0);
}
string16 MenuItemView::GetAcceleratorText() {
« no previous file with comments | « views/controls/menu/menu_item_view.h ('k') | views/controls/menu/menu_item_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698