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

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
« no previous file with comments | « ui/views/controls/menu/menu_item_view.cc ('k') | ui/views/controls/menu/menu_item_view_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4ee3e68a30e6948476e36d41a31d659029e85cf6 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));
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 -
« no previous file with comments | « ui/views/controls/menu/menu_item_view.cc ('k') | ui/views/controls/menu/menu_item_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698