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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 return -1; | 841 return -1; |
842 const int kMaxMenuItemWidth = 320; | 842 const int kMaxMenuItemWidth = 320; |
843 return menu->GetCommand() == menu_item_->GetCommand() ? | 843 return menu->GetCommand() == menu_item_->GetCommand() ? |
844 kMaxMenuItemWidth : -1; | 844 kMaxMenuItemWidth : -1; |
845 } | 845 } |
846 | 846 |
847 const gfx::FontList* GetLabelFontListAt(int index) const { | 847 const gfx::FontList* GetLabelFontListAt(int index) const { |
848 return model_->GetLabelFontListAt(index); | 848 return model_->GetLabelFontListAt(index); |
849 } | 849 } |
850 | 850 |
851 bool GetForegroundColorAt(int index, | 851 bool GetShouldUseDisabledEmphasizedForegroundColor(int index) const { |
852 bool is_hovered, | 852 // The items for which we get a font list, should be shown in the bolded |
853 SkColor* override_color) const { | 853 // color. |
854 // The items for which we get a font list, should be shown in black. | 854 return GetLabelFontListAt(index) ? true : false; |
855 if (GetLabelFontListAt(index)) { | |
856 *override_color = SK_ColorBLACK; | |
857 return true; | |
858 } | |
859 return false; | |
860 } | 855 } |
861 | 856 |
862 // ui::MenuModelDelegate implementation: | 857 // ui::MenuModelDelegate implementation: |
863 | 858 |
864 virtual void OnIconChanged(int index) OVERRIDE { | 859 virtual void OnIconChanged(int index) OVERRIDE { |
865 int command_id = model_->GetCommandIdAt(index); | 860 int command_id = model_->GetCommandIdAt(index); |
866 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id); | 861 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id); |
867 DCHECK(item); | 862 DCHECK(item); |
868 gfx::Image icon; | 863 gfx::Image icon; |
869 model_->GetIconAt(index, &icon); | 864 model_->GetIconAt(index, &icon); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 } | 991 } |
997 | 992 |
998 const gfx::FontList* WrenchMenu::GetLabelFontList(int command_id) const { | 993 const gfx::FontList* WrenchMenu::GetLabelFontList(int command_id) const { |
999 if (IsRecentTabsCommand(command_id)) { | 994 if (IsRecentTabsCommand(command_id)) { |
1000 return recent_tabs_menu_model_delegate_->GetLabelFontListAt( | 995 return recent_tabs_menu_model_delegate_->GetLabelFontListAt( |
1001 ModelIndexFromCommandId(command_id)); | 996 ModelIndexFromCommandId(command_id)); |
1002 } | 997 } |
1003 return NULL; | 998 return NULL; |
1004 } | 999 } |
1005 | 1000 |
1006 bool WrenchMenu::GetForegroundColor(int command_id, | 1001 bool WrenchMenu::GetShouldUseDisabledEmphasizedForegroundColor( |
1007 bool is_hovered, | 1002 int command_id) const { |
1008 SkColor* override_color) const { | |
1009 if (IsRecentTabsCommand(command_id)) { | 1003 if (IsRecentTabsCommand(command_id)) { |
1010 return recent_tabs_menu_model_delegate_->GetForegroundColorAt( | 1004 return recent_tabs_menu_model_delegate_-> |
1011 ModelIndexFromCommandId(command_id), is_hovered, override_color); | 1005 GetShouldUseDisabledEmphasizedForegroundColor( |
| 1006 ModelIndexFromCommandId(command_id)); |
1012 } | 1007 } |
1013 return false; | 1008 return false; |
1014 } | 1009 } |
1015 | 1010 |
1016 base::string16 WrenchMenu::GetTooltipText(int command_id, | 1011 base::string16 WrenchMenu::GetTooltipText(int command_id, |
1017 const gfx::Point& p) const { | 1012 const gfx::Point& p) const { |
1018 return IsBookmarkCommand(command_id) ? | 1013 return IsBookmarkCommand(command_id) ? |
1019 bookmark_menu_delegate_->GetTooltipText(command_id, p) : base::string16(); | 1014 bookmark_menu_delegate_->GetTooltipText(command_id, p) : base::string16(); |
1020 } | 1015 } |
1021 | 1016 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 0, | 1356 0, |
1362 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1357 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1363 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1358 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
1364 } | 1359 } |
1365 | 1360 |
1366 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1361 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
1367 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1362 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1368 DCHECK(ix != command_id_to_entry_.end()); | 1363 DCHECK(ix != command_id_to_entry_.end()); |
1369 return ix->second.second; | 1364 return ix->second.second; |
1370 } | 1365 } |
OLD | NEW |