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

Side by Side Diff: ash/common/system/chromeos/ime_menu/ime_menu_tray.cc

Issue 2480813003: Reduce views::Border creation verbosity by promoting factory functions (Closed)
Patch Set: fix bad merge 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
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/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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 }; 83 };
84 84
85 SystemMenuButton* CreateImeMenuButton(views::ButtonListener* listener, 85 SystemMenuButton* CreateImeMenuButton(views::ButtonListener* listener,
86 const gfx::VectorIcon& icon, 86 const gfx::VectorIcon& icon,
87 int accessible_name_id, 87 int accessible_name_id,
88 int right_border) { 88 int right_border) {
89 SystemMenuButton* button = 89 SystemMenuButton* button =
90 new SystemMenuButton(listener, SystemMenuButton::InkDropStyle::SQUARE, 90 new SystemMenuButton(listener, SystemMenuButton::InkDropStyle::SQUARE,
91 icon, accessible_name_id); 91 icon, accessible_name_id);
92 if (!MaterialDesignController::IsShelfMaterial()) { 92 if (!MaterialDesignController::IsShelfMaterial()) {
93 button->SetBorder(views::Border::CreateSolidSidedBorder( 93 button->SetBorder(
94 0, 0, 0, right_border, kBorderDarkColor)); 94 views::CreateSolidSidedBorder(0, 0, 0, right_border, kBorderDarkColor));
95 } 95 }
96 return button; 96 return button;
97 } 97 }
98 98
99 // The view that contains IME menu title in the material design. 99 // The view that contains IME menu title in the material design.
100 class ImeTitleView : public views::View { 100 class ImeTitleView : public views::View {
101 public: 101 public:
102 ImeTitleView() { 102 ImeTitleView() {
103 auto* box_layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 103 auto* box_layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0,
104 kMenuSeparatorVerticalPadding, 0); 104 kMenuSeparatorVerticalPadding, 0);
105 SetLayoutManager(box_layout); 105 SetLayoutManager(box_layout);
106 106
107 views::Label* title_label = 107 views::Label* title_label =
108 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME)); 108 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME));
109 const int title_padding = 109 const int title_padding =
110 kMenuSeparatorVerticalPadding + (kMenuButtonSize - kMenuIconSize) / 2; 110 kMenuSeparatorVerticalPadding + (kMenuButtonSize - kMenuIconSize) / 2;
111 title_label->SetBorder( 111 title_label->SetBorder(views::CreateEmptyBorder(0, title_padding, 0, 0));
112 views::Border::CreateEmptyBorder(0, title_padding, 0, 0));
113 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 112 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
114 TrayPopupItemStyle style(GetNativeTheme(), 113 TrayPopupItemStyle style(GetNativeTheme(),
115 TrayPopupItemStyle::FontStyle::TITLE); 114 TrayPopupItemStyle::FontStyle::TITLE);
116 style.SetupLabel(title_label); 115 style.SetupLabel(title_label);
117 AddChildView(title_label); 116 AddChildView(title_label);
118 box_layout->SetFlexForView(title_label, 1); 117 box_layout->SetFlexForView(title_label, 1);
119 } 118 }
120 119
121 ~ImeTitleView() override {} 120 ~ImeTitleView() override {}
122 121
(...skipping 16 matching lines...) Expand all
139 public ViewClickListener { 138 public ViewClickListener {
140 public: 139 public:
141 ImeButtonsView(ImeMenuTray* ime_menu_tray, 140 ImeButtonsView(ImeMenuTray* ime_menu_tray,
142 bool show_emoji_button, 141 bool show_emoji_button,
143 bool show_voice_button, 142 bool show_voice_button,
144 bool show_handwriting_button, 143 bool show_handwriting_button,
145 bool show_settings_button) 144 bool show_settings_button)
146 : ime_menu_tray_(ime_menu_tray) { 145 : ime_menu_tray_(ime_menu_tray) {
147 DCHECK(ime_menu_tray_); 146 DCHECK(ime_menu_tray_);
148 147
149 SetBorder( 148 SetBorder(views::CreateSolidSidedBorder(1, 0, 0, 0, kBorderDarkColor));
150 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kBorderDarkColor));
151 149
152 // If there's only one settings button, the bottom should be a label with 150 // If there's only one settings button, the bottom should be a label with
153 // normal background. Otherwise, show button icons with header background. 151 // normal background. Otherwise, show button icons with header background.
154 if (show_settings_button && !show_emoji_button && 152 if (show_settings_button && !show_emoji_button &&
155 !show_handwriting_button && !show_voice_button) { 153 !show_handwriting_button && !show_voice_button) {
156 ShowOneSettingButton(); 154 ShowOneSettingButton();
157 } else { 155 } else {
158 ShowButtons(show_emoji_button, show_handwriting_button, show_voice_button, 156 ShowButtons(show_emoji_button, show_handwriting_button, show_voice_button,
159 show_settings_button); 157 show_settings_button);
160 } 158 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 303
306 // In the material design, we will add a title item with a separator on the 304 // In the material design, we will add a title item with a separator on the
307 // top of the IME menu. 305 // top of the IME menu.
308 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 306 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
309 ImeTitleView* title_view = new ImeTitleView(); 307 ImeTitleView* title_view = new ImeTitleView();
310 bubble_view->AddChildView(title_view); 308 bubble_view->AddChildView(title_view);
311 views::Separator* separator = 309 views::Separator* separator =
312 new views::Separator(views::Separator::HORIZONTAL); 310 new views::Separator(views::Separator::HORIZONTAL);
313 separator->SetColor(kBorderLightColor); 311 separator->SetColor(kBorderLightColor);
314 separator->SetPreferredSize(kSeparatorWidth); 312 separator->SetPreferredSize(kSeparatorWidth);
315 separator->SetBorder(views::Border::CreateEmptyBorder( 313 separator->SetBorder(
316 0, 0, kMenuSeparatorVerticalPadding, 0)); 314 views::CreateEmptyBorder(0, 0, kMenuSeparatorVerticalPadding, 0));
317 bubble_view->AddChildView(separator); 315 bubble_view->AddChildView(separator);
318 } 316 }
319 317
320 // Adds IME list to the bubble. 318 // Adds IME list to the bubble.
321 ime_list_view_ = 319 ime_list_view_ =
322 new ImeListView(nullptr, false, ImeListView::SHOW_SINGLE_IME); 320 new ImeListView(nullptr, false, ImeListView::SHOW_SINGLE_IME);
323 321
324 uint32_t current_height = ime_list_view_->scroll_content()->height(); 322 uint32_t current_height = ime_list_view_->scroll_content()->height();
325 const gfx::Range height_range = GetImeListViewRange(); 323 const gfx::Range height_range = GetImeListViewRange();
326 if (current_height > height_range.end()) { 324 if (current_height > height_range.end()) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 397 }
400 } 398 }
401 399
402 bool ImeMenuTray::ShouldBlockShelfAutoHide() const { 400 bool ImeMenuTray::ShouldBlockShelfAutoHide() const {
403 return should_block_shelf_auto_hide_; 401 return should_block_shelf_auto_hide_;
404 } 402 }
405 403
406 void ImeMenuTray::SetShelfAlignment(ShelfAlignment alignment) { 404 void ImeMenuTray::SetShelfAlignment(ShelfAlignment alignment) {
407 TrayBackgroundView::SetShelfAlignment(alignment); 405 TrayBackgroundView::SetShelfAlignment(alignment);
408 if (!MaterialDesignController::IsShelfMaterial()) 406 if (!MaterialDesignController::IsShelfMaterial())
409 tray_container()->SetBorder(views::Border::NullBorder()); 407 tray_container()->SetBorder(views::NullBorder());
410 } 408 }
411 409
412 base::string16 ImeMenuTray::GetAccessibleNameForTray() { 410 base::string16 ImeMenuTray::GetAccessibleNameForTray() {
413 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); 411 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME);
414 } 412 }
415 413
416 void ImeMenuTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) { 414 void ImeMenuTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) {
417 if (bubble_->bubble_view() == bubble_view) 415 if (bubble_->bubble_view() == bubble_view)
418 HideImeMenuBubble(); 416 HideImeMenuBubble();
419 } 417 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_); 533 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_);
536 534
537 // Updates the tray label based on the current input method. 535 // Updates the tray label based on the current input method.
538 if (current_ime_.third_party) 536 if (current_ime_.third_party)
539 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); 537 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*"));
540 else 538 else
541 label_->SetText(current_ime_.short_name); 539 label_->SetText(current_ime_.short_name);
542 } 540 }
543 541
544 } // namespace ash 542 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/ime_menu/ime_list_view.cc ('k') | ash/common/system/chromeos/network/network_list_md.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698