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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 MenuButtonBackground* bg = | 399 MenuButtonBackground* bg = |
400 new MenuButtonBackground(type, menu_->use_new_menu()); | 400 new MenuButtonBackground(type, menu_->use_new_menu()); |
401 button->set_background(bg); | 401 button->set_background(bg); |
402 const MenuConfig& menu_config = menu_->GetMenuConfig(); | 402 const MenuConfig& menu_config = menu_->GetMenuConfig(); |
403 button->SetTextColor(views::Button::STATE_NORMAL, menu_config.text_color); | 403 button->SetTextColor(views::Button::STATE_NORMAL, menu_config.text_color); |
404 if (background) | 404 if (background) |
405 *background = bg; | 405 *background = bg; |
406 button->set_border( | 406 button->set_border( |
407 new MenuButtonBorder(menu_config, menu_->use_new_menu())); | 407 new MenuButtonBorder(menu_config, menu_->use_new_menu())); |
408 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 408 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
409 button->SetFontList(gfx::FontList(menu_config.font)); | 409 button->SetFontList(menu_config.font_list); |
410 ui::NativeTheme* native_theme = button->GetNativeTheme(); | 410 ui::NativeTheme* native_theme = button->GetNativeTheme(); |
411 button->SetTextColor( | 411 button->SetTextColor( |
412 views::Button::STATE_DISABLED, | 412 views::Button::STATE_DISABLED, |
413 native_theme->GetSystemColor( | 413 native_theme->GetSystemColor( |
414 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); | 414 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); |
415 button->SetTextColor( | 415 button->SetTextColor( |
416 views::Button::STATE_HOVERED, | 416 views::Button::STATE_HOVERED, |
417 native_theme->GetSystemColor( | 417 native_theme->GetSystemColor( |
418 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor)); | 418 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor)); |
419 button->SetTextColor( | 419 button->SetTextColor( |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 620 |
621 MenuButtonBackground* center_bg = new MenuButtonBackground( | 621 MenuButtonBackground* center_bg = new MenuButtonBackground( |
622 menu->use_new_menu() && menu->supports_new_separators_ ? | 622 menu->use_new_menu() && menu->supports_new_separators_ ? |
623 MenuButtonBackground::RIGHT_BUTTON : | 623 MenuButtonBackground::RIGHT_BUTTON : |
624 MenuButtonBackground::CENTER_BUTTON, | 624 MenuButtonBackground::CENTER_BUTTON, |
625 menu->use_new_menu()); | 625 menu->use_new_menu()); |
626 zoom_label_->set_background(center_bg); | 626 zoom_label_->set_background(center_bg); |
627 const MenuConfig& menu_config(menu->GetMenuConfig()); | 627 const MenuConfig& menu_config(menu->GetMenuConfig()); |
628 zoom_label_->set_border( | 628 zoom_label_->set_border( |
629 new MenuButtonBorder(menu_config, menu->use_new_menu())); | 629 new MenuButtonBorder(menu_config, menu->use_new_menu())); |
630 zoom_label_->SetFontList(gfx::FontList(menu_config.font)); | 630 zoom_label_->SetFontList(menu_config.font_list); |
631 | 631 |
632 AddChildView(zoom_label_); | 632 AddChildView(zoom_label_); |
633 zoom_label_width_ = MaxWidthForZoomLabel(); | 633 zoom_label_width_ = MaxWidthForZoomLabel(); |
634 | 634 |
635 increment_button_ = CreateButtonWithAccName( | 635 increment_button_ = CreateButtonWithAccName( |
636 IDS_ZOOM_PLUS2, MenuButtonBackground::RIGHT_BUTTON, increment_index, | 636 IDS_ZOOM_PLUS2, MenuButtonBackground::RIGHT_BUTTON, increment_index, |
637 NULL, IDS_ACCNAME_ZOOM_PLUS2); | 637 NULL, IDS_ACCNAME_ZOOM_PLUS2); |
638 | 638 |
639 center_bg->SetOtherButtons(decrement_button_, increment_button_); | 639 center_bg->SetOtherButtons(decrement_button_, increment_button_); |
640 | 640 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 // Return the specific menu width of recent tabs submenu if |menu| is the | 838 // Return the specific menu width of recent tabs submenu if |menu| is the |
839 // recent tabs submenu, else return -1. | 839 // recent tabs submenu, else return -1. |
840 int GetMaxWidthForMenu(views::MenuItemView* menu) { | 840 int GetMaxWidthForMenu(views::MenuItemView* menu) { |
841 if (!menu_item_->HasSubmenu()) | 841 if (!menu_item_->HasSubmenu()) |
842 return -1; | 842 return -1; |
843 const int kMaxMenuItemWidth = 320; | 843 const int kMaxMenuItemWidth = 320; |
844 return menu->GetCommand() == menu_item_->GetCommand() ? | 844 return menu->GetCommand() == menu_item_->GetCommand() ? |
845 kMaxMenuItemWidth : -1; | 845 kMaxMenuItemWidth : -1; |
846 } | 846 } |
847 | 847 |
848 const gfx::Font* GetLabelFontAt(int index) const { | 848 const gfx::FontList* GetLabelFontListAt(int index) const { |
849 return model_->GetLabelFontAt(index); | 849 return model_->GetLabelFontListAt(index); |
850 } | 850 } |
851 | 851 |
852 bool GetForegroundColorAt(int index, | 852 bool GetForegroundColorAt(int index, |
853 bool is_hovered, | 853 bool is_hovered, |
854 SkColor* override_color) const { | 854 SkColor* override_color) const { |
855 // The items for which we get a font, should be shown in black. | 855 // The items for which we get a font list, should be shown in black. |
856 if (GetLabelFontAt(index)) { | 856 if (GetLabelFontListAt(index)) { |
857 *override_color = SK_ColorBLACK; | 857 *override_color = SK_ColorBLACK; |
858 return true; | 858 return true; |
859 } | 859 } |
860 return false; | 860 return false; |
861 } | 861 } |
862 | 862 |
863 // ui::MenuModelDelegate implementation: | 863 // ui::MenuModelDelegate implementation: |
864 | 864 |
865 virtual void OnIconChanged(int index) OVERRIDE { | 865 virtual void OnIconChanged(int index) OVERRIDE { |
866 int command_id = model_->GetCommandIdAt(index); | 866 int command_id = model_->GetCommandIdAt(index); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 } | 989 } |
990 | 990 |
991 void WrenchMenu::AddObserver(WrenchMenuObserver* observer) { | 991 void WrenchMenu::AddObserver(WrenchMenuObserver* observer) { |
992 observer_list_.AddObserver(observer); | 992 observer_list_.AddObserver(observer); |
993 } | 993 } |
994 | 994 |
995 void WrenchMenu::RemoveObserver(WrenchMenuObserver* observer) { | 995 void WrenchMenu::RemoveObserver(WrenchMenuObserver* observer) { |
996 observer_list_.RemoveObserver(observer); | 996 observer_list_.RemoveObserver(observer); |
997 } | 997 } |
998 | 998 |
999 const gfx::Font* WrenchMenu::GetLabelFont(int command_id) const { | 999 const gfx::FontList* WrenchMenu::GetLabelFontList(int command_id) const { |
1000 if (IsRecentTabsCommand(command_id)) { | 1000 if (IsRecentTabsCommand(command_id)) { |
1001 return recent_tabs_menu_model_delegate_->GetLabelFontAt( | 1001 return recent_tabs_menu_model_delegate_->GetLabelFontListAt( |
1002 ModelIndexFromCommandId(command_id)); | 1002 ModelIndexFromCommandId(command_id)); |
1003 } | 1003 } |
1004 return NULL; | 1004 return NULL; |
1005 } | 1005 } |
1006 | 1006 |
1007 bool WrenchMenu::GetForegroundColor(int command_id, | 1007 bool WrenchMenu::GetForegroundColor(int command_id, |
1008 bool is_hovered, | 1008 bool is_hovered, |
1009 SkColor* override_color) const { | 1009 SkColor* override_color) const { |
1010 if (IsRecentTabsCommand(command_id)) { | 1010 if (IsRecentTabsCommand(command_id)) { |
1011 return recent_tabs_menu_model_delegate_->GetForegroundColorAt( | 1011 return recent_tabs_menu_model_delegate_->GetForegroundColorAt( |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 0, | 1361 0, |
1362 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1362 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1363 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1363 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
1364 } | 1364 } |
1365 | 1365 |
1366 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1366 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
1367 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1367 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1368 DCHECK(ix != command_id_to_entry_.end()); | 1368 DCHECK(ix != command_id_to_entry_.end()); |
1369 return ix->second.second; | 1369 return ix->second.second; |
1370 } | 1370 } |
OLD | NEW |