OLD | NEW |
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/ime_menu/ime_menu_tray.h" | 5 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" |
6 | 6 |
7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
8 #include "ash/common/ash_constants.h" | 8 #include "ash/common/ash_constants.h" |
9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0))); | 124 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0))); |
125 auto* box_layout = | 125 auto* box_layout = |
126 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 126 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
127 box_layout->set_minimum_cross_axis_size( | 127 box_layout->set_minimum_cross_axis_size( |
128 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); | 128 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); |
129 SetLayoutManager(box_layout); | 129 SetLayoutManager(box_layout); |
130 title_label_ = | 130 title_label_ = |
131 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME)); | 131 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME)); |
132 title_label_->SetBorder(views::CreateEmptyBorder( | 132 title_label_->SetBorder(views::CreateEmptyBorder( |
133 0, kMenuEdgeEffectivePadding, kTrayMenuBottomRowPadding, 0)); | 133 0, kMenuEdgeEffectivePadding, kTrayMenuBottomRowPadding, 0)); |
| 134 UpdateStyle(); |
134 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 135 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
135 AddChildView(title_label_); | 136 AddChildView(title_label_); |
136 box_layout->SetFlexForView(title_label_, 1); | 137 box_layout->SetFlexForView(title_label_, 1); |
137 | 138 |
138 if (show_settings_button) { | 139 if (show_settings_button) { |
139 settings_button_ = CreateImeMenuButton( | 140 settings_button_ = CreateImeMenuButton( |
140 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); | 141 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); |
141 if (IsInLoginOrLockScreen()) | 142 if (IsInLoginOrLockScreen()) |
142 settings_button_->SetEnabled(false); | 143 settings_button_->SetEnabled(false); |
143 AddChildView(settings_button_); | 144 AddChildView(settings_button_); |
144 } | 145 } |
145 } | 146 } |
146 | 147 |
| 148 void UpdateStyle() { |
| 149 if (!GetNativeTheme() || !title_label_) { |
| 150 return; |
| 151 } |
| 152 |
| 153 TrayPopupItemStyle style(GetNativeTheme(), |
| 154 TrayPopupItemStyle::FontStyle::TITLE); |
| 155 style.SetupLabel(title_label_); |
| 156 } |
| 157 |
147 // views::View: | 158 // views::View: |
148 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { | 159 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
149 TrayPopupItemStyle style(theme, TrayPopupItemStyle::FontStyle::TITLE); | 160 UpdateStyle(); |
150 style.SetupLabel(title_label_); | |
151 } | 161 } |
152 | 162 |
153 // views::ButtonListener: | 163 // views::ButtonListener: |
154 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 164 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
155 DCHECK_EQ(sender, settings_button_); | 165 DCHECK_EQ(sender, settings_button_); |
156 ShowIMESettings(); | 166 ShowIMESettings(); |
157 } | 167 } |
158 | 168 |
159 ~ImeTitleView() override {} | 169 ~ImeTitleView() override {} |
160 | 170 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 one_settings_button_view_->SetEnabled(false); | 256 one_settings_button_view_->SetEnabled(false); |
247 AddChildView(one_settings_button_view_); | 257 AddChildView(one_settings_button_view_); |
248 } | 258 } |
249 | 259 |
250 // Shows the UI of more than one buttons. | 260 // Shows the UI of more than one buttons. |
251 void ShowButtons(bool show_emoji_button, | 261 void ShowButtons(bool show_emoji_button, |
252 bool show_handwriting_button, | 262 bool show_handwriting_button, |
253 bool show_voice_button, | 263 bool show_voice_button, |
254 bool show_settings_button) { | 264 bool show_settings_button) { |
255 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 265 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
256 SetLayoutManager( | 266 auto* box_layout = |
257 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 267 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
| 268 box_layout->set_minimum_cross_axis_size( |
| 269 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); |
| 270 SetLayoutManager(box_layout); |
258 SetBorder(views::CreatePaddedBorder( | 271 SetBorder(views::CreatePaddedBorder( |
259 views::CreateSolidSidedBorder(kSeparatorWidth, 0, 0, 0, | 272 views::CreateSolidSidedBorder(kSeparatorWidth, 0, 0, 0, |
260 kHorizontalSeparatorColor), | 273 kHorizontalSeparatorColor), |
261 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, | 274 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, |
262 GetTrayConstant(TRAY_POPUP_ITEM_LEFT_INSET)))); | 275 GetTrayConstant(TRAY_POPUP_ITEM_LEFT_INSET)))); |
263 } else { | 276 } else { |
264 auto* box_layout = | 277 auto* box_layout = |
265 new views::BoxLayout(views::BoxLayout::kHorizontal, 4, 4, 0); | 278 new views::BoxLayout(views::BoxLayout::kHorizontal, 4, 4, 0); |
266 set_background( | 279 set_background( |
267 views::Background::CreateSolidBackground(kHeaderBackgroundColor)); | 280 views::Background::CreateSolidBackground(kHeaderBackgroundColor)); |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 650 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
638 | 651 |
639 // Updates the tray label based on the current input method. | 652 // Updates the tray label based on the current input method. |
640 if (current_ime_.third_party) | 653 if (current_ime_.third_party) |
641 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 654 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
642 else | 655 else |
643 label_->SetText(current_ime_.short_name); | 656 label_->SetText(current_ime_.short_name); |
644 } | 657 } |
645 | 658 |
646 } // namespace ash | 659 } // namespace ash |
OLD | NEW |