Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu.cc

Issue 2382443007: Clean up NativeTheme (particularly CommonTheme). (Closed)
Patch Set: share color constant Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/app_menu.h" 5 #include "chrome/browser/ui/views/toolbar/app_menu.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 default: 187 default:
188 return theme->GetSystemColor( 188 return theme->GetSystemColor(
189 ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor); 189 ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor);
190 } 190 }
191 } 191 }
192 192
193 static SkColor BackgroundColor(const View* view, 193 static SkColor BackgroundColor(const View* view,
194 views::Button::ButtonState state) { 194 views::Button::ButtonState state) {
195 const ui::NativeTheme* theme = view->GetNativeTheme(); 195 const ui::NativeTheme* theme = view->GetNativeTheme();
196 switch (state) { 196 switch (state) {
197 case views::Button::STATE_PRESSED:
198 return theme->GetSystemColor(
199 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor);
197 case views::Button::STATE_HOVERED: 200 case views::Button::STATE_HOVERED:
198 // Hovered should be handled in DrawBackground. 201 // Hovered should be handled in DrawBackground.
199 NOTREACHED(); 202 NOTREACHED();
200 return theme->GetSystemColor(
201 ui::NativeTheme::kColorId_HoverMenuItemBackgroundColor);
202 case views::Button::STATE_PRESSED:
203 return theme->GetSystemColor(
204 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor);
205 default: 203 default:
206 return theme->GetSystemColor( 204 return theme->GetSystemColor(
207 ui::NativeTheme::kColorId_MenuBackgroundColor); 205 ui::NativeTheme::kColorId_MenuBackgroundColor);
208 } 206 }
209 } 207 }
210 208
211 void DrawBackground(gfx::Canvas* canvas, 209 void DrawBackground(gfx::Canvas* canvas,
212 const views::View* view, 210 const views::View* view,
213 const gfx::Rect& bounds, 211 const gfx::Rect& bounds,
214 views::Button::ButtonState state) const { 212 views::Button::ButtonState state) const {
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 } 722 }
725 723
726 ~RecentTabsMenuModelDelegate() override { 724 ~RecentTabsMenuModelDelegate() override {
727 model_->SetMenuModelDelegate(NULL); 725 model_->SetMenuModelDelegate(NULL);
728 } 726 }
729 727
730 const gfx::FontList* GetLabelFontListAt(int index) const { 728 const gfx::FontList* GetLabelFontListAt(int index) const {
731 return model_->GetLabelFontListAt(index); 729 return model_->GetLabelFontListAt(index);
732 } 730 }
733 731
734 bool GetShouldUseDisabledEmphasizedForegroundColor(int index) const {
735 // The items for which we get a font list, should be shown in the bolded
736 // color.
737 return GetLabelFontListAt(index) ? true : false;
738 }
739
740 // ui::MenuModelDelegate implementation: 732 // ui::MenuModelDelegate implementation:
741 733
742 void OnIconChanged(int index) override { 734 void OnIconChanged(int index) override {
743 int command_id = model_->GetCommandIdAt(index); 735 int command_id = model_->GetCommandIdAt(index);
744 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id); 736 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id);
745 DCHECK(item); 737 DCHECK(item);
746 gfx::Image icon; 738 gfx::Image icon;
747 model_->GetIconAt(index, &icon); 739 model_->GetIconAt(index, &icon);
748 item->SetIcon(*icon.ToImageSkia()); 740 item->SetIcon(*icon.ToImageSkia());
749 } 741 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 } 847 }
856 848
857 const gfx::FontList* AppMenu::GetLabelFontList(int command_id) const { 849 const gfx::FontList* AppMenu::GetLabelFontList(int command_id) const {
858 if (IsRecentTabsCommand(command_id)) { 850 if (IsRecentTabsCommand(command_id)) {
859 return recent_tabs_menu_model_delegate_->GetLabelFontListAt( 851 return recent_tabs_menu_model_delegate_->GetLabelFontListAt(
860 ModelIndexFromCommandId(command_id)); 852 ModelIndexFromCommandId(command_id));
861 } 853 }
862 return NULL; 854 return NULL;
863 } 855 }
864 856
865 bool AppMenu::GetShouldUseDisabledEmphasizedForegroundColor( 857 bool AppMenu::GetShouldUseNormalForegroundColor(int command_id) const {
866 int command_id) const { 858 return IsRecentTabsCommand(command_id);
867 if (IsRecentTabsCommand(command_id)) {
868 return recent_tabs_menu_model_delegate_->
869 GetShouldUseDisabledEmphasizedForegroundColor(
870 ModelIndexFromCommandId(command_id));
871 }
872 return false;
873 } 859 }
874 860
875 base::string16 AppMenu::GetTooltipText(int command_id, 861 base::string16 AppMenu::GetTooltipText(int command_id,
876 const gfx::Point& p) const { 862 const gfx::Point& p) const {
877 return IsBookmarkCommand(command_id) ? 863 return IsBookmarkCommand(command_id) ?
878 bookmark_menu_delegate_->GetTooltipText(command_id, p) : base::string16(); 864 bookmark_menu_delegate_->GetTooltipText(command_id, p) : base::string16();
879 } 865 }
880 866
881 bool AppMenu::IsTriggerableEvent(views::MenuItemView* menu, 867 bool AppMenu::IsTriggerableEvent(views::MenuItemView* menu,
882 const ui::Event& e) { 868 const ui::Event& e) {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 0, 1232 0,
1247 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1233 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1248 BOOKMARK_LAUNCH_LOCATION_APP_MENU); 1234 BOOKMARK_LAUNCH_LOCATION_APP_MENU);
1249 } 1235 }
1250 1236
1251 int AppMenu::ModelIndexFromCommandId(int command_id) const { 1237 int AppMenu::ModelIndexFromCommandId(int command_id) const {
1252 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1238 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1253 DCHECK(ix != command_id_to_entry_.end()); 1239 DCHECK(ix != command_id_to_entry_.end());
1254 return ix->second.second; 1240 return ix->second.second;
1255 } 1241 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/app_menu.h ('k') | chrome/browser/ui/views/toolbar/toolbar_action_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698