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

Side by Side Diff: ash/common/system/chromeos/palette/palette_tray.cc

Issue 2661023006: Remove unused references to NativeTheme in TrayPopupItemStyle. (Closed)
Patch Set: slight improvement Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ash/common/system/chromeos/palette/palette_tray.h" 5 #include "ash/common/system/chromeos/palette/palette_tray.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/shelf_constants.h" 9 #include "ash/common/shelf/shelf_constants.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 class TitleView : public views::View, public views::ButtonListener { 78 class TitleView : public views::View, public views::ButtonListener {
79 public: 79 public:
80 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { 80 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) {
81 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title. 81 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title.
82 // See crbug.com/614453. 82 // See crbug.com/614453.
83 auto* box_layout = 83 auto* box_layout =
84 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 84 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
85 SetLayoutManager(box_layout); 85 SetLayoutManager(box_layout);
86 86
87 title_label_ = 87 auto title_label =
88 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE)); 88 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE));
89 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 89 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
90 AddChildView(title_label_); 90 AddChildView(title_label);
91 box_layout->SetFlexForView(title_label_, 1); 91 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE);
92 style.SetupLabel(title_label);
93 box_layout->SetFlexForView(title_label, 1);
92 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 94 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
93 help_button_ = 95 help_button_ =
94 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, 96 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED,
95 kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP); 97 kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP);
96 settings_button_ = new SystemMenuButton( 98 settings_button_ = new SystemMenuButton(
97 this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuSettingsIcon, 99 this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuSettingsIcon,
98 IDS_ASH_STATUS_TRAY_SETTINGS); 100 IDS_ASH_STATUS_TRAY_SETTINGS);
99 } else { 101 } else {
100 gfx::ImageSkia help_icon = 102 gfx::ImageSkia help_icon =
101 gfx::CreateVectorIcon(kSystemMenuHelpIcon, kMenuIconColor); 103 gfx::CreateVectorIcon(kSystemMenuHelpIcon, kMenuIconColor);
(...skipping 13 matching lines...) Expand all
115 settings_button_ = settings_button; 117 settings_button_ = settings_button;
116 } 118 }
117 119
118 AddChildView(help_button_); 120 AddChildView(help_button_);
119 AddChildView(settings_button_); 121 AddChildView(settings_button_);
120 } 122 }
121 123
122 ~TitleView() override {} 124 ~TitleView() override {}
123 125
124 private: 126 private:
125 // views::View:
126 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
127 UpdateStyle();
128 }
129
130 // views::ButtonListener: 127 // views::ButtonListener:
131 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 128 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
132 if (sender == settings_button_) { 129 if (sender == settings_button_) {
133 palette_tray_->RecordPaletteOptionsUsage( 130 palette_tray_->RecordPaletteOptionsUsage(
134 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON); 131 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON);
135 WmShell::Get()->system_tray_controller()->ShowPaletteSettings(); 132 WmShell::Get()->system_tray_controller()->ShowPaletteSettings();
136 palette_tray_->HidePalette(); 133 palette_tray_->HidePalette();
137 } else if (sender == help_button_) { 134 } else if (sender == help_button_) {
138 palette_tray_->RecordPaletteOptionsUsage( 135 palette_tray_->RecordPaletteOptionsUsage(
139 PaletteTrayOptions::PALETTE_HELP_BUTTON); 136 PaletteTrayOptions::PALETTE_HELP_BUTTON);
140 WmShell::Get()->system_tray_controller()->ShowPaletteHelp(); 137 WmShell::Get()->system_tray_controller()->ShowPaletteHelp();
141 palette_tray_->HidePalette(); 138 palette_tray_->HidePalette();
142 } else { 139 } else {
143 NOTREACHED(); 140 NOTREACHED();
144 } 141 }
145 } 142 }
146 143
147 void UpdateStyle() {
148 TrayPopupItemStyle style(GetNativeTheme(),
149 TrayPopupItemStyle::FontStyle::TITLE);
150 style.SetupLabel(title_label_);
151 }
152
153 // Unowned pointers to button views so we can determine which button was 144 // Unowned pointers to button views so we can determine which button was
154 // clicked. 145 // clicked.
155 views::View* settings_button_; 146 views::View* settings_button_;
156 views::View* help_button_; 147 views::View* help_button_;
157 // Needed for UpdateStyles()
158 views::Label* title_label_;
159 PaletteTray* palette_tray_; 148 PaletteTray* palette_tray_;
160 149
161 DISALLOW_COPY_AND_ASSIGN(TitleView); 150 DISALLOW_COPY_AND_ASSIGN(TitleView);
162 }; 151 };
163 152
164 } // namespace 153 } // namespace
165 154
166 PaletteTray::PaletteTray(WmShelf* wm_shelf) 155 PaletteTray::PaletteTray(WmShelf* wm_shelf)
167 : TrayBackgroundView(wm_shelf), 156 : TrayBackgroundView(wm_shelf),
168 palette_tool_manager_(new PaletteToolManager(this)), 157 palette_tool_manager_(new PaletteToolManager(this)),
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } else { 444 } else {
456 UpdateIconVisibility(); 445 UpdateIconVisibility();
457 } 446 }
458 } 447 }
459 448
460 void PaletteTray::UpdateIconVisibility() { 449 void PaletteTray::UpdateIconVisibility() {
461 SetVisible(is_palette_enabled_ && IsInUserSession()); 450 SetVisible(is_palette_enabled_ && IsInUserSession());
462 } 451 }
463 452
464 } // namespace ash 453 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/network/vpn_list_view.cc ('k') | ash/common/system/chromeos/power/power_status_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698