Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/wrench_menu.h" | 5 #include "chrome/browser/ui/views/toolbar/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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 using views::CustomButton; | 67 using views::CustomButton; |
| 68 using views::ImageButton; | 68 using views::ImageButton; |
| 69 using views::Label; | 69 using views::Label; |
| 70 using views::LabelButton; | 70 using views::LabelButton; |
| 71 using views::MenuConfig; | 71 using views::MenuConfig; |
| 72 using views::MenuItemView; | 72 using views::MenuItemView; |
| 73 using views::View; | 73 using views::View; |
| 74 | 74 |
| 75 namespace { | 75 namespace { |
| 76 | 76 |
| 77 // Colors used for buttons. | |
| 78 const SkColor kEnabledTouchBackgroundColor = SkColorSetARGB(247, 255, 255, 255); | |
| 79 const SkColor kHoverTouchBackgroundColor = SkColorSetARGB(247, 242, 242, 242); | |
| 80 const SkColor kFocusedTouchBackgroundColor = SkColorSetARGB(247, 235, 235, 235); | |
| 81 | |
| 82 const SkColor kTouchButtonText = 0xff5a5a5a; | |
| 83 | |
| 84 // Horizontal padding on the edges of the buttons. | 77 // Horizontal padding on the edges of the buttons. |
| 85 const int kHorizontalPadding = 6; | 78 const int kHorizontalPadding = 6; |
| 86 // Horizontal padding for a touch enabled menu. | 79 // Horizontal padding for a touch enabled menu. |
| 87 const int kHorizontalTouchPadding = 15; | 80 const int kHorizontalTouchPadding = 15; |
| 88 | 81 |
| 89 // Menu items which have embedded buttons should have this height in pixel. | 82 // Menu items which have embedded buttons should have this height in pixel. |
| 90 const int kMenuItemContainingButtonsHeight = 43; | 83 const int kMenuItemContainingButtonsHeight = 43; |
| 91 | 84 |
| 92 // Returns true if |command_id| identifies a bookmark menu item. | 85 // Returns true if |command_id| identifies a bookmark menu item. |
| 93 bool IsBookmarkCommand(int command_id) { | 86 bool IsBookmarkCommand(int command_id) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 left_button_ = right_button; | 174 left_button_ = right_button; |
| 182 right_button_ = left_button; | 175 right_button_ = left_button; |
| 183 } else { | 176 } else { |
| 184 left_button_ = left_button; | 177 left_button_ = left_button; |
| 185 right_button_ = right_button; | 178 right_button_ = right_button; |
| 186 } | 179 } |
| 187 } | 180 } |
| 188 | 181 |
| 189 // Overridden from views::Background. | 182 // Overridden from views::Background. |
| 190 virtual void Paint(gfx::Canvas* canvas, View* view) const OVERRIDE { | 183 virtual void Paint(gfx::Canvas* canvas, View* view) const OVERRIDE { |
| 191 CustomButton::ButtonState state = | 184 CustomButton* button = CustomButton::AsCustomButton(view); |
| 192 (!strcmp(view->GetClassName(), views::Label::kViewClassName)) ? | 185 views::Button::ButtonState state = |
| 193 CustomButton::STATE_NORMAL : static_cast<CustomButton*>(view)->state(); | 186 button ? button->state() : views::Button::STATE_NORMAL; |
| 194 int w = view->width(); | 187 int w = view->width(); |
| 195 int h = view->height(); | 188 int h = view->height(); |
| 196 #if defined(USE_AURA) | 189 #if defined(USE_AURA) |
| 197 if (use_new_menu_ && | 190 // Normal buttons get a border drawn on the right side and the rest gets |
| 198 view->GetNativeTheme() == ui::NativeThemeAura::instance()) { | 191 // filled in. The left button however does not get a line to combine |
| 199 // Normal buttons get a border drawn on the right side and the rest gets | 192 // buttons. |
| 200 // filled in. The left button however does not get a line to combine | 193 int border = 0; |
| 201 // buttons. | 194 if (type_ != RIGHT_BUTTON) { |
| 202 int border = 0; | 195 border = 1; |
| 203 if (type_ != RIGHT_BUTTON) { | 196 canvas->FillRect(gfx::Rect(0, 0, border, h), |
| 204 border = 1; | 197 BorderColor(view, views::Button::STATE_NORMAL)); |
| 205 canvas->FillRect(gfx::Rect(0, 0, border, h), | 198 } |
| 206 BorderColor(view, CustomButton::STATE_NORMAL)); | 199 if (use_new_menu_) { |
| 207 } | 200 gfx::Rect bounds(view->GetLocalBounds()); |
| 208 canvas->FillRect(gfx::Rect(border, 0, w - border, h), | 201 bounds.set_x(view->GetMirroredXForRect(bounds)); |
| 209 touch_background_color(state)); | 202 DrawBackground(canvas, view, bounds, state); |
| 210 return; | 203 return; |
| 211 } | 204 } |
| 205 if (use_new_menu_) | |
| 206 return; | |
| 212 #endif | 207 #endif |
| 213 const SkColor background = BackgroundColor(view, state); | 208 const SkColor border_color = BorderColor(view, state); |
| 214 const SkColor border = BorderColor(view, state); | |
| 215 switch (TypeAdjustedForRTL()) { | 209 switch (TypeAdjustedForRTL()) { |
| 216 // TODO(pkasting): Why don't all the following use SkPaths with rounded | 210 // TODO(pkasting): Why don't all the following use SkPaths with rounded |
| 217 // corners? | 211 // corners? |
| 218 case LEFT_BUTTON: | 212 case LEFT_BUTTON: |
| 219 canvas->FillRect(gfx::Rect(1, 1, w, h - 2), background); | 213 DrawBackground(canvas, view, gfx::Rect(1, 1, w, h - 2), state); |
| 220 canvas->FillRect(gfx::Rect(2, 0, w, 1), border); | 214 canvas->FillRect(gfx::Rect(2, 0, w, 1), border_color); |
| 221 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border); | 215 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color); |
| 222 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border); | 216 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color); |
| 223 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border); | 217 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color); |
| 224 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border); | 218 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border_color); |
| 225 break; | 219 break; |
| 226 | 220 |
| 227 case CENTER_BUTTON: { | 221 case CENTER_BUTTON: { |
| 228 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), background); | 222 DrawBackground(canvas, view, gfx::Rect(1, 1, w - 2, h - 2), state); |
| 229 SkColor left_color = state != CustomButton::STATE_NORMAL ? | 223 SkColor left_color = state != views::Button::STATE_NORMAL ? |
| 230 border : BorderColor(view, left_button_->state()); | 224 border_color : BorderColor(view, left_button_->state()); |
| 231 canvas->FillRect(gfx::Rect(0, 0, 1, h), left_color); | 225 canvas->FillRect(gfx::Rect(0, 0, 1, h), left_color); |
| 232 canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border); | 226 canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border_color); |
| 233 canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1), | 227 canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1), |
| 234 border); | 228 border_color); |
| 235 SkColor right_color = state != CustomButton::STATE_NORMAL ? | 229 SkColor right_color = state != views::Button::STATE_NORMAL ? |
| 236 border : BorderColor(view, right_button_->state()); | 230 border_color : BorderColor(view, right_button_->state()); |
| 237 canvas->FillRect(gfx::Rect(w - 1, 0, 1, h), right_color); | 231 canvas->FillRect(gfx::Rect(w - 1, 0, 1, h), right_color); |
| 238 break; | 232 break; |
| 239 } | 233 } |
| 240 | 234 |
| 241 case RIGHT_BUTTON: | 235 case RIGHT_BUTTON: |
| 242 canvas->FillRect(gfx::Rect(0, 1, w - 1, h - 2), background); | 236 DrawBackground(canvas, view, gfx::Rect(0, 1, w - 1, h - 2), state); |
| 243 canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border); | 237 canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border_color); |
| 244 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border); | 238 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color); |
| 245 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border); | 239 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color); |
| 246 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border); | 240 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color); |
| 247 canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1), border); | 241 canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1), border_color); |
| 248 break; | 242 break; |
| 249 | 243 |
| 250 case SINGLE_BUTTON: | 244 case SINGLE_BUTTON: |
| 251 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), background); | 245 DrawBackground(canvas, view, gfx::Rect(1, 1, w - 2, h - 2), state); |
| 252 canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border); | 246 canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border_color); |
| 253 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border); | 247 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color); |
| 254 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border); | 248 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color); |
| 255 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border); | 249 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color); |
| 256 canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1), border); | 250 canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1), border_color); |
| 257 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border); | 251 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color); |
| 258 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border); | 252 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color); |
| 259 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border); | 253 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color); |
| 260 break; | 254 break; |
| 261 | 255 |
| 262 default: | 256 default: |
| 263 NOTREACHED(); | 257 NOTREACHED(); |
| 264 break; | 258 break; |
| 265 } | 259 } |
| 266 } | 260 } |
| 267 | 261 |
| 268 private: | 262 private: |
| 269 static SkColor BorderColor(View* view, CustomButton::ButtonState state) { | 263 static SkColor BorderColor(View* view, views::Button::ButtonState state) { |
| 270 ui::NativeTheme* theme = view->GetNativeTheme(); | 264 ui::NativeTheme* theme = view->GetNativeTheme(); |
| 271 switch (state) { | 265 switch (state) { |
| 272 case CustomButton::STATE_HOVERED: | 266 case views::Button::STATE_HOVERED: |
| 273 return theme->GetSystemColor( | 267 return theme->GetSystemColor( |
| 274 ui::NativeTheme::kColorId_HoverMenuButtonBorderColor); | 268 ui::NativeTheme::kColorId_HoverMenuButtonBorderColor); |
| 275 case CustomButton::STATE_PRESSED: | 269 case views::Button::STATE_PRESSED: |
| 276 return theme->GetSystemColor( | 270 return theme->GetSystemColor( |
| 277 ui::NativeTheme::kColorId_FocusedMenuButtonBorderColor); | 271 ui::NativeTheme::kColorId_FocusedMenuButtonBorderColor); |
| 278 default: | 272 default: |
| 279 return theme->GetSystemColor( | 273 return theme->GetSystemColor( |
| 280 ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor); | 274 ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor); |
| 281 } | 275 } |
| 282 } | 276 } |
| 283 | 277 |
| 284 static SkColor BackgroundColor(View* view, CustomButton::ButtonState state) { | 278 static SkColor BackgroundColor(const View* view, views::Button::ButtonState st ate) { |
| 285 ui::NativeTheme* theme = view->GetNativeTheme(); | 279 const ui::NativeTheme* theme = view->GetNativeTheme(); |
| 286 switch (state) { | 280 switch (state) { |
| 287 case CustomButton::STATE_HOVERED: | 281 case views::Button::STATE_HOVERED: |
| 282 NOTREACHED(); | |
| 288 return theme->GetSystemColor( | 283 return theme->GetSystemColor( |
| 289 ui::NativeTheme::kColorId_HoverMenuItemBackgroundColor); | 284 ui::NativeTheme::kColorId_HoverMenuItemBackgroundColor); |
| 290 case CustomButton::STATE_PRESSED: | 285 case views::Button::STATE_PRESSED: |
| 291 return theme->GetSystemColor( | 286 return theme->GetSystemColor( |
| 292 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor); | 287 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor); |
| 293 default: | 288 default: |
| 294 return theme->GetSystemColor( | 289 return theme->GetSystemColor( |
| 295 ui::NativeTheme::kColorId_MenuBackgroundColor); | 290 ui::NativeTheme::kColorId_MenuBackgroundColor); |
| 296 } | 291 } |
| 297 } | 292 } |
| 298 | 293 |
| 299 static SkColor touch_background_color(CustomButton::ButtonState state) { | 294 void DrawBackground(gfx::Canvas* canvas, |
| 300 switch (state) { | 295 const views::View* view, |
| 301 case CustomButton::STATE_HOVERED: return kHoverTouchBackgroundColor; | 296 const gfx::Rect& bounds, |
| 302 case CustomButton::STATE_PRESSED: return kFocusedTouchBackgroundColor; | 297 views::Button::ButtonState state) const { |
| 303 default: return kEnabledTouchBackgroundColor; | 298 if (state == views::Button::STATE_HOVERED) { |
| 299 view->GetNativeTheme()->Paint(canvas->sk_canvas(), | |
| 300 ui::NativeTheme::kMenuItemBackground, | |
| 301 ui::NativeTheme::kHovered, | |
| 302 bounds, | |
| 303 ui::NativeTheme::ExtraParams()); | |
| 304 return; | |
| 304 } | 305 } |
| 306 if (use_new_menu_) | |
| 307 return; | |
| 308 canvas->FillRect(bounds, BackgroundColor(view, state)); | |
|
oshima
2013/11/25 21:59:01
I wonder if this is correct/intentional. MenuItemv
| |
| 305 } | 309 } |
| 306 | 310 |
| 307 ButtonType TypeAdjustedForRTL() const { | 311 ButtonType TypeAdjustedForRTL() const { |
| 308 if (!base::i18n::IsRTL()) | 312 if (!base::i18n::IsRTL()) |
| 309 return type_; | 313 return type_; |
| 310 | 314 |
| 311 switch (type_) { | 315 switch (type_) { |
| 312 case LEFT_BUTTON: return RIGHT_BUTTON; | 316 case LEFT_BUTTON: return RIGHT_BUTTON; |
| 313 case RIGHT_BUTTON: return LEFT_BUTTON; | 317 case RIGHT_BUTTON: return LEFT_BUTTON; |
| 314 default: break; | 318 default: break; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 // Overridden from views::View. | 365 // Overridden from views::View. |
| 362 virtual void SchedulePaintInRect(const gfx::Rect& r) OVERRIDE { | 366 virtual void SchedulePaintInRect(const gfx::Rect& r) OVERRIDE { |
| 363 // Normally when the mouse enters/exits a button the buttons invokes | 367 // Normally when the mouse enters/exits a button the buttons invokes |
| 364 // SchedulePaint. As part of the button border (MenuButtonBackground) is | 368 // SchedulePaint. As part of the button border (MenuButtonBackground) is |
| 365 // rendered by the button to the left/right of it SchedulePaint on the the | 369 // rendered by the button to the left/right of it SchedulePaint on the the |
| 366 // button may not be enough, so this forces a paint all. | 370 // button may not be enough, so this forces a paint all. |
| 367 View::SchedulePaintInRect(gfx::Rect(size())); | 371 View::SchedulePaintInRect(gfx::Rect(size())); |
| 368 } | 372 } |
| 369 | 373 |
| 370 LabelButton* CreateAndConfigureButton(int string_id, | 374 LabelButton* CreateAndConfigureButton(int string_id, |
| 371 MenuButtonBackground::ButtonType type, | 375 MenuButtonBackground::ButtonType type, |
| 372 int index, | 376 int index, |
| 373 MenuButtonBackground** background) { | 377 MenuButtonBackground** background) { |
| 374 return CreateButtonWithAccName( | 378 return CreateButtonWithAccName( |
| 375 string_id, type, index, background, string_id); | 379 string_id, type, index, background, string_id); |
| 376 } | 380 } |
| 377 | 381 |
| 378 LabelButton* CreateButtonWithAccName(int string_id, | 382 LabelButton* CreateButtonWithAccName(int string_id, |
| 379 MenuButtonBackground::ButtonType type, | 383 MenuButtonBackground::ButtonType type, |
| 380 int index, | 384 int index, |
| 381 MenuButtonBackground** background, | 385 MenuButtonBackground** background, |
| 382 int acc_string_id) { | 386 int acc_string_id) { |
| 383 // Should only be invoked during construction when |menu_| is valid. | 387 // Should only be invoked during construction when |menu_| is valid. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 394 new MenuButtonBackground(type, menu_->use_new_menu()); | 398 new MenuButtonBackground(type, menu_->use_new_menu()); |
| 395 button->set_background(bg); | 399 button->set_background(bg); |
| 396 const MenuConfig& menu_config = menu_->GetMenuConfig(); | 400 const MenuConfig& menu_config = menu_->GetMenuConfig(); |
| 397 button->SetTextColor(views::Button::STATE_NORMAL, menu_config.text_color); | 401 button->SetTextColor(views::Button::STATE_NORMAL, menu_config.text_color); |
| 398 if (background) | 402 if (background) |
| 399 *background = bg; | 403 *background = bg; |
| 400 button->set_border( | 404 button->set_border( |
| 401 new MenuButtonBorder(menu_config, menu_->use_new_menu())); | 405 new MenuButtonBorder(menu_config, menu_->use_new_menu())); |
| 402 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 406 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 403 button->SetFont(menu_config.font); | 407 button->SetFont(menu_config.font); |
| 408 ui::NativeTheme* native_theme = button->GetNativeTheme(); | |
| 409 | |
| 410 button->SetTextColor( | |
| 411 views::Button::STATE_DISABLED, | |
| 412 native_theme->GetSystemColor( | |
| 413 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); | |
| 414 button->SetTextColor( | |
| 415 views::Button::STATE_HOVERED, | |
| 416 native_theme->GetSystemColor( | |
| 417 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor)); | |
| 418 button->SetTextColor( | |
| 419 views::Button::STATE_PRESSED, | |
| 420 native_theme->GetSystemColor( | |
| 421 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor)); | |
| 422 button->SetTextColor( | |
| 423 views::Button::STATE_NORMAL, | |
| 424 native_theme->GetSystemColor( | |
| 425 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor)); | |
| 404 AddChildView(button); | 426 AddChildView(button); |
| 405 return button; | 427 return button; |
| 406 } | 428 } |
| 407 | 429 |
| 408 // Overridden from WrenchMenuObserver: | 430 // Overridden from WrenchMenuObserver: |
| 409 virtual void WrenchMenuDestroyed() OVERRIDE { | 431 virtual void WrenchMenuDestroyed() OVERRIDE { |
| 410 menu_->RemoveObserver(this); | 432 menu_->RemoveObserver(this); |
| 411 menu_ = NULL; | 433 menu_ = NULL; |
| 412 menu_model_ = NULL; | 434 menu_model_ = NULL; |
| 413 } | 435 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 IDS_COPY, MenuButtonBackground::CENTER_BUTTON, copy_index, | 499 IDS_COPY, MenuButtonBackground::CENTER_BUTTON, copy_index, |
| 478 ©_background); | 500 ©_background); |
| 479 | 501 |
| 480 LabelButton* paste = CreateAndConfigureButton( | 502 LabelButton* paste = CreateAndConfigureButton( |
| 481 IDS_PASTE, | 503 IDS_PASTE, |
| 482 menu->use_new_menu() && menu->supports_new_separators_ ? | 504 menu->use_new_menu() && menu->supports_new_separators_ ? |
| 483 MenuButtonBackground::CENTER_BUTTON : | 505 MenuButtonBackground::CENTER_BUTTON : |
| 484 MenuButtonBackground::RIGHT_BUTTON, | 506 MenuButtonBackground::RIGHT_BUTTON, |
| 485 paste_index, | 507 paste_index, |
| 486 NULL); | 508 NULL); |
| 487 if (menu->use_new_menu()) { | 509 SkColor text_color = native_theme->GetSystemColor( |
| 488 cut->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); | 510 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); |
| 489 copy->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); | 511 cut->SetTextColor(views::Button::STATE_NORMAL, text_color); |
| 490 paste->SetTextColor(views::Button::STATE_NORMAL, kTouchButtonText); | 512 copy->SetTextColor(views::Button::STATE_NORMAL, text_color); |
| 491 } else { | 513 paste->SetTextColor(views::Button::STATE_NORMAL, text_color); |
| 492 SkColor text_color = native_theme->GetSystemColor( | |
| 493 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); | |
| 494 cut->SetTextColor(views::Button::STATE_NORMAL, text_color); | |
| 495 copy->SetTextColor(views::Button::STATE_NORMAL, text_color); | |
| 496 paste->SetTextColor(views::Button::STATE_NORMAL, text_color); | |
| 497 } | |
| 498 copy_background->SetOtherButtons(cut, paste); | 514 copy_background->SetOtherButtons(cut, paste); |
| 499 } | 515 } |
| 500 | 516 |
| 501 // Overridden from View. | 517 // Overridden from View. |
| 502 virtual gfx::Size GetPreferredSize() OVERRIDE { | 518 virtual gfx::Size GetPreferredSize() OVERRIDE { |
| 503 // Returned height doesn't matter as MenuItemView forces everything to the | 519 // Returned height doesn't matter as MenuItemView forces everything to the |
| 504 // height of the menuitemview. | 520 // height of the menuitemview. |
| 505 return gfx::Size(GetMaxChildViewPreferredWidth() * child_count(), 0); | 521 return gfx::Size(GetMaxChildViewPreferredWidth() * child_count(), 0); |
| 506 } | 522 } |
| 507 | 523 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 IDS_ZOOM_PLUS2, MenuButtonBackground::RIGHT_BUTTON, increment_index, | 602 IDS_ZOOM_PLUS2, MenuButtonBackground::RIGHT_BUTTON, increment_index, |
| 587 NULL, IDS_ACCNAME_ZOOM_PLUS2); | 603 NULL, IDS_ACCNAME_ZOOM_PLUS2); |
| 588 | 604 |
| 589 center_bg->SetOtherButtons(decrement_button_, increment_button_); | 605 center_bg->SetOtherButtons(decrement_button_, increment_button_); |
| 590 | 606 |
| 591 fullscreen_button_ = new FullscreenButton(this); | 607 fullscreen_button_ = new FullscreenButton(this); |
| 592 gfx::ImageSkia* full_screen_image = | 608 gfx::ImageSkia* full_screen_image = |
| 593 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 609 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 594 IDR_FULLSCREEN_MENU_BUTTON); | 610 IDR_FULLSCREEN_MENU_BUTTON); |
| 595 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); | 611 fullscreen_button_->SetImage(ImageButton::STATE_NORMAL, full_screen_image); |
| 596 if (menu->use_new_menu()) { | 612 SkColor enabled_text_color = native_theme->GetSystemColor( |
| 597 zoom_label_->SetEnabledColor(kTouchButtonText); | 613 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); |
| 598 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, | 614 zoom_label_->SetEnabledColor(enabled_text_color); |
| 599 kTouchButtonText); | 615 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, |
| 600 increment_button_->SetTextColor(views::Button::STATE_NORMAL, | 616 enabled_text_color); |
| 601 kTouchButtonText); | 617 increment_button_->SetTextColor(views::Button::STATE_NORMAL, |
| 602 } else { | 618 enabled_text_color); |
| 603 SkColor enabled_text_color = native_theme->GetSystemColor( | 619 SkColor disabled_text_color = native_theme->GetSystemColor( |
| 604 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); | 620 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); |
| 605 zoom_label_->SetEnabledColor(enabled_text_color); | 621 decrement_button_->SetTextColor(views::Button::STATE_DISABLED, |
| 606 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, | 622 disabled_text_color); |
| 607 enabled_text_color); | 623 increment_button_->SetTextColor(views::Button::STATE_DISABLED, |
| 608 increment_button_->SetTextColor(views::Button::STATE_NORMAL, | 624 disabled_text_color); |
| 609 enabled_text_color); | |
| 610 SkColor disabled_text_color = native_theme->GetSystemColor( | |
| 611 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); | |
| 612 decrement_button_->SetTextColor(views::Button::STATE_DISABLED, | |
| 613 disabled_text_color); | |
| 614 increment_button_->SetTextColor(views::Button::STATE_DISABLED, | |
| 615 disabled_text_color); | |
| 616 } | |
| 617 | |
| 618 fullscreen_button_->set_focusable(true); | 625 fullscreen_button_->set_focusable(true); |
| 619 fullscreen_button_->set_request_focus_on_press(false); | 626 fullscreen_button_->set_request_focus_on_press(false); |
| 620 fullscreen_button_->set_tag(fullscreen_index); | 627 fullscreen_button_->set_tag(fullscreen_index); |
| 621 fullscreen_button_->SetImageAlignment( | 628 fullscreen_button_->SetImageAlignment( |
| 622 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); | 629 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); |
| 623 int horizontal_padding = | 630 int horizontal_padding = |
| 624 menu->use_new_menu() ? kHorizontalTouchPadding : kHorizontalPadding; | 631 menu->use_new_menu() ? kHorizontalTouchPadding : kHorizontalPadding; |
| 625 fullscreen_button_->set_border(views::Border::CreateEmptyBorder( | 632 fullscreen_button_->set_border(views::Border::CreateEmptyBorder( |
| 626 0, horizontal_padding, 0, horizontal_padding)); | 633 0, horizontal_padding, 0, horizontal_padding)); |
| 627 fullscreen_button_->set_background( | 634 fullscreen_button_->set_background( |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1311 0, | 1318 0, |
| 1312 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1319 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1313 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1320 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
| 1314 } | 1321 } |
| 1315 | 1322 |
| 1316 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1323 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
| 1317 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1324 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1318 DCHECK(ix != command_id_to_entry_.end()); | 1325 DCHECK(ix != command_id_to_entry_.end()); |
| 1319 return ix->second.second; | 1326 return ix->second.second; |
| 1320 } | 1327 } |
| OLD | NEW |