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

Unified Diff: ui/views/controls/menu/menu_item_view_views.cc

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
Patch Set: Added support for icon views (view used instead of icon in a menu item). Created 8 years, 6 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
Index: ui/views/controls/menu/menu_item_view_views.cc
diff --git a/ui/views/controls/menu/menu_item_view_views.cc b/ui/views/controls/menu/menu_item_view_views.cc
index 720c24e18b016eed75a32e5e51c3cec7b14e3ea4..ac3251c1c573b0427d2b2e4e5660bcf95a7d08d6 100644
--- a/ui/views/controls/menu/menu_item_view_views.cc
+++ b/ui/views/controls/menu/menu_item_view_views.cc
@@ -23,7 +23,7 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
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 Interesting, I had it before then removed to be co
msw 2012/06/28 17:40:25 Ah, right. Feel free to ignore style preference ni
int icon_x = config.item_left_margin;
int top_margin = GetTopMargin();
@@ -72,11 +72,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 +
- (available_height - font.GetHeight() + 1) / 2, width,
- font.GetHeight());
+ gfx::Rect text_bounds(label_start_, top_margin, width, available_height);
text_bounds.set_x(GetMirroredXForRect(text_bounds));
- int flags = GetRootMenuItem()->GetDrawStringFlags();
+ int flags = GetRootMenuItem()->GetDrawStringFlags() |
+ gfx::Canvas::TEXT_VALIGN_MIDDLE;
if (mode == PB_FOR_DRAG)
flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING;
canvas->DrawStringInt(title(), font, fg_color,
@@ -85,23 +84,6 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
PaintAccelerator(canvas);
- // Render the icon.
- 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));
- if (!enabled()) {
- SkPaint paint;
- paint.setAlpha(120);
- canvas->DrawImageInt(icon_, icon_bounds.x(), icon_bounds.y(), paint);
- } else {
- canvas->DrawImageInt(icon_, icon_bounds.x(), icon_bounds.y());
- }
- }
-
// Render the submenu indicator (arrow).
if (HasSubmenu()) {
gfx::Rect arrow_bounds(this->width() - config.arrow_width -

Powered by Google App Engine
This is Rietveld 408576698