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

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: Address comments Created 4 years, 1 month 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/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/shelf/shelf_constants.h" 9 #include "ash/common/shelf/shelf_constants.h"
9 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/shelf/wm_shelf_util.h" 11 #include "ash/common/shelf/wm_shelf_util.h"
11 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" 12 #include "ash/common/system/chromeos/palette/palette_tool_manager.h"
12 #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"
13 #include "ash/common/system/tray/system_tray_controller.h" 15 #include "ash/common/system/tray/system_tray_controller.h"
14 #include "ash/common/system/tray/system_tray_delegate.h" 16 #include "ash/common/system/tray/system_tray_delegate.h"
15 #include "ash/common/system/tray/tray_bubble_wrapper.h" 17 #include "ash/common/system/tray/tray_bubble_wrapper.h"
16 #include "ash/common/system/tray/tray_constants.h" 18 #include "ash/common/system/tray/tray_constants.h"
17 #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"
18 #include "ash/common/wm_lookup.h" 21 #include "ash/common/wm_lookup.h"
19 #include "ash/common/wm_root_window_controller.h" 22 #include "ash/common/wm_root_window_controller.h"
20 #include "ash/common/wm_shell.h" 23 #include "ash/common/wm_shell.h"
21 #include "ash/common/wm_window.h" 24 #include "ash/common/wm_window.h"
22 #include "ash/public/cpp/shell_window_ids.h" 25 #include "ash/public/cpp/shell_window_ids.h"
23 #include "ash/resources/vector_icons/vector_icons.h" 26 #include "ash/resources/vector_icons/vector_icons.h"
24 #include "base/metrics/histogram_macros.h" 27 #include "base/metrics/histogram_macros.h"
25 #include "grit/ash_resources.h" 28 #include "grit/ash_resources.h"
26 #include "grit/ash_strings.h" 29 #include "grit/ash_strings.h"
27 #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
75 bool IsInUserSession() { 78 bool IsInUserSession() {
76 SessionStateDelegate* session_state_delegate = 79 SessionStateDelegate* session_state_delegate =
77 WmShell::Get()->GetSessionStateDelegate(); 80 WmShell::Get()->GetSessionStateDelegate();
78 return !session_state_delegate->IsUserSessionBlocked() && 81 return !session_state_delegate->IsUserSessionBlocked() &&
79 session_state_delegate->GetSessionState() == 82 session_state_delegate->GetSessionState() ==
80 session_manager::SessionState::ACTIVE && 83 session_manager::SessionState::ACTIVE &&
81 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != 84 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() !=
82 LoginStatus::KIOSK_APP; 85 LoginStatus::KIOSK_APP;
83 } 86 }
84 87
85 // Returns the font used by the title view.
86 const gfx::FontList& GetTitleFont() {
87 // TODO(tdanderson|jdufault): Use TrayPopupItemStyle instead.
88 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
89 2, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM);
90 }
91
92 class TitleView : public views::View, public views::ButtonListener { 88 class TitleView : public views::View, public views::ButtonListener {
93 public: 89 public:
94 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.
95 auto* box_layout = new views::BoxLayout( 93 auto* box_layout = new views::BoxLayout(
96 views::BoxLayout::kHorizontal, 0, kVerticalMarginAroundTitleView, 94 views::BoxLayout::kHorizontal, 0, kVerticalMarginAroundTitleView,
97 kHorizontalPaddingBetweenTitleEntries); 95 kHorizontalPaddingBetweenTitleEntries);
98 SetLayoutManager(box_layout); 96 SetLayoutManager(box_layout);
99 97
100 views::Label* text_label = 98 title_label_ =
101 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE)); 99 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE));
102 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 100 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
103 text_label->SetFontList(GetTitleFont()); 101 AddChildView(title_label_);
104 AddChildView(text_label); 102 box_layout->SetFlexForView(title_label_, 1);
105 box_layout->SetFlexForView(text_label, 1); 103 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
104 help_button_ =
105 new SystemMenuButton(this, SystemMenuButton::InkDropStyle::SQUARE,
106 kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP);
107 settings_button_ = new SystemMenuButton(
108 this, SystemMenuButton::InkDropStyle::SQUARE, kSystemMenuSettingsIcon,
109 IDS_ASH_STATUS_TRAY_SETTINGS);
tdanderson 2016/11/23 02:12:26 Note that Evan's CL https://chromiumcodereview.app
110 } else {
111 gfx::ImageSkia help_icon =
112 gfx::CreateVectorIcon(kSystemMenuHelpIcon, kMenuIconColor);
113 gfx::ImageSkia settings_icon =
114 gfx::CreateVectorIcon(kSystemMenuSettingsIcon, kMenuIconColor);
106 115
107 gfx::ImageSkia settings_icon = 116 auto* help_button = new ash::TrayPopupHeaderButton(
108 gfx::CreateVectorIcon(kSystemMenuSettingsIcon, kMenuIconColor); 117 this, help_icon, IDS_ASH_STATUS_TRAY_HELP);
109 gfx::ImageSkia help_icon = 118 help_button->SetTooltipText(
110 gfx::CreateVectorIcon(kSystemMenuHelpIcon, kMenuIconColor); 119 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HELP));
120 help_button_ = help_button;
111 121
112 help_button_ = new ash::TrayPopupHeaderButton(this, help_icon, 122 auto* settings_button = new ash::TrayPopupHeaderButton(
113 IDS_ASH_STATUS_TRAY_HELP); 123 this, settings_icon, IDS_ASH_STATUS_TRAY_SETTINGS);
114 help_button_->SetTooltipText( 124 settings_button->SetTooltipText(
115 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HELP)); 125 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SETTINGS));
126 settings_button_ = settings_button;
127 }
128
116 AddChildView(help_button_); 129 AddChildView(help_button_);
117
118 settings_button_ = new ash::TrayPopupHeaderButton(
119 this, settings_icon, IDS_ASH_STATUS_TRAY_SETTINGS);
120 settings_button_->SetTooltipText(
121 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SETTINGS));
122 AddChildView(settings_button_); 130 AddChildView(settings_button_);
123 } 131 }
124 132
125 ~TitleView() override {} 133 ~TitleView() override {}
126 134
127 private: 135 private:
136 // views::View:
137 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
138 UpdateStyle();
139 }
140
128 // views::ButtonListener: 141 // views::ButtonListener:
129 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 142 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
130 if (sender == settings_button_) { 143 if (sender == settings_button_) {
131 palette_tray_->RecordPaletteOptionsUsage( 144 palette_tray_->RecordPaletteOptionsUsage(
132 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON); 145 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON);
133 WmShell::Get()->system_tray_controller()->ShowPaletteSettings(); 146 WmShell::Get()->system_tray_controller()->ShowPaletteSettings();
134 palette_tray_->HidePalette(); 147 palette_tray_->HidePalette();
135 } else if (sender == help_button_) { 148 } else if (sender == help_button_) {
136 palette_tray_->RecordPaletteOptionsUsage( 149 palette_tray_->RecordPaletteOptionsUsage(
137 PaletteTrayOptions::PALETTE_HELP_BUTTON); 150 PaletteTrayOptions::PALETTE_HELP_BUTTON);
138 WmShell::Get()->system_tray_controller()->ShowPaletteHelp(); 151 WmShell::Get()->system_tray_controller()->ShowPaletteHelp();
139 palette_tray_->HidePalette(); 152 palette_tray_->HidePalette();
140 } else { 153 } else {
141 NOTREACHED(); 154 NOTREACHED();
142 } 155 }
143 } 156 }
144 157
158 void UpdateStyle() {
159 TrayPopupItemStyle style(GetNativeTheme(),
160 TrayPopupItemStyle::FontStyle::TITLE);
161 style.SetupLabel(title_label_);
162 }
163
145 // 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
146 // clicked. 165 // clicked.
147 ash::TrayPopupHeaderButton* settings_button_; 166 views::View* settings_button_;
148 ash::TrayPopupHeaderButton* help_button_; 167 views::View* help_button_;
168 // Needed for UpdateStyles()
169 views::Label* title_label_;
149 PaletteTray* palette_tray_; 170 PaletteTray* palette_tray_;
150 171
151 DISALLOW_COPY_AND_ASSIGN(TitleView); 172 DISALLOW_COPY_AND_ASSIGN(TitleView);
152 }; 173 };
153 174
154 } // namespace 175 } // namespace
155 176
156 PaletteTray::PaletteTray(WmShelf* wm_shelf) 177 PaletteTray::PaletteTray(WmShelf* wm_shelf)
157 : TrayBackgroundView(wm_shelf), 178 : TrayBackgroundView(wm_shelf),
158 palette_tool_manager_(new PaletteToolManager(this)), 179 palette_tool_manager_(new PaletteToolManager(this)),
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } else { 484 } else {
464 UpdateIconVisibility(); 485 UpdateIconVisibility();
465 } 486 }
466 } 487 }
467 488
468 void PaletteTray::UpdateIconVisibility() { 489 void PaletteTray::UpdateIconVisibility() {
469 SetVisible(IsInUserSession()); 490 SetVisible(IsInUserSession());
470 } 491 }
471 492
472 } // namespace ash 493 } // 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