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

Side by Side Diff: ash/common/system/chromeos/ime_menu/ime_list_view.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_list_view.h" 5 #include "ash/common/system/chromeos/ime_menu/ime_list_view.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/system/tray/hover_highlight_view.h" 8 #include "ash/common/system/tray/hover_highlight_view.h"
9 #include "ash/common/system/tray/ime_info.h" 9 #include "ash/common/system/tray/ime_info.h"
10 #include "ash/common/system/tray/system_menu_button.h" 10 #include "ash/common/system/tray/system_menu_button.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const int kMinFontSizeDelta = -10; 43 const int kMinFontSizeDelta = -10;
44 44
45 const SkColor kKeyboardRowSeparatorColor = SkColorSetA(SK_ColorBLACK, 0x1F); 45 const SkColor kKeyboardRowSeparatorColor = SkColorSetA(SK_ColorBLACK, 0x1F);
46 46
47 // Creates a separator that will be used between the IME list items. 47 // Creates a separator that will be used between the IME list items.
48 views::Separator* CreateListItemSeparator() { 48 views::Separator* CreateListItemSeparator() {
49 views::Separator* separator = 49 views::Separator* separator =
50 new views::Separator(views::Separator::HORIZONTAL); 50 new views::Separator(views::Separator::HORIZONTAL);
51 separator->SetColor(kBorderLightColor); 51 separator->SetColor(kBorderLightColor);
52 separator->SetPreferredSize(kSeparatorWidth); 52 separator->SetPreferredSize(kSeparatorWidth);
53 separator->SetBorder(views::Border::CreateEmptyBorder( 53 separator->SetBorder(
54 kMenuSeparatorVerticalPadding, 54 views::CreateEmptyBorder(kMenuSeparatorVerticalPadding,
55 kMenuExtraMarginFromLeftEdge + kMenuButtonSize, 55 kMenuExtraMarginFromLeftEdge + kMenuButtonSize,
56 kMenuSeparatorVerticalPadding, 0)); 56 kMenuSeparatorVerticalPadding, 0));
57 return separator; 57 return separator;
58 } 58 }
59 59
60 // A |HoverHighlightView| that uses bold or normal font depending on whether it 60 // A |HoverHighlightView| that uses bold or normal font depending on whether it
61 // is selected. This view exposes itself as a checkbox to the accessibility 61 // is selected. This view exposes itself as a checkbox to the accessibility
62 // framework. 62 // framework.
63 class SelectableHoverHighlightView : public HoverHighlightView { 63 class SelectableHoverHighlightView : public HoverHighlightView {
64 public: 64 public:
65 SelectableHoverHighlightView(ViewClickListener* listener, 65 SelectableHoverHighlightView(ViewClickListener* listener,
66 const base::string16& label, 66 const base::string16& label,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 int GetHeightForWidth(int w) const override { 194 int GetHeightForWidth(int w) const override {
195 return GetPreferredSize().height(); 195 return GetPreferredSize().height();
196 } 196 }
197 197
198 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { 198 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
199 UpdateStyle(); 199 UpdateStyle();
200 } 200 }
201 201
202 private: 202 private:
203 void Init() { 203 void Init() {
204 SetBorder(views::Border::CreateSolidSidedBorder( 204 SetBorder(views::CreateSolidSidedBorder(kKeyboardRowSeparatorThickness, 0,
205 kKeyboardRowSeparatorThickness, 0, 0, 0, kKeyboardRowSeparatorColor)); 205 0, 0, kKeyboardRowSeparatorColor));
206 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); 206 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
207 AddChildView(tri_view); 207 AddChildView(tri_view);
208 SetLayoutManager(new views::FillLayout); 208 SetLayoutManager(new views::FillLayout);
209 209
210 // The on-screen keyboard image button. 210 // The on-screen keyboard image button.
211 views::ImageView* keyboard_image = TrayPopupUtils::CreateMainImageView(); 211 views::ImageView* keyboard_image = TrayPopupUtils::CreateMainImageView();
212 keyboard_image->SetImage(gfx::CreateVectorIcon( 212 keyboard_image->SetImage(gfx::CreateVectorIcon(
213 kImeMenuOnScreenKeyboardIcon, kMenuIconSize, kMenuIconColor)); 213 kImeMenuOnScreenKeyboardIcon, kMenuIconSize, kMenuIconColor));
214 tri_view->AddView(TriView::Container::START, keyboard_image); 214 tri_view->AddView(TriView::Container::START, keyboard_image);
215 215
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 317 }
318 318
319 void ImeListView::AppendIMEProperties( 319 void ImeListView::AppendIMEProperties(
320 const IMEPropertyInfoList& property_list) { 320 const IMEPropertyInfoList& property_list) {
321 DCHECK(property_map_.empty()); 321 DCHECK(property_map_.empty());
322 for (size_t i = 0; i < property_list.size(); i++) { 322 for (size_t i = 0; i < property_list.size(); i++) {
323 HoverHighlightView* container = new SelectableHoverHighlightView( 323 HoverHighlightView* container = new SelectableHoverHighlightView(
324 this, property_list[i].name, property_list[i].selected); 324 this, property_list[i].name, property_list[i].selected);
325 if (i == 0) 325 if (i == 0)
326 container->SetBorder( 326 container->SetBorder(
327 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kBorderLightColor)); 327 views::CreateSolidSidedBorder(1, 0, 0, 0, kBorderLightColor));
328 scroll_content()->AddChildView(container); 328 scroll_content()->AddChildView(container);
329 property_map_[container] = property_list[i].key; 329 property_map_[container] = property_list[i].key;
330 } 330 }
331 } 331 }
332 332
333 void ImeListView::AppendImeListAndProperties( 333 void ImeListView::AppendImeListAndProperties(
334 const IMEInfoList& list, 334 const IMEInfoList& list,
335 const IMEPropertyInfoList& property_list) { 335 const IMEPropertyInfoList& property_list) {
336 DCHECK(ime_map_.empty()); 336 DCHECK(ime_map_.empty());
337 for (size_t i = 0; i < list.size(); i++) { 337 for (size_t i = 0; i < list.size(); i++) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 412 }
413 413
414 void ImeListView::ButtonPressed(views::Button* sender, const ui::Event& event) { 414 void ImeListView::ButtonPressed(views::Button* sender, const ui::Event& event) {
415 if (material_keyboard_statuts_view_ && 415 if (material_keyboard_statuts_view_ &&
416 sender == material_keyboard_statuts_view_->toggle()) { 416 sender == material_keyboard_statuts_view_->toggle()) {
417 WmShell::Get()->ToggleIgnoreExternalKeyboard(); 417 WmShell::Get()->ToggleIgnoreExternalKeyboard();
418 } 418 }
419 } 419 }
420 420
421 } // namespace ash 421 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/brightness/tray_brightness.cc ('k') | ash/common/system/chromeos/ime_menu/ime_menu_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698