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

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

Issue 2502153002: Use correct fonts and add ripples to palette tray help/settings icon. (Closed)
Patch Set: Rebase Created 4 years 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
« no previous file with comments | « ash/common/system/chromeos/palette/common_palette_tool.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "ash/common/shelf/wm_shelf_util.h" 11 #include "ash/common/shelf/wm_shelf_util.h"
12 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" 12 #include "ash/common/system/chromeos/palette/palette_tool_manager.h"
13 #include "ash/common/system/chromeos/palette/palette_utils.h" 13 #include "ash/common/system/chromeos/palette/palette_utils.h"
14 #include "ash/common/system/tray/system_menu_button.h"
14 #include "ash/common/system/tray/system_tray_controller.h" 15 #include "ash/common/system/tray/system_tray_controller.h"
15 #include "ash/common/system/tray/system_tray_delegate.h" 16 #include "ash/common/system/tray/system_tray_delegate.h"
16 #include "ash/common/system/tray/tray_bubble_wrapper.h" 17 #include "ash/common/system/tray/tray_bubble_wrapper.h"
17 #include "ash/common/system/tray/tray_constants.h" 18 #include "ash/common/system/tray/tray_constants.h"
18 #include "ash/common/system/tray/tray_popup_header_button.h" 19 #include "ash/common/system/tray/tray_popup_header_button.h"
20 #include "ash/common/system/tray/tray_popup_item_style.h"
19 #include "ash/common/wm_lookup.h" 21 #include "ash/common/wm_lookup.h"
20 #include "ash/common/wm_root_window_controller.h" 22 #include "ash/common/wm_root_window_controller.h"
21 #include "ash/common/wm_shell.h" 23 #include "ash/common/wm_shell.h"
22 #include "ash/common/wm_window.h" 24 #include "ash/common/wm_window.h"
23 #include "ash/public/cpp/shell_window_ids.h" 25 #include "ash/public/cpp/shell_window_ids.h"
24 #include "ash/resources/vector_icons/vector_icons.h" 26 #include "ash/resources/vector_icons/vector_icons.h"
25 #include "base/metrics/histogram_macros.h" 27 #include "base/metrics/histogram_macros.h"
26 #include "grit/ash_resources.h" 28 #include "grit/ash_resources.h"
27 #include "grit/ash_strings.h" 29 #include "grit/ash_strings.h"
28 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 bool IsInUserSession() { 78 bool IsInUserSession() {
77 SessionStateDelegate* session_state_delegate = 79 SessionStateDelegate* session_state_delegate =
78 WmShell::Get()->GetSessionStateDelegate(); 80 WmShell::Get()->GetSessionStateDelegate();
79 return !session_state_delegate->IsUserSessionBlocked() && 81 return !session_state_delegate->IsUserSessionBlocked() &&
80 session_state_delegate->GetSessionState() == 82 session_state_delegate->GetSessionState() ==
81 session_manager::SessionState::ACTIVE && 83 session_manager::SessionState::ACTIVE &&
82 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != 84 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() !=
83 LoginStatus::KIOSK_APP; 85 LoginStatus::KIOSK_APP;
84 } 86 }
85 87
86 // Returns the font used by the title view.
87 const gfx::FontList& GetTitleFont() {
88 // TODO(tdanderson|jdufault): Use TrayPopupItemStyle instead.
89 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
90 2, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM);
91 }
92
93 class TitleView : public views::View, public views::ButtonListener { 88 class TitleView : public views::View, public views::ButtonListener {
94 public: 89 public:
95 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { 90 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) {
91 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title.
92 // See crbug.com/614453.
96 auto* box_layout = new views::BoxLayout( 93 auto* box_layout = new views::BoxLayout(
97 views::BoxLayout::kHorizontal, 0, kVerticalMarginAroundTitleView, 94 views::BoxLayout::kHorizontal, 0, kVerticalMarginAroundTitleView,
98 kHorizontalPaddingBetweenTitleEntries); 95 kHorizontalPaddingBetweenTitleEntries);
99 SetLayoutManager(box_layout); 96 SetLayoutManager(box_layout);
100 97
101 views::Label* text_label = 98 title_label_ =
102 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE)); 99 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE));
103 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 100 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
104 text_label->SetFontList(GetTitleFont()); 101 AddChildView(title_label_);
105 AddChildView(text_label); 102 box_layout->SetFlexForView(title_label_, 1);
106 box_layout->SetFlexForView(text_label, 1); 103 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
104 help_button_ =
105 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED,
106 kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP);
107 settings_button_ = new SystemMenuButton(
108 this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuSettingsIcon,
109 IDS_ASH_STATUS_TRAY_SETTINGS);
110 } else {
111 gfx::ImageSkia help_icon =
112 gfx::CreateVectorIcon(kSystemMenuHelpIcon, kMenuIconColor);
113 gfx::ImageSkia settings_icon =
114 gfx::CreateVectorIcon(kSystemMenuSettingsIcon, kMenuIconColor);
107 115
108 gfx::ImageSkia settings_icon = 116 auto* help_button = new ash::TrayPopupHeaderButton(
109 gfx::CreateVectorIcon(kSystemMenuSettingsIcon, kMenuIconColor); 117 this, help_icon, IDS_ASH_STATUS_TRAY_HELP);
110 gfx::ImageSkia help_icon = 118 help_button->SetTooltipText(
111 gfx::CreateVectorIcon(kSystemMenuHelpIcon, kMenuIconColor); 119 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HELP));
120 help_button_ = help_button;
112 121
113 help_button_ = new ash::TrayPopupHeaderButton(this, help_icon, 122 auto* settings_button = new ash::TrayPopupHeaderButton(
114 IDS_ASH_STATUS_TRAY_HELP); 123 this, settings_icon, IDS_ASH_STATUS_TRAY_SETTINGS);
115 help_button_->SetTooltipText( 124 settings_button->SetTooltipText(
116 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HELP)); 125 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SETTINGS));
126 settings_button_ = settings_button;
127 }
128
117 AddChildView(help_button_); 129 AddChildView(help_button_);
118
119 settings_button_ = new ash::TrayPopupHeaderButton(
120 this, settings_icon, IDS_ASH_STATUS_TRAY_SETTINGS);
121 settings_button_->SetTooltipText(
122 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SETTINGS));
123 AddChildView(settings_button_); 130 AddChildView(settings_button_);
124 } 131 }
125 132
126 ~TitleView() override {} 133 ~TitleView() override {}
127 134
128 private: 135 private:
136 // views::View:
137 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
138 UpdateStyle();
139 }
140
129 // views::ButtonListener: 141 // views::ButtonListener:
130 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 142 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
131 if (sender == settings_button_) { 143 if (sender == settings_button_) {
132 palette_tray_->RecordPaletteOptionsUsage( 144 palette_tray_->RecordPaletteOptionsUsage(
133 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON); 145 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON);
134 WmShell::Get()->system_tray_controller()->ShowPaletteSettings(); 146 WmShell::Get()->system_tray_controller()->ShowPaletteSettings();
135 palette_tray_->HidePalette(); 147 palette_tray_->HidePalette();
136 } else if (sender == help_button_) { 148 } else if (sender == help_button_) {
137 palette_tray_->RecordPaletteOptionsUsage( 149 palette_tray_->RecordPaletteOptionsUsage(
138 PaletteTrayOptions::PALETTE_HELP_BUTTON); 150 PaletteTrayOptions::PALETTE_HELP_BUTTON);
139 WmShell::Get()->system_tray_controller()->ShowPaletteHelp(); 151 WmShell::Get()->system_tray_controller()->ShowPaletteHelp();
140 palette_tray_->HidePalette(); 152 palette_tray_->HidePalette();
141 } else { 153 } else {
142 NOTREACHED(); 154 NOTREACHED();
143 } 155 }
144 } 156 }
145 157
158 void UpdateStyle() {
159 TrayPopupItemStyle style(GetNativeTheme(),
160 TrayPopupItemStyle::FontStyle::TITLE);
161 style.SetupLabel(title_label_);
162 }
163
146 // Unowned pointers to button views so we can determine which button was 164 // Unowned pointers to button views so we can determine which button was
147 // clicked. 165 // clicked.
148 ash::TrayPopupHeaderButton* settings_button_; 166 views::View* settings_button_;
149 ash::TrayPopupHeaderButton* help_button_; 167 views::View* help_button_;
168 // Needed for UpdateStyles()
169 views::Label* title_label_;
150 PaletteTray* palette_tray_; 170 PaletteTray* palette_tray_;
151 171
152 DISALLOW_COPY_AND_ASSIGN(TitleView); 172 DISALLOW_COPY_AND_ASSIGN(TitleView);
153 }; 173 };
154 174
155 } // namespace 175 } // namespace
156 176
157 PaletteTray::PaletteTray(WmShelf* wm_shelf) 177 PaletteTray::PaletteTray(WmShelf* wm_shelf)
158 : TrayBackgroundView(wm_shelf), 178 : TrayBackgroundView(wm_shelf),
159 palette_tool_manager_(new PaletteToolManager(this)), 179 palette_tool_manager_(new PaletteToolManager(this)),
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } else { 462 } else {
443 UpdateIconVisibility(); 463 UpdateIconVisibility();
444 } 464 }
445 } 465 }
446 466
447 void PaletteTray::UpdateIconVisibility() { 467 void PaletteTray::UpdateIconVisibility() {
448 SetVisible(IsInUserSession()); 468 SetVisible(IsInUserSession());
449 } 469 }
450 470
451 } // namespace ash 471 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/palette/common_palette_tool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698