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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 MenuButtonBackground::ButtonType type, | 383 MenuButtonBackground::ButtonType type, |
384 int index, | 384 int index, |
385 MenuButtonBackground** background, | 385 MenuButtonBackground** background, |
386 int acc_string_id) { | 386 int acc_string_id) { |
387 // Should only be invoked during construction when |menu_| is valid. | 387 // Should only be invoked during construction when |menu_| is valid. |
388 DCHECK(menu_); | 388 DCHECK(menu_); |
389 LabelButton* button = new LabelButton(this, gfx::RemoveAcceleratorChar( | 389 LabelButton* button = new LabelButton(this, gfx::RemoveAcceleratorChar( |
390 l10n_util::GetStringUTF16(string_id), '&', NULL, NULL)); | 390 l10n_util::GetStringUTF16(string_id), '&', NULL, NULL)); |
391 button->SetAccessibleName( | 391 button->SetAccessibleName( |
392 GetAccessibleNameForWrenchMenuItem(menu_model_, index, acc_string_id)); | 392 GetAccessibleNameForWrenchMenuItem(menu_model_, index, acc_string_id)); |
393 button->set_focusable(true); | 393 button->SetFocusable(true); |
394 button->set_request_focus_on_press(false); | 394 button->set_request_focus_on_press(false); |
395 button->set_tag(index); | 395 button->set_tag(index); |
396 button->SetEnabled(menu_model_->IsEnabledAt(index)); | 396 button->SetEnabled(menu_model_->IsEnabledAt(index)); |
397 MenuButtonBackground* bg = | 397 MenuButtonBackground* bg = |
398 new MenuButtonBackground(type, menu_->use_new_menu()); | 398 new MenuButtonBackground(type, menu_->use_new_menu()); |
399 button->set_background(bg); | 399 button->set_background(bg); |
400 const MenuConfig& menu_config = menu_->GetMenuConfig(); | 400 const MenuConfig& menu_config = menu_->GetMenuConfig(); |
401 button->SetTextColor(views::Button::STATE_NORMAL, menu_config.text_color); | 401 button->SetTextColor(views::Button::STATE_NORMAL, menu_config.text_color); |
402 if (background) | 402 if (background) |
403 *background = bg; | 403 *background = bg; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, | 656 decrement_button_->SetTextColor(views::Button::STATE_NORMAL, |
657 enabled_text_color); | 657 enabled_text_color); |
658 increment_button_->SetTextColor(views::Button::STATE_NORMAL, | 658 increment_button_->SetTextColor(views::Button::STATE_NORMAL, |
659 enabled_text_color); | 659 enabled_text_color); |
660 SkColor disabled_text_color = native_theme->GetSystemColor( | 660 SkColor disabled_text_color = native_theme->GetSystemColor( |
661 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); | 661 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); |
662 decrement_button_->SetTextColor(views::Button::STATE_DISABLED, | 662 decrement_button_->SetTextColor(views::Button::STATE_DISABLED, |
663 disabled_text_color); | 663 disabled_text_color); |
664 increment_button_->SetTextColor(views::Button::STATE_DISABLED, | 664 increment_button_->SetTextColor(views::Button::STATE_DISABLED, |
665 disabled_text_color); | 665 disabled_text_color); |
666 fullscreen_button_->set_focusable(true); | 666 fullscreen_button_->SetFocusable(true); |
667 fullscreen_button_->set_request_focus_on_press(false); | 667 fullscreen_button_->set_request_focus_on_press(false); |
668 fullscreen_button_->set_tag(fullscreen_index); | 668 fullscreen_button_->set_tag(fullscreen_index); |
669 fullscreen_button_->SetImageAlignment( | 669 fullscreen_button_->SetImageAlignment( |
670 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); | 670 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); |
671 int horizontal_padding = | 671 int horizontal_padding = |
672 menu->use_new_menu() ? kHorizontalTouchPadding : kHorizontalPadding; | 672 menu->use_new_menu() ? kHorizontalTouchPadding : kHorizontalPadding; |
673 fullscreen_button_->set_border(views::Border::CreateEmptyBorder( | 673 fullscreen_button_->set_border(views::Border::CreateEmptyBorder( |
674 0, horizontal_padding, 0, horizontal_padding)); | 674 0, horizontal_padding, 0, horizontal_padding)); |
675 fullscreen_button_->set_background( | 675 fullscreen_button_->set_background( |
676 new MenuButtonBackground(MenuButtonBackground::SINGLE_BUTTON, | 676 new MenuButtonBackground(MenuButtonBackground::SINGLE_BUTTON, |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 0, | 1359 0, |
1360 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1360 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1361 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1361 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
1362 } | 1362 } |
1363 | 1363 |
1364 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1364 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
1365 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1365 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1366 DCHECK(ix != command_id_to_entry_.end()); | 1366 DCHECK(ix != command_id_to_entry_.end()); |
1367 return ix->second.second; | 1367 return ix->second.second; |
1368 } | 1368 } |
OLD | NEW |