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..94ae968e9d8115e7af53cd4599af2196a62c8d7e 100644 |
--- a/chrome/browser/ui/views/wrench_menu.cc |
+++ b/chrome/browser/ui/views/wrench_menu.cc |
@@ -187,58 +187,58 @@ 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)); |
return; |
} |
#endif |
+ const SkColor background = background_color(view, state); |
+ const SkColor border = border_color(view, state); |
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); |
+ canvas->FillRect(gfx::Rect(2, 0, w, 1), border); |
+ canvas->FillRect(gfx::Rect(1, 1, 1, 1), border); |
+ canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border); |
+ canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border); |
+ canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border); |
break; |
case CENTER_BUTTON: { |
- canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), |
- background_color(state)); |
+ canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), background); |
SkColor left_color = state != CustomButton::STATE_NORMAL ? |
- border_color(state) : border_color(left_button_->state()); |
+ border : 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); |
+ canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1), |
+ border); |
SkColor right_color = state != CustomButton::STATE_NORMAL ? |
- border_color(state) : border_color(right_button_->state()); |
+ border : 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)); |
+ canvas->FillRect(gfx::Rect(0, 1, w - 1, h - 2), background); |
+ canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border); |
+ canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border); |
+ canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border); |
+ canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border); |
+ canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1), border); |
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)); |
+ canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), background); |
+ canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border); |
+ canvas->FillRect(gfx::Rect(1, 1, 1, 1), border); |
+ canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border); |
+ canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border); |
+ canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1), border); |
+ canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border); |
+ canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border); |
+ canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border); |
break; |
default: |
@@ -248,7 +248,38 @@ class MenuButtonBackground : public views::Background { |
} |
private: |
- static SkColor border_color(CustomButton::ButtonState state) { |
+#if defined(USE_AURA) |
Elliot Glaysher
2013/03/18 21:38:21
It's a start, but this #ifdef block still exists.
Bobby Powers
2013/03/19 13:27:01
Done.
|
+ static SkColor border_color(View* view, CustomButton::ButtonState state) { |
+ ui::NativeTheme *theme = view->GetNativeTheme(); |
+ switch (state) { |
+ case CustomButton::STATE_HOVERED: |
+ return theme->GetSystemColor( |
+ ui::NativeTheme::kColorId_HoverBorderColor); |
+ 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 +287,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 +442,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 +467,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 +521,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 +579,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 +820,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 +1066,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 +1081,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 +1090,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 +1100,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; |