| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/wrench_menu.h" | 5 #include "chrome/browser/ui/views/wrench_menu.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 using views::ImageButton; | 64 using views::ImageButton; |
| 65 using views::Label; | 65 using views::Label; |
| 66 using views::LabelButton; | 66 using views::LabelButton; |
| 67 using views::MenuConfig; | 67 using views::MenuConfig; |
| 68 using views::MenuItemView; | 68 using views::MenuItemView; |
| 69 using views::View; | 69 using views::View; |
| 70 | 70 |
| 71 namespace { | 71 namespace { |
| 72 | 72 |
| 73 // Colors used for buttons. | 73 // Colors used for buttons. |
| 74 const SkColor kHotBorderColor = SkColorSetARGB(72, 0, 0, 0); | 74 const SkColor kEnabledTouchBackgroundColor = SkColorSetARGB(247, 255, 255, 255); |
| 75 const SkColor kBorderColor = SkColorSetARGB(36, 0, 0, 0); | 75 const SkColor kHoverTouchBackgroundColor = SkColorSetARGB(247, 242, 242, 242); |
| 76 const SkColor kPushedBorderColor = SkColorSetARGB(72, 0, 0, 0); | 76 const SkColor kFocusedTouchBackgroundColor = SkColorSetARGB(247, 235, 235, 235); |
| 77 const SkColor kHotBackgroundColor = SkColorSetARGB(204, 255, 255, 255); | |
| 78 const SkColor kBackgroundColor = SkColorSetARGB(102, 255, 255, 255); | |
| 79 const SkColor kPushedBackgroundColor = SkColorSetARGB(13, 0, 0, 0); | |
| 80 const SkColor kTouchBackgroundColor = SkColorSetARGB(247, 255, 255, 255); | |
| 81 const SkColor kHotTouchBackgroundColor = SkColorSetARGB(247, 242, 242, 242); | |
| 82 const SkColor kPushedTouchBackgroundColor = SkColorSetARGB(247, 235, 235, 235); | |
| 83 | 77 |
| 84 const SkColor kTouchButtonText = 0xff5a5a5a; | 78 const SkColor kTouchButtonText = 0xff5a5a5a; |
| 85 | 79 |
| 86 // Horizontal padding on the edges of the buttons. | 80 // Horizontal padding on the edges of the buttons. |
| 87 const int kHorizontalPadding = 6; | 81 const int kHorizontalPadding = 6; |
| 88 // Horizontal padding for a touch enabled menu. | 82 // Horizontal padding for a touch enabled menu. |
| 89 const int kHorizontalTouchPadding = 15; | 83 const int kHorizontalTouchPadding = 15; |
| 90 | 84 |
| 91 // Menu items which have embedded buttons should have this height in pixel. | 85 // Menu items which have embedded buttons should have this height in pixel. |
| 92 const int kMenuItemContainingButtonsHeight = 43; | 86 const int kMenuItemContainingButtonsHeight = 43; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 #if defined(USE_AURA) | 174 #if defined(USE_AURA) |
| 181 if (use_new_menu_ && | 175 if (use_new_menu_ && |
| 182 view->GetNativeTheme() == ui::NativeThemeAura::instance()) { | 176 view->GetNativeTheme() == ui::NativeThemeAura::instance()) { |
| 183 // Normal buttons get a border drawn on the right side and the rest gets | 177 // Normal buttons get a border drawn on the right side and the rest gets |
| 184 // filled in. The left button however does not get a line to combine | 178 // filled in. The left button however does not get a line to combine |
| 185 // buttons. | 179 // buttons. |
| 186 int border = 0; | 180 int border = 0; |
| 187 if (type_ != RIGHT_BUTTON) { | 181 if (type_ != RIGHT_BUTTON) { |
| 188 border = 1; | 182 border = 1; |
| 189 canvas->FillRect(gfx::Rect(0, 0, border, h), | 183 canvas->FillRect(gfx::Rect(0, 0, border, h), |
| 190 border_color(CustomButton::STATE_NORMAL)); | 184 BorderColor(view, CustomButton::STATE_NORMAL)); |
| 191 } | 185 } |
| 192 canvas->FillRect(gfx::Rect(border, 0, w - border, h), | 186 canvas->FillRect(gfx::Rect(border, 0, w - border, h), |
| 193 touch_background_color(state)); | 187 touch_background_color(state)); |
| 194 return; | 188 return; |
| 195 } | 189 } |
| 196 #endif | 190 #endif |
| 191 const SkColor background = BackgroundColor(view, state); |
| 192 const SkColor border = BorderColor(view, state); |
| 197 switch (TypeAdjustedForRTL()) { | 193 switch (TypeAdjustedForRTL()) { |
| 198 case LEFT_BUTTON: | 194 case LEFT_BUTTON: |
| 199 canvas->FillRect(gfx::Rect(1, 1, w, h - 2), background_color(state)); | 195 canvas->FillRect(gfx::Rect(1, 1, w, h - 2), background); |
| 200 canvas->FillRect(gfx::Rect(2, 0, w, 1), border_color(state)); | 196 canvas->FillRect(gfx::Rect(2, 0, w, 1), border); |
| 201 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(state)); | 197 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border); |
| 202 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(state)); | 198 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border); |
| 203 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(state)); | 199 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border); |
| 204 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border_color(state)); | 200 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border); |
| 205 break; | 201 break; |
| 206 | 202 |
| 207 case CENTER_BUTTON: { | 203 case CENTER_BUTTON: { |
| 208 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), | 204 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), background); |
| 209 background_color(state)); | |
| 210 SkColor left_color = state != CustomButton::STATE_NORMAL ? | 205 SkColor left_color = state != CustomButton::STATE_NORMAL ? |
| 211 border_color(state) : border_color(left_button_->state()); | 206 border : BorderColor(view, left_button_->state()); |
| 212 canvas->FillRect(gfx::Rect(0, 0, 1, h), left_color); | 207 canvas->FillRect(gfx::Rect(0, 0, 1, h), left_color); |
| 213 canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border_color(state)); | 208 canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border); |
| 214 canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1), border_color(state)); | 209 canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1), |
| 210 border); |
| 215 SkColor right_color = state != CustomButton::STATE_NORMAL ? | 211 SkColor right_color = state != CustomButton::STATE_NORMAL ? |
| 216 border_color(state) : border_color(right_button_->state()); | 212 border : BorderColor(view, right_button_->state()); |
| 217 canvas->FillRect(gfx::Rect(w - 1, 0, 1, h), right_color); | 213 canvas->FillRect(gfx::Rect(w - 1, 0, 1, h), right_color); |
| 218 break; | 214 break; |
| 219 } | 215 } |
| 220 | 216 |
| 221 case RIGHT_BUTTON: | 217 case RIGHT_BUTTON: |
| 222 canvas->FillRect(gfx::Rect(0, 1, w - 1, h - 2), | 218 canvas->FillRect(gfx::Rect(0, 1, w - 1, h - 2), background); |
| 223 background_color(state)); | 219 canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border); |
| 224 canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border_color(state)); | 220 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border); |
| 225 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(state)); | 221 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border); |
| 226 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color(state)); | 222 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border); |
| 227 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color(state)); | 223 canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1), border); |
| 228 canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1), border_color(state)); | |
| 229 break; | 224 break; |
| 230 | 225 |
| 231 case SINGLE_BUTTON: | 226 case SINGLE_BUTTON: |
| 232 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), | 227 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), background); |
| 233 background_color(state)); | 228 canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border); |
| 234 canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border_color(state)); | 229 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border); |
| 235 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(state)); | 230 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border); |
| 236 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(state)); | 231 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border); |
| 237 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(state)); | 232 canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1), border); |
| 238 canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1), border_color(state)); | 233 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border); |
| 239 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(state)); | 234 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border); |
| 240 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color(state)); | 235 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border); |
| 241 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color(state)); | |
| 242 break; | 236 break; |
| 243 | 237 |
| 244 default: | 238 default: |
| 245 NOTREACHED(); | 239 NOTREACHED(); |
| 246 break; | 240 break; |
| 247 } | 241 } |
| 248 } | 242 } |
| 249 | 243 |
| 250 private: | 244 private: |
| 251 static SkColor border_color(CustomButton::ButtonState state) { | 245 static SkColor BorderColor(View* view, CustomButton::ButtonState state) { |
| 246 ui::NativeTheme* theme = view->GetNativeTheme(); |
| 252 switch (state) { | 247 switch (state) { |
| 253 case CustomButton::STATE_HOVERED: return kHotBorderColor; | 248 case CustomButton::STATE_HOVERED: |
| 254 case CustomButton::STATE_PRESSED: return kPushedBorderColor; | 249 return theme->GetSystemColor( |
| 255 default: return kBorderColor; | 250 ui::NativeTheme::kColorId_HoverMenuButtonBorderColor); |
| 251 case CustomButton::STATE_PRESSED: |
| 252 return theme->GetSystemColor( |
| 253 ui::NativeTheme::kColorId_FocusedMenuButtonBorderColor); |
| 254 default: |
| 255 return theme->GetSystemColor( |
| 256 ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor); |
| 256 } | 257 } |
| 257 } | 258 } |
| 258 | 259 |
| 259 static SkColor background_color(CustomButton::ButtonState state) { | 260 static SkColor BackgroundColor(View* view, CustomButton::ButtonState state) { |
| 261 ui::NativeTheme* theme = view->GetNativeTheme(); |
| 260 switch (state) { | 262 switch (state) { |
| 261 case CustomButton::STATE_HOVERED: return kHotBackgroundColor; | 263 case CustomButton::STATE_HOVERED: |
| 262 case CustomButton::STATE_PRESSED: return kPushedBackgroundColor; | 264 return theme->GetSystemColor( |
| 263 default: return kBackgroundColor; | 265 ui::NativeTheme::kColorId_HoverMenuItemBackgroundColor); |
| 266 case CustomButton::STATE_PRESSED: |
| 267 return theme->GetSystemColor( |
| 268 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor); |
| 269 default: |
| 270 return theme->GetSystemColor( |
| 271 ui::NativeTheme::kColorId_MenuBackgroundColor); |
| 264 } | 272 } |
| 265 } | 273 } |
| 266 | 274 |
| 267 static SkColor touch_background_color(CustomButton::ButtonState state) { | 275 static SkColor touch_background_color(CustomButton::ButtonState state) { |
| 268 switch (state) { | 276 switch (state) { |
| 269 case CustomButton::STATE_HOVERED: return kHotTouchBackgroundColor; | 277 case CustomButton::STATE_HOVERED: return kHoverTouchBackgroundColor; |
| 270 case CustomButton::STATE_PRESSED: return kPushedTouchBackgroundColor; | 278 case CustomButton::STATE_PRESSED: return kFocusedTouchBackgroundColor; |
| 271 default: return kTouchBackgroundColor; | 279 default: return kEnabledTouchBackgroundColor; |
| 272 } | 280 } |
| 273 } | 281 } |
| 274 | 282 |
| 275 ButtonType TypeAdjustedForRTL() const { | 283 ButtonType TypeAdjustedForRTL() const { |
| 276 if (!base::i18n::IsRTL()) | 284 if (!base::i18n::IsRTL()) |
| 277 return type_; | 285 return type_; |
| 278 | 286 |
| 279 switch (type_) { | 287 switch (type_) { |
| 280 case LEFT_BUTTON: return RIGHT_BUTTON; | 288 case LEFT_BUTTON: return RIGHT_BUTTON; |
| 281 case RIGHT_BUTTON: return LEFT_BUTTON; | 289 case RIGHT_BUTTON: return LEFT_BUTTON; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 411 |
| 404 } // namespace | 412 } // namespace |
| 405 | 413 |
| 406 // CutCopyPasteView ------------------------------------------------------------ | 414 // CutCopyPasteView ------------------------------------------------------------ |
| 407 | 415 |
| 408 // CutCopyPasteView is the view containing the cut/copy/paste buttons. | 416 // CutCopyPasteView is the view containing the cut/copy/paste buttons. |
| 409 class WrenchMenu::CutCopyPasteView : public WrenchMenuView { | 417 class WrenchMenu::CutCopyPasteView : public WrenchMenuView { |
| 410 public: | 418 public: |
| 411 CutCopyPasteView(WrenchMenu* menu, | 419 CutCopyPasteView(WrenchMenu* menu, |
| 412 MenuModel* menu_model, | 420 MenuModel* menu_model, |
| 421 const ui::NativeTheme* native_theme, |
| 413 int cut_index, | 422 int cut_index, |
| 414 int copy_index, | 423 int copy_index, |
| 415 int paste_index) | 424 int paste_index) |
| 416 : WrenchMenuView(menu, menu_model) { | 425 : WrenchMenuView(menu, menu_model) { |
| 417 LabelButton* cut = CreateAndConfigureButton( | 426 LabelButton* cut = CreateAndConfigureButton( |
| 418 IDS_CUT, MenuButtonBackground::LEFT_BUTTON, cut_index, NULL); | 427 IDS_CUT, MenuButtonBackground::LEFT_BUTTON, cut_index, NULL); |
| 419 | 428 |
| 420 MenuButtonBackground* copy_background = NULL; | 429 MenuButtonBackground* copy_background = NULL; |
| 421 LabelButton* copy = CreateAndConfigureButton( | 430 LabelButton* copy = CreateAndConfigureButton( |
| 422 IDS_COPY, MenuButtonBackground::CENTER_BUTTON, copy_index, | 431 IDS_COPY, MenuButtonBackground::CENTER_BUTTON, copy_index, |
| 423 ©_background); | 432 ©_background); |
| 424 | 433 |
| 425 LabelButton* paste = CreateAndConfigureButton( | 434 LabelButton* paste = CreateAndConfigureButton( |
| 426 IDS_PASTE, | 435 IDS_PASTE, |
| 427 menu_->use_new_menu() && menu_->supports_new_separators_ ? | 436 menu_->use_new_menu() && menu_->supports_new_separators_ ? |
| 428 MenuButtonBackground::CENTER_BUTTON : | 437 MenuButtonBackground::CENTER_BUTTON : |
| 429 MenuButtonBackground::RIGHT_BUTTON, | 438 MenuButtonBackground::RIGHT_BUTTON, |
| 430 paste_index, | 439 paste_index, |
| 431 NULL); | 440 NULL); |
| 432 if (menu_->use_new_menu()) { | 441 if (menu_->use_new_menu()) { |
| 433 cut->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); | 442 cut->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); |
| 434 copy->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); | 443 copy->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); |
| 435 paste->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); | 444 paste->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); |
| 436 } else { | 445 } else { |
| 437 SkColor text_color = GetNativeTheme()->GetSystemColor( | 446 SkColor text_color = native_theme->GetSystemColor( |
| 438 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); | 447 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); |
| 439 cut->SetTextColor(views::Button::STATE_NORMAL, text_color); | 448 cut->SetTextColor(views::Button::STATE_NORMAL, text_color); |
| 440 copy->SetTextColor(views::Button::STATE_NORMAL, text_color); | 449 copy->SetTextColor(views::Button::STATE_NORMAL, text_color); |
| 441 paste->SetTextColor(views::Button::STATE_NORMAL, text_color); | 450 paste->SetTextColor(views::Button::STATE_NORMAL, text_color); |
| 442 } | 451 } |
| 443 copy_background->SetOtherButtons(cut, paste); | 452 copy_background->SetOtherButtons(cut, paste); |
| 444 } | 453 } |
| 445 | 454 |
| 446 // Overridden from View. | 455 // Overridden from View. |
| 447 virtual gfx::Size GetPreferredSize() OVERRIDE { | 456 virtual gfx::Size GetPreferredSize() OVERRIDE { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 static const int kZoomPadding = 6; | 490 static const int kZoomPadding = 6; |
| 482 static const int kTouchZoomPadding = 14; | 491 static const int kTouchZoomPadding = 14; |
| 483 | 492 |
| 484 // ZoomView contains the various zoom controls: two buttons to increase/decrease | 493 // ZoomView contains the various zoom controls: two buttons to increase/decrease |
| 485 // the zoom, a label showing the current zoom percent, and a button to go | 494 // the zoom, a label showing the current zoom percent, and a button to go |
| 486 // full-screen. | 495 // full-screen. |
| 487 class WrenchMenu::ZoomView : public WrenchMenuView { | 496 class WrenchMenu::ZoomView : public WrenchMenuView { |
| 488 public: | 497 public: |
| 489 ZoomView(WrenchMenu* menu, | 498 ZoomView(WrenchMenu* menu, |
| 490 MenuModel* menu_model, | 499 MenuModel* menu_model, |
| 500 const ui::NativeTheme* native_theme, |
| 491 int decrement_index, | 501 int decrement_index, |
| 492 int increment_index, | 502 int increment_index, |
| 493 int fullscreen_index) | 503 int fullscreen_index) |
| 494 : WrenchMenuView(menu, menu_model), | 504 : WrenchMenuView(menu, menu_model), |
| 495 fullscreen_index_(fullscreen_index), | 505 fullscreen_index_(fullscreen_index), |
| 496 zoom_callback_(base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, | 506 zoom_callback_(base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, |
| 497 base::Unretained(this))), | 507 base::Unretained(this))), |
| 498 increment_button_(NULL), | 508 increment_button_(NULL), |
| 499 zoom_label_(NULL), | 509 zoom_label_(NULL), |
| 500 decrement_button_(NULL), | 510 decrement_button_(NULL), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 548 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 539 IDR_FULLSCREEN_MENU_BUTTON); | 549 IDR_FULLSCREEN_MENU_BUTTON); |
| 540 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); | 550 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); |
| 541 if (menu_->use_new_menu()) { | 551 if (menu_->use_new_menu()) { |
| 542 zoom_label_->SetEnabledColor(kTouchButtonText); | 552 zoom_label_->SetEnabledColor(kTouchButtonText); |
| 543 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, | 553 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, |
| 544 kTouchButtonText); | 554 kTouchButtonText); |
| 545 increment_button_->SetTextColor(views::Button::STATE_NORMAL, | 555 increment_button_->SetTextColor(views::Button::STATE_NORMAL, |
| 546 kTouchButtonText); | 556 kTouchButtonText); |
| 547 } else { | 557 } else { |
| 548 SkColor enabled_text_color = GetNativeTheme()->GetSystemColor( | 558 SkColor enabled_text_color = native_theme->GetSystemColor( |
| 549 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); | 559 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); |
| 550 zoom_label_->SetEnabledColor(enabled_text_color); | 560 zoom_label_->SetEnabledColor(enabled_text_color); |
| 551 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, | 561 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, |
| 552 enabled_text_color); | 562 enabled_text_color); |
| 553 increment_button_->SetTextColor(views::Button::STATE_NORMAL, | 563 increment_button_->SetTextColor(views::Button::STATE_NORMAL, |
| 554 enabled_text_color); | 564 enabled_text_color); |
| 555 SkColor disabled_text_color = GetNativeTheme()->GetSystemColor( | 565 SkColor disabled_text_color = native_theme->GetSystemColor( |
| 556 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); | 566 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); |
| 557 decrement_button_->SetTextColor(views::Button::STATE_DISABLED, | 567 decrement_button_->SetTextColor(views::Button::STATE_DISABLED, |
| 558 disabled_text_color); | 568 disabled_text_color); |
| 559 increment_button_->SetTextColor(views::Button::STATE_DISABLED, | 569 increment_button_->SetTextColor(views::Button::STATE_DISABLED, |
| 560 disabled_text_color); | 570 disabled_text_color); |
| 561 } | 571 } |
| 562 | 572 |
| 563 fullscreen_button_->set_focusable(true); | 573 fullscreen_button_->set_focusable(true); |
| 564 fullscreen_button_->set_request_focus_on_press(false); | 574 fullscreen_button_->set_request_focus_on_press(false); |
| 565 fullscreen_button_->set_tag(fullscreen_index); | 575 fullscreen_button_->set_tag(fullscreen_index); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 model->RemoveObserver(this); | 823 model->RemoveObserver(this); |
| 814 } | 824 } |
| 815 if (selected_menu_model_) | 825 if (selected_menu_model_) |
| 816 selected_menu_model_->ActivatedAt(selected_index_); | 826 selected_menu_model_->ActivatedAt(selected_index_); |
| 817 } | 827 } |
| 818 | 828 |
| 819 bool WrenchMenu::IsShowing() { | 829 bool WrenchMenu::IsShowing() { |
| 820 return menu_runner_.get() && menu_runner_->IsRunning(); | 830 return menu_runner_.get() && menu_runner_->IsRunning(); |
| 821 } | 831 } |
| 822 | 832 |
| 823 const views::MenuConfig& WrenchMenu::GetMenuConfig() const { | 833 const ui::NativeTheme* WrenchMenu::GetNativeTheme() const { |
| 824 views::Widget* browser_widget = views::Widget::GetWidgetForNativeView( | 834 views::Widget* browser_widget = views::Widget::GetWidgetForNativeView( |
| 825 browser_->window()->GetNativeWindow()); | 835 browser_->window()->GetNativeWindow()); |
| 826 DCHECK(browser_widget); | 836 DCHECK(browser_widget); |
| 827 return MenuConfig::instance(browser_widget->GetNativeTheme()); | 837 return browser_widget->GetNativeTheme(); |
| 838 } |
| 839 |
| 840 const views::MenuConfig& WrenchMenu::GetMenuConfig() const { |
| 841 return MenuConfig::instance(GetNativeTheme()); |
| 828 } | 842 } |
| 829 | 843 |
| 830 string16 WrenchMenu::GetTooltipText(int id, | 844 string16 WrenchMenu::GetTooltipText(int id, |
| 831 const gfx::Point& p) const { | 845 const gfx::Point& p) const { |
| 832 return is_bookmark_command(id) ? | 846 return is_bookmark_command(id) ? |
| 833 bookmark_menu_delegate_->GetTooltipText(id, p) : string16(); | 847 bookmark_menu_delegate_->GetTooltipText(id, p) : string16(); |
| 834 } | 848 } |
| 835 | 849 |
| 836 bool WrenchMenu::IsTriggerableEvent(views::MenuItemView* menu, | 850 bool WrenchMenu::IsTriggerableEvent(views::MenuItemView* menu, |
| 837 const ui::Event& e) { | 851 const ui::Event& e) { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 (model->GetCommandIdAt(i) == IDC_CUT || | 1055 (model->GetCommandIdAt(i) == IDC_CUT || |
| 1042 model->GetCommandIdAt(i) == IDC_ZOOM_MINUS)) | 1056 model->GetCommandIdAt(i) == IDC_ZOOM_MINUS)) |
| 1043 height = kMenuItemContainingButtonsHeight; | 1057 height = kMenuItemContainingButtonsHeight; |
| 1044 | 1058 |
| 1045 MenuItemView* item = AppendMenuItem( | 1059 MenuItemView* item = AppendMenuItem( |
| 1046 parent, model, i, model->GetTypeAt(i), next_id, height); | 1060 parent, model, i, model->GetTypeAt(i), next_id, height); |
| 1047 | 1061 |
| 1048 if (model->GetTypeAt(i) == MenuModel::TYPE_SUBMENU) | 1062 if (model->GetTypeAt(i) == MenuModel::TYPE_SUBMENU) |
| 1049 PopulateMenu(item, model->GetSubmenuModelAt(i), next_id); | 1063 PopulateMenu(item, model->GetSubmenuModelAt(i), next_id); |
| 1050 | 1064 |
| 1065 const ui::NativeTheme* native_theme = GetNativeTheme(); |
| 1066 |
| 1051 switch (model->GetCommandIdAt(i)) { | 1067 switch (model->GetCommandIdAt(i)) { |
| 1052 case IDC_CUT: | 1068 case IDC_CUT: |
| 1053 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); | 1069 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); |
| 1054 DCHECK_LT(i + 2, max); | 1070 DCHECK_LT(i + 2, max); |
| 1055 DCHECK_EQ(IDC_COPY, model->GetCommandIdAt(i + 1)); | 1071 DCHECK_EQ(IDC_COPY, model->GetCommandIdAt(i + 1)); |
| 1056 DCHECK_EQ(IDC_PASTE, model->GetCommandIdAt(i + 2)); | 1072 DCHECK_EQ(IDC_PASTE, model->GetCommandIdAt(i + 2)); |
| 1057 item->SetTitle(l10n_util::GetStringUTF16(IDS_EDIT2)); | 1073 item->SetTitle(l10n_util::GetStringUTF16(IDS_EDIT2)); |
| 1058 item->AddChildView(new CutCopyPasteView(this, model, i, i + 1, i + 2)); | 1074 item->AddChildView(new CutCopyPasteView(this, model, native_theme, |
| 1075 i, i + 1, i + 2)); |
| 1059 i += 2; | 1076 i += 2; |
| 1060 break; | 1077 break; |
| 1061 | 1078 |
| 1062 case IDC_ZOOM_MINUS: | 1079 case IDC_ZOOM_MINUS: |
| 1063 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); | 1080 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); |
| 1064 DCHECK_EQ(IDC_ZOOM_PLUS, model->GetCommandIdAt(i + 1)); | 1081 DCHECK_EQ(IDC_ZOOM_PLUS, model->GetCommandIdAt(i + 1)); |
| 1065 DCHECK_EQ(IDC_FULLSCREEN, model->GetCommandIdAt(i + 2)); | 1082 DCHECK_EQ(IDC_FULLSCREEN, model->GetCommandIdAt(i + 2)); |
| 1066 item->SetTitle(l10n_util::GetStringUTF16(IDS_ZOOM_MENU2)); | 1083 item->SetTitle(l10n_util::GetStringUTF16(IDS_ZOOM_MENU2)); |
| 1067 item->AddChildView(new ZoomView(this, model, i, i + 1, i + 2)); | 1084 item->AddChildView(new ZoomView(this, model, native_theme, |
| 1085 i, i + 1, i + 2)); |
| 1068 i += 2; | 1086 i += 2; |
| 1069 break; | 1087 break; |
| 1070 | 1088 |
| 1071 case IDC_BOOKMARKS_MENU: | 1089 case IDC_BOOKMARKS_MENU: |
| 1072 DCHECK(!bookmark_menu_); | 1090 DCHECK(!bookmark_menu_); |
| 1073 bookmark_menu_ = item; | 1091 bookmark_menu_ = item; |
| 1074 break; | 1092 break; |
| 1075 | 1093 |
| 1076 case IDC_FEEDBACK: | 1094 case IDC_FEEDBACK: |
| 1077 DCHECK(!feedback_menu_item_); | 1095 DCHECK(!feedback_menu_item_); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 bookmark_menu_delegate_.reset( | 1169 bookmark_menu_delegate_.reset( |
| 1152 new BookmarkMenuDelegate(browser_, | 1170 new BookmarkMenuDelegate(browser_, |
| 1153 browser_, | 1171 browser_, |
| 1154 parent, | 1172 parent, |
| 1155 first_bookmark_command_id_)); | 1173 first_bookmark_command_id_)); |
| 1156 bookmark_menu_delegate_->Init( | 1174 bookmark_menu_delegate_->Init( |
| 1157 this, bookmark_menu_, model->bookmark_bar_node(), 0, | 1175 this, bookmark_menu_, model->bookmark_bar_node(), 0, |
| 1158 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1176 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1159 bookmark_utils::LAUNCH_WRENCH_MENU); | 1177 bookmark_utils::LAUNCH_WRENCH_MENU); |
| 1160 } | 1178 } |
| OLD | NEW |