| 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 button->set_request_focus_on_press(false); | 397 button->set_request_focus_on_press(false); |
| 398 button->set_tag(index); | 398 button->set_tag(index); |
| 399 button->SetEnabled(menu_model_->IsEnabledAt(index)); | 399 button->SetEnabled(menu_model_->IsEnabledAt(index)); |
| 400 MenuButtonBackground* bg = | 400 MenuButtonBackground* bg = |
| 401 new MenuButtonBackground(type, menu_->use_new_menu()); | 401 new MenuButtonBackground(type, menu_->use_new_menu()); |
| 402 button->set_background(bg); | 402 button->set_background(bg); |
| 403 const MenuConfig& menu_config = menu_->GetMenuConfig(); | 403 const MenuConfig& menu_config = menu_->GetMenuConfig(); |
| 404 button->SetTextColor(views::Button::STATE_NORMAL, menu_config.text_color); | 404 button->SetTextColor(views::Button::STATE_NORMAL, menu_config.text_color); |
| 405 if (background) | 405 if (background) |
| 406 *background = bg; | 406 *background = bg; |
| 407 button->set_border( | 407 button->SetBorder(scoped_ptr<views::Border>( |
| 408 new MenuButtonBorder(menu_config, menu_->use_new_menu())); | 408 new MenuButtonBorder(menu_config, menu_->use_new_menu()))); |
| 409 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 409 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 410 button->SetFontList(menu_config.font_list); | 410 button->SetFontList(menu_config.font_list); |
| 411 ui::NativeTheme* native_theme = button->GetNativeTheme(); | 411 ui::NativeTheme* native_theme = button->GetNativeTheme(); |
| 412 button->SetTextColor( | 412 button->SetTextColor( |
| 413 views::Button::STATE_DISABLED, | 413 views::Button::STATE_DISABLED, |
| 414 native_theme->GetSystemColor( | 414 native_theme->GetSystemColor( |
| 415 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); | 415 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); |
| 416 button->SetTextColor( | 416 button->SetTextColor( |
| 417 views::Button::STATE_HOVERED, | 417 views::Button::STATE_HOVERED, |
| 418 native_theme->GetSystemColor( | 418 native_theme->GetSystemColor( |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 zoom_label_->SetAutoColorReadabilityEnabled(false); | 619 zoom_label_->SetAutoColorReadabilityEnabled(false); |
| 620 zoom_label_->SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 620 zoom_label_->SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
| 621 | 621 |
| 622 MenuButtonBackground* center_bg = new MenuButtonBackground( | 622 MenuButtonBackground* center_bg = new MenuButtonBackground( |
| 623 menu->use_new_menu() && menu->supports_new_separators_ ? | 623 menu->use_new_menu() && menu->supports_new_separators_ ? |
| 624 MenuButtonBackground::RIGHT_BUTTON : | 624 MenuButtonBackground::RIGHT_BUTTON : |
| 625 MenuButtonBackground::CENTER_BUTTON, | 625 MenuButtonBackground::CENTER_BUTTON, |
| 626 menu->use_new_menu()); | 626 menu->use_new_menu()); |
| 627 zoom_label_->set_background(center_bg); | 627 zoom_label_->set_background(center_bg); |
| 628 const MenuConfig& menu_config(menu->GetMenuConfig()); | 628 const MenuConfig& menu_config(menu->GetMenuConfig()); |
| 629 zoom_label_->set_border( | 629 zoom_label_->SetBorder(scoped_ptr<views::Border>( |
| 630 new MenuButtonBorder(menu_config, menu->use_new_menu())); | 630 new MenuButtonBorder(menu_config, menu->use_new_menu()))); |
| 631 zoom_label_->SetFontList(menu_config.font_list); | 631 zoom_label_->SetFontList(menu_config.font_list); |
| 632 | 632 |
| 633 AddChildView(zoom_label_); | 633 AddChildView(zoom_label_); |
| 634 zoom_label_width_ = MaxWidthForZoomLabel(); | 634 zoom_label_width_ = MaxWidthForZoomLabel(); |
| 635 | 635 |
| 636 increment_button_ = CreateButtonWithAccName( | 636 increment_button_ = CreateButtonWithAccName( |
| 637 IDS_ZOOM_PLUS2, MenuButtonBackground::RIGHT_BUTTON, increment_index, | 637 IDS_ZOOM_PLUS2, MenuButtonBackground::RIGHT_BUTTON, increment_index, |
| 638 NULL, IDS_ACCNAME_ZOOM_PLUS2); | 638 NULL, IDS_ACCNAME_ZOOM_PLUS2); |
| 639 | 639 |
| 640 center_bg->SetOtherButtons(decrement_button_, increment_button_); | 640 center_bg->SetOtherButtons(decrement_button_, increment_button_); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 670 disabled_text_color); | 670 disabled_text_color); |
| 671 increment_button_->SetTextColor(views::Button::STATE_DISABLED, | 671 increment_button_->SetTextColor(views::Button::STATE_DISABLED, |
| 672 disabled_text_color); | 672 disabled_text_color); |
| 673 fullscreen_button_->SetFocusable(true); | 673 fullscreen_button_->SetFocusable(true); |
| 674 fullscreen_button_->set_request_focus_on_press(false); | 674 fullscreen_button_->set_request_focus_on_press(false); |
| 675 fullscreen_button_->set_tag(fullscreen_index); | 675 fullscreen_button_->set_tag(fullscreen_index); |
| 676 fullscreen_button_->SetImageAlignment( | 676 fullscreen_button_->SetImageAlignment( |
| 677 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); | 677 ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); |
| 678 int horizontal_padding = | 678 int horizontal_padding = |
| 679 menu->use_new_menu() ? kHorizontalTouchPadding : kHorizontalPadding; | 679 menu->use_new_menu() ? kHorizontalTouchPadding : kHorizontalPadding; |
| 680 fullscreen_button_->set_border(views::Border::CreateEmptyBorder( | 680 fullscreen_button_->SetBorder(views::Border::CreateEmptyBorder( |
| 681 0, horizontal_padding, 0, horizontal_padding)); | 681 0, horizontal_padding, 0, horizontal_padding)); |
| 682 fullscreen_button_->set_background( | 682 fullscreen_button_->set_background( |
| 683 new MenuButtonBackground(MenuButtonBackground::SINGLE_BUTTON, | 683 new MenuButtonBackground(MenuButtonBackground::SINGLE_BUTTON, |
| 684 menu->use_new_menu())); | 684 menu->use_new_menu())); |
| 685 fullscreen_button_->SetAccessibleName( | 685 fullscreen_button_->SetAccessibleName( |
| 686 GetAccessibleNameForWrenchMenuItem( | 686 GetAccessibleNameForWrenchMenuItem( |
| 687 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); | 687 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); |
| 688 AddChildView(fullscreen_button_); | 688 AddChildView(fullscreen_button_); |
| 689 | 689 |
| 690 UpdateZoomControls(); | 690 UpdateZoomControls(); |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 0, | 1366 0, |
| 1367 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1367 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1368 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1368 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1371 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
| 1372 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1372 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1373 DCHECK(ix != command_id_to_entry_.end()); | 1373 DCHECK(ix != command_id_to_entry_.end()); |
| 1374 return ix->second.second; | 1374 return ix->second.second; |
| 1375 } | 1375 } |
| OLD | NEW |