summaryrefslogtreecommitdiffstats
path: root/ui/views
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-14 21:08:43 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-14 21:08:43 +0000
commit51ca81afcdedec601cfdaceb96f0ccc1aac927ad (patch)
tree11c604ac56ff5482b3e293cf359735bf121b8312 /ui/views
parent578ea5eb88907a1a08c798c092879e893ed75c96 (diff)
downloadchromium_src-51ca81afcdedec601cfdaceb96f0ccc1aac927ad.zip
chromium_src-51ca81afcdedec601cfdaceb96f0ccc1aac927ad.tar.gz
chromium_src-51ca81afcdedec601cfdaceb96f0ccc1aac927ad.tar.bz2
Final tweaks to launcher menu appearance:
- Increase maximum menu width - Tinting caption line text in black - Changing indenting of caption line - Removing separator and replacing with only spacing BUG=189124 TEST=visual Review URL: https://chromiumcodereview.appspot.com/12829003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r--ui/views/controls/menu/menu_delegate.cc6
-rw-r--r--ui/views/controls/menu/menu_delegate.h7
-rw-r--r--ui/views/controls/menu/menu_item_view.cc24
3 files changed, 27 insertions, 10 deletions
diff --git a/ui/views/controls/menu/menu_delegate.cc b/ui/views/controls/menu/menu_delegate.cc
index 7be72f0..cced8f2 100644
--- a/ui/views/controls/menu/menu_delegate.cc
+++ b/ui/views/controls/menu/menu_delegate.cc
@@ -27,6 +27,12 @@ bool MenuDelegate::GetBackgroundColor(int command_id,
return false;
}
+bool MenuDelegate::GetForegroundColor(int command_id,
+ bool is_hovered,
+ SkColor* override_color) const {
+ return false;
+}
+
string16 MenuDelegate::GetTooltipText(int id,
const gfx::Point& screen_loc) const {
return string16();
diff --git a/ui/views/controls/menu/menu_delegate.h b/ui/views/controls/menu/menu_delegate.h
index 872c019..3f9fd44 100644
--- a/ui/views/controls/menu/menu_delegate.h
+++ b/ui/views/controls/menu/menu_delegate.h
@@ -66,6 +66,13 @@ class VIEWS_EXPORT MenuDelegate {
// The font for the menu item label.
virtual const gfx::Font* GetLabelFont(int id) const;
+ // Override the text color of a given menu item dependent on the
+ // |command_id| and its |is_hovered| state. Returns true if it chooses to
+ // override the color.
+ virtual bool GetForegroundColor(int command_id,
+ bool is_hovered,
+ SkColor* override_color) const;
+
// Override the background color of a given menu item dependent on the
// |command_id| and its |is_hovered| state. Returns true if it chooses to
// override the color.
diff --git a/ui/views/controls/menu/menu_item_view.cc b/ui/views/controls/menu/menu_item_view.cc
index 8ac72d6..c40c05a 100644
--- a/ui/views/controls/menu/menu_item_view.cc
+++ b/ui/views/controls/menu/menu_item_view.cc
@@ -780,16 +780,15 @@ void MenuItemView::PaintButtonCommon(gfx::Canvas* canvas,
bottom_margin - config.check_height) / 2;
int icon_height = config.check_height;
int available_height = height() - top_margin - bottom_margin;
-
+ MenuDelegate *delegate = GetDelegate();
// Render the background. As MenuScrollViewContainer draws the background, we
// only need the background when we want it to look different, as when we're
// selected.
ui::NativeTheme* native_theme = GetNativeTheme();
SkColor override_color;
- if (GetDelegate() &&
- GetDelegate()->GetBackgroundColor(GetCommand(),
- render_selection,
- &override_color)) {
+ if (delegate && delegate->GetBackgroundColor(GetCommand(),
+ render_selection,
+ &override_color)) {
canvas->DrawColor(override_color);
} else if (render_selection) {
// TODO(erg): The following doesn't actually get the focused menu item
@@ -807,7 +806,7 @@ void MenuItemView::PaintButtonCommon(gfx::Canvas* canvas,
}
// Render the check.
- if (type_ == CHECKBOX && GetDelegate()->IsItemChecked(GetCommand())) {
+ if (type_ == CHECKBOX && delegate->IsItemChecked(GetCommand())) {
const gfx::ImageSkia* check = GetMenuCheckImage();
// Don't use config.check_width here as it's padded
// to force more padding (AURA).
@@ -816,7 +815,7 @@ void MenuItemView::PaintButtonCommon(gfx::Canvas* canvas,
canvas->DrawImageInt(*check, check_bounds.x(), check_bounds.y());
} else if (type_ == RADIO) {
const gfx::ImageSkia* image =
- GetRadioButtonImage(GetDelegate()->IsItemChecked(GetCommand()));
+ GetRadioButtonImage(delegate->IsItemChecked(GetCommand()));
gfx::Rect radio_bounds(icon_x,
top_margin +
(height() - top_margin - bottom_margin -
@@ -831,6 +830,11 @@ void MenuItemView::PaintButtonCommon(gfx::Canvas* canvas,
SkColor fg_color = native_theme->GetSystemColor(
enabled() ? ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor
: ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor);
+ SkColor override_foreground_color;
+ if (delegate && delegate->GetForegroundColor(GetCommand(),
+ render_selection,
+ &override_foreground_color))
+ fg_color = override_foreground_color;
const gfx::Font& font = GetFont();
int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width();
@@ -839,9 +843,9 @@ void MenuItemView::PaintButtonCommon(gfx::Canvas* canvas,
label_start += icon_view_->size().width() + config.icon_to_label_padding;
int width = this->width() - label_start - accel_width -
- (!GetDelegate() ||
- GetDelegate()->ShouldReserveSpaceForSubmenuIndicator() ?
- item_right_margin_ : config.arrow_to_edge_padding);
+ (!delegate ||
+ delegate->ShouldReserveSpaceForSubmenuIndicator() ?
+ item_right_margin_ : config.arrow_to_edge_padding);
gfx::Rect text_bounds(label_start, top_margin, width, available_height);
text_bounds.set_x(GetMirroredXForRect(text_bounds));
int flags = GetDrawStringFlags();