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

Unified Diff: ui/views/controls/menu/menu_item_view_win.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_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..8589f21ac28fa5e87e2ea3cdee3c4290fb98f118 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));
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());
AdjustBoundsForRTLUI(&arrow_bounds);
// If our sub menus open from right to left (which is the case when the
« no previous file with comments | « ui/views/controls/menu/menu_item_view_views.cc ('k') | ui/views/controls/menu/menu_scroll_view_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698