| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 explicit ImeTitleView(bool show_settings_button) : settings_button_(nullptr) { | 143 explicit ImeTitleView(bool show_settings_button) : settings_button_(nullptr) { |
| 144 SetBorder(views::CreatePaddedBorder( | 144 SetBorder(views::CreatePaddedBorder( |
| 145 views::CreateSolidSidedBorder(0, 0, kSeparatorWidth, 0, | 145 views::CreateSolidSidedBorder(0, 0, kSeparatorWidth, 0, |
| 146 kHorizontalSeparatorColor), | 146 kHorizontalSeparatorColor), |
| 147 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0))); | 147 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0))); |
| 148 auto* box_layout = | 148 auto* box_layout = |
| 149 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 149 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
| 150 box_layout->set_minimum_cross_axis_size( | 150 box_layout->set_minimum_cross_axis_size( |
| 151 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); | 151 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); |
| 152 SetLayoutManager(box_layout); | 152 SetLayoutManager(box_layout); |
| 153 title_label_ = | 153 auto title_label = |
| 154 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME)); | 154 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME)); |
| 155 title_label_->SetBorder(views::CreateEmptyBorder( | 155 title_label->SetBorder(views::CreateEmptyBorder( |
| 156 0, kMenuEdgeEffectivePadding, kTrayMenuBottomRowPadding, 0)); | 156 0, kMenuEdgeEffectivePadding, kTrayMenuBottomRowPadding, 0)); |
| 157 UpdateStyle(); | 157 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 158 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 158 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE); |
| 159 AddChildView(title_label_); | 159 style.SetupLabel(title_label); |
| 160 box_layout->SetFlexForView(title_label_, 1); | 160 |
| 161 AddChildView(title_label); |
| 162 box_layout->SetFlexForView(title_label, 1); |
| 161 | 163 |
| 162 if (show_settings_button) { | 164 if (show_settings_button) { |
| 163 settings_button_ = CreateImeMenuButton( | 165 settings_button_ = CreateImeMenuButton( |
| 164 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); | 166 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); |
| 165 if (IsInLoginOrLockScreen()) | 167 if (IsInLoginOrLockScreen()) |
| 166 settings_button_->SetEnabled(false); | 168 settings_button_->SetEnabled(false); |
| 167 AddChildView(settings_button_); | 169 AddChildView(settings_button_); |
| 168 } | 170 } |
| 169 } | 171 } |
| 170 | 172 |
| 171 void UpdateStyle() { | |
| 172 if (!GetNativeTheme() || !title_label_) { | |
| 173 return; | |
| 174 } | |
| 175 | |
| 176 TrayPopupItemStyle style(GetNativeTheme(), | |
| 177 TrayPopupItemStyle::FontStyle::TITLE); | |
| 178 style.SetupLabel(title_label_); | |
| 179 } | |
| 180 | |
| 181 // views::View: | |
| 182 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { | |
| 183 UpdateStyle(); | |
| 184 } | |
| 185 | |
| 186 // views::ButtonListener: | 173 // views::ButtonListener: |
| 187 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 174 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 188 DCHECK_EQ(sender, settings_button_); | 175 DCHECK_EQ(sender, settings_button_); |
| 189 ShowIMESettings(); | 176 ShowIMESettings(); |
| 190 } | 177 } |
| 191 | 178 |
| 192 ~ImeTitleView() override {} | 179 ~ImeTitleView() override {} |
| 193 | 180 |
| 194 private: | 181 private: |
| 195 views::Label* title_label_; | |
| 196 | |
| 197 // Settings button that is only used in material design, and only if the | 182 // Settings button that is only used in material design, and only if the |
| 198 // emoji, handwriting and voice buttons are not available. | 183 // emoji, handwriting and voice buttons are not available. |
| 199 SystemMenuButton* settings_button_; | 184 SystemMenuButton* settings_button_; |
| 200 | 185 |
| 201 DISALLOW_COPY_AND_ASSIGN(ImeTitleView); | 186 DISALLOW_COPY_AND_ASSIGN(ImeTitleView); |
| 202 }; | 187 }; |
| 203 | 188 |
| 204 // The view that contains buttons shown on the bottom of IME menu. | 189 // The view that contains buttons shown on the bottom of IME menu. |
| 205 class ImeButtonsView : public views::View, | 190 class ImeButtonsView : public views::View, |
| 206 public views::ButtonListener, | 191 public views::ButtonListener, |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 662 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
| 678 | 663 |
| 679 // Updates the tray label based on the current input method. | 664 // Updates the tray label based on the current input method. |
| 680 if (current_ime_.third_party) | 665 if (current_ime_.third_party) |
| 681 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 666 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
| 682 else | 667 else |
| 683 label_->SetText(current_ime_.short_name); | 668 label_->SetText(current_ime_.short_name); |
| 684 } | 669 } |
| 685 | 670 |
| 686 } // namespace ash | 671 } // namespace ash |
| OLD | NEW |