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

Unified Diff: chrome/browser/ui/views/wrench_menu.cc

Issue 12483006: wrench_menu: use NativeTheme colors under aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: always use View::GetNativeTheme() Created 7 years, 9 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 | « chrome/browser/ui/views/wrench_menu.h ('k') | ui/native_theme/common_theme.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/wrench_menu.cc
diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc
index fce9d4348c6c127a10f190178fec6c43ce386a25..a56d6d4b39e89d3b4fb260f01c7ae0a6dad86c76 100644
--- a/chrome/browser/ui/views/wrench_menu.cc
+++ b/chrome/browser/ui/views/wrench_menu.cc
@@ -187,7 +187,7 @@ class MenuButtonBackground : public views::Background {
if (type_ != RIGHT_BUTTON) {
border = 1;
canvas->FillRect(gfx::Rect(0, 0, border, h),
- border_color(CustomButton::STATE_NORMAL));
+ border_color(view, CustomButton::STATE_NORMAL));
}
canvas->FillRect(gfx::Rect(border, 0, w - border, h),
touch_background_color(state));
@@ -196,49 +196,59 @@ class MenuButtonBackground : public views::Background {
#endif
switch (TypeAdjustedForRTL()) {
case LEFT_BUTTON:
- canvas->FillRect(gfx::Rect(1, 1, w, h - 2), background_color(state));
- canvas->FillRect(gfx::Rect(2, 0, w, 1), border_color(state));
- canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(state));
- canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(state));
- canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(state));
- canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border_color(state));
+ canvas->FillRect(gfx::Rect(1, 1, w, h - 2),
+ background_color(view, state));
Elliot Glaysher 2013/03/18 21:03:39 Please call {background,border}_color(view, state)
Bobby Powers 2013/03/18 21:24:58 Done.
+ canvas->FillRect(gfx::Rect(2, 0, w, 1), border_color(view, state));
+ canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(view, state));
+ canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(view, state));
+ canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(view, state));
+ canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border_color(view, state));
break;
case CENTER_BUTTON: {
canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2),
- background_color(state));
+ background_color(view, state));
SkColor left_color = state != CustomButton::STATE_NORMAL ?
- border_color(state) : border_color(left_button_->state());
+ border_color(view, state) :
+ border_color(view, left_button_->state());
canvas->FillRect(gfx::Rect(0, 0, 1, h), left_color);
- canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border_color(state));
- canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1), border_color(state));
+ canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border_color(view, state));
+ canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1),
+ border_color(view, state));
SkColor right_color = state != CustomButton::STATE_NORMAL ?
- border_color(state) : border_color(right_button_->state());
+ border_color(view, state) :
+ border_color(view, right_button_->state());
canvas->FillRect(gfx::Rect(w - 1, 0, 1, h), right_color);
break;
}
case RIGHT_BUTTON:
canvas->FillRect(gfx::Rect(0, 1, w - 1, h - 2),
- background_color(state));
- canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border_color(state));
- canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(state));
- canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color(state));
- canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color(state));
- canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1), border_color(state));
+ background_color(view, state));
+ canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border_color(view, state));
+ canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(view, state));
+ canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4),
+ border_color(view, state));
+ canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1),
+ border_color(view, state));
+ canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1),
+ border_color(view, state));
break;
case SINGLE_BUTTON:
canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2),
- background_color(state));
- canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border_color(state));
- canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(state));
- canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(state));
- canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(state));
- canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1), border_color(state));
- canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(state));
- canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color(state));
- canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color(state));
+ background_color(view, state));
+ canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border_color(view, state));
+ canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(view, state));
+ canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(view, state));
+ canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(view, state));
+ canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1),
+ border_color(view, state));
+ canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(view, state));
+ canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4),
+ border_color(view, state));
+ canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1),
+ border_color(view, state));
break;
default:
@@ -248,7 +258,38 @@ class MenuButtonBackground : public views::Background {
}
private:
- static SkColor border_color(CustomButton::ButtonState state) {
+#if defined(USE_AURA)
+ static SkColor border_color(View* view, CustomButton::ButtonState state) {
Elliot Glaysher 2013/03/18 21:03:39 This block changes the behavior of border_color on
Bobby Powers 2013/03/18 21:24:58 Done.
+ ui::NativeTheme *theme = view->GetNativeTheme();
+ switch (state) {
+ case CustomButton::STATE_HOVERED:
+ return theme->GetSystemColor(
+ ui::NativeTheme::kColorId_UnfocusedBorderColor);
+ case CustomButton::STATE_PRESSED:
+ return theme->GetSystemColor(
+ ui::NativeTheme::kColorId_FocusedBorderColor);
+ default:
+ return theme->GetSystemColor(
+ ui::NativeTheme::kColorId_MenuBorderColor);
+ }
+ }
+
+ static SkColor background_color(View* view, CustomButton::ButtonState state) {
+ ui::NativeTheme *theme = view->GetNativeTheme();
+ switch (state) {
+ case CustomButton::STATE_HOVERED:
+ return theme->GetSystemColor(
+ ui::NativeTheme::kColorId_HoverMenuItemBackgroundColor);
+ case CustomButton::STATE_PRESSED:
+ return theme->GetSystemColor(
+ ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor);
+ default:
+ return theme->GetSystemColor(
+ ui::NativeTheme::kColorId_MenuBackgroundColor);
+ }
+ }
+#else
+ static SkColor border_color(View *view, CustomButton::ButtonState state) {
switch (state) {
case CustomButton::STATE_HOVERED: return kHotBorderColor;
case CustomButton::STATE_PRESSED: return kPushedBorderColor;
@@ -256,13 +297,14 @@ class MenuButtonBackground : public views::Background {
}
}
- static SkColor background_color(CustomButton::ButtonState state) {
+ static SkColor background_color(View *view, CustomButton::ButtonState state) {
switch (state) {
case CustomButton::STATE_HOVERED: return kHotBackgroundColor;
case CustomButton::STATE_PRESSED: return kPushedBackgroundColor;
default: return kBackgroundColor;
}
}
+#endif
static SkColor touch_background_color(CustomButton::ButtonState state) {
switch (state) {
@@ -410,6 +452,7 @@ class WrenchMenu::CutCopyPasteView : public WrenchMenuView {
public:
CutCopyPasteView(WrenchMenu* menu,
MenuModel* menu_model,
+ View* menu_view,
int cut_index,
int copy_index,
int paste_index)
@@ -434,7 +477,7 @@ class WrenchMenu::CutCopyPasteView : public WrenchMenuView {
copy->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText);
paste->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText);
} else {
- SkColor text_color = GetNativeTheme()->GetSystemColor(
+ SkColor text_color = menu_view->GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor);
cut->SetTextColor(views::Button::STATE_NORMAL, text_color);
copy->SetTextColor(views::Button::STATE_NORMAL, text_color);
@@ -488,6 +531,7 @@ class WrenchMenu::ZoomView : public WrenchMenuView {
public:
ZoomView(WrenchMenu* menu,
MenuModel* menu_model,
+ View* menu_view,
int decrement_index,
int increment_index,
int fullscreen_index)
@@ -545,14 +589,14 @@ class WrenchMenu::ZoomView : public WrenchMenuView {
increment_button_->SetTextColor(views::Button::STATE_NORMAL,
kTouchButtonText);
} else {
- SkColor enabled_text_color = GetNativeTheme()->GetSystemColor(
+ SkColor enabled_text_color = menu_view->GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor);
zoom_label_->SetEnabledColor(enabled_text_color);
decrement_button_->SetTextColor(views::Button::STATE_NORMAL,
enabled_text_color);
increment_button_->SetTextColor(views::Button::STATE_NORMAL,
enabled_text_color);
- SkColor disabled_text_color = GetNativeTheme()->GetSystemColor(
+ SkColor disabled_text_color = menu_view->GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor);
decrement_button_->SetTextColor(views::Button::STATE_DISABLED,
disabled_text_color);
@@ -786,13 +830,13 @@ WrenchMenu::~WrenchMenu() {
}
}
-void WrenchMenu::Init(ui::MenuModel* model) {
+void WrenchMenu::Init(View* view, ui::MenuModel* model) {
DCHECK(!root_);
root_ = new MenuItemView(this);
root_->set_has_icons(true); // We have checks, radios and icons, set this
// so we get the taller menu style.
int next_id = 1;
- PopulateMenu(root_, model, &next_id);
+ PopulateMenu(root_, model, view, &next_id);
first_bookmark_command_id_ = next_id + 1;
menu_runner_.reset(new views::MenuRunner(root_));
}
@@ -1032,6 +1076,7 @@ void WrenchMenu::Observe(int type,
void WrenchMenu::PopulateMenu(MenuItemView* parent,
MenuModel* model,
+ View* view,
int* next_id) {
for (int i = 0, max = model->GetItemCount(); i < max; ++i) {
// The button container menu items have a special height which we have to
@@ -1046,7 +1091,7 @@ void WrenchMenu::PopulateMenu(MenuItemView* parent,
parent, model, i, model->GetTypeAt(i), next_id, height);
if (model->GetTypeAt(i) == MenuModel::TYPE_SUBMENU)
- PopulateMenu(item, model->GetSubmenuModelAt(i), next_id);
+ PopulateMenu(item, model->GetSubmenuModelAt(i), view, next_id);
switch (model->GetCommandIdAt(i)) {
case IDC_CUT:
@@ -1055,7 +1100,8 @@ void WrenchMenu::PopulateMenu(MenuItemView* parent,
DCHECK_EQ(IDC_COPY, model->GetCommandIdAt(i + 1));
DCHECK_EQ(IDC_PASTE, model->GetCommandIdAt(i + 2));
item->SetTitle(l10n_util::GetStringUTF16(IDS_EDIT2));
- item->AddChildView(new CutCopyPasteView(this, model, i, i + 1, i + 2));
+ item->AddChildView(new CutCopyPasteView(this, model, view,
+ i, i + 1, i + 2));
i += 2;
break;
@@ -1064,7 +1110,8 @@ void WrenchMenu::PopulateMenu(MenuItemView* parent,
DCHECK_EQ(IDC_ZOOM_PLUS, model->GetCommandIdAt(i + 1));
DCHECK_EQ(IDC_FULLSCREEN, model->GetCommandIdAt(i + 2));
item->SetTitle(l10n_util::GetStringUTF16(IDS_ZOOM_MENU2));
- item->AddChildView(new ZoomView(this, model, i, i + 1, i + 2));
+ item->AddChildView(new ZoomView(this, model, view,
+ i, i + 1, i + 2));
i += 2;
break;
« no previous file with comments | « chrome/browser/ui/views/wrench_menu.h ('k') | ui/native_theme/common_theme.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698