 Chromium Code Reviews
 Chromium Code Reviews Issue 10532171:
  Added support for icon views (view used instead of icon in a menu item).  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 10532171:
  Added support for icon views (view used instead of icon in a menu item).  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: ui/views/controls/menu/menu_item_view_win.cc | 
| diff --git a/ui/views/controls/menu/menu_item_view_win.cc b/ui/views/controls/menu/menu_item_view_win.cc | 
| index 6f9063ad416626c859d2dd6d7cd9f9f228b7b481..ee3f506f8037a19a47eab0875344883d1a28e625 100644 | 
| --- a/ui/views/controls/menu/menu_item_view_win.cc | 
| +++ b/ui/views/controls/menu/menu_item_view_win.cc | 
| @@ -19,10 +19,11 @@ namespace views { | 
| void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { | 
| const MenuConfig& config = MenuConfig::instance(); | 
| + | 
| bool render_selection = | 
| (mode == PB_NORMAL && IsSelected() && | 
| parent_menu_item_->GetSubmenu()->GetShowSelection(this) && | 
| - !has_children()); | 
| + NonIconChildViewsCount() == 0); | 
| 
msw
2012/06/28 01:56:38
nit: add parens around this conditional term.
 
yefimt
2012/06/28 16:53:34
Done.
 | 
| int default_sys_color; | 
| int state; | 
| NativeTheme::State control_state; | 
| @@ -85,7 +86,10 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { | 
| const gfx::Font& font = GetFont(); | 
| int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width(); | 
| int width = this->width() - item_right_margin_ - label_start_ - accel_width; | 
| - gfx::Rect text_bounds(label_start_, top_margin, width, font.GetHeight()); | 
| + int height = this->height() - GetTopMargin() - GetBottomMargin(); | 
| + int flags = gfx::Canvas::TEXT_VALIGN_MIDDLE | | 
| + GetRootMenuItem()->GetDrawStringFlags(); | 
| + gfx::Rect text_bounds(label_start_, top_margin, width, height); | 
| text_bounds.set_x(GetMirroredXForRect(text_bounds)); | 
| if (mode == PB_FOR_DRAG) { | 
| // With different themes, it's difficult to tell what the correct | 
| @@ -94,31 +98,20 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { | 
| // cases. | 
| canvas->DrawStringWithHalo(title(), font, 0x00000000, 0xFFFFFFFF, | 
| text_bounds.x(), text_bounds.y(), text_bounds.width(), | 
| - text_bounds.height(), GetRootMenuItem()->GetDrawStringFlags()); | 
| + text_bounds.height(), flags); | 
| } else { | 
| canvas->DrawStringInt(title(), font, fg_color, | 
| text_bounds.x(), text_bounds.y(), text_bounds.width(), | 
| - text_bounds.height(), | 
| - GetRootMenuItem()->GetDrawStringFlags()); | 
| + text_bounds.height(), flags); | 
| } | 
| PaintAccelerator(canvas); | 
| - if (icon_.width() > 0) { | 
| - gfx::Rect icon_bounds(config.item_left_margin, | 
| - top_margin + (height() - top_margin - | 
| - bottom_margin - icon_.height()) / 2, | 
| - icon_.width(), | 
| - icon_.height()); | 
| - icon_bounds.set_x(GetMirroredXForRect(icon_bounds)); | 
| - canvas->DrawImageInt(icon_, icon_bounds.x(), icon_bounds.y()); | 
| - } | 
| - | 
| if (HasSubmenu()) { | 
| int state_id = enabled() ? MSM_NORMAL : MSM_DISABLED; | 
| gfx::Rect arrow_bounds(this->width() - item_right_margin_ + | 
| config.label_to_arrow_padding, 0, | 
| - config.arrow_width, height()); | 
| + config.arrow_width, this->height()); | 
| 
msw
2012/06/28 01:56:38
nit: remove unnecessary explicit "this->" from wid
 
yefimt
2012/06/28 16:53:34
There are width and height variables defined above
 
msw
2012/06/28 17:40:25
Gotcha, thanks.
 | 
| AdjustBoundsForRTLUI(&arrow_bounds); | 
| // If our sub menus open from right to left (which is the case when the |