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

Side by Side Diff: ui/chromeos/ime/candidate_window_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
« no previous file with comments | « ui/chromeos/ime/candidate_view.cc ('k') | ui/chromeos/ime/infolist_window.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/chromeos/ime/candidate_window_view.h" 5 #include "ui/chromeos/ime/candidate_window_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 enum BorderPosition { 94 enum BorderPosition {
95 TOP, 95 TOP,
96 BOTTOM 96 BOTTOM
97 }; 97 };
98 98
99 // Specify the alignment and initialize the control. 99 // Specify the alignment and initialize the control.
100 InformationTextArea(gfx::HorizontalAlignment align, int min_width) 100 InformationTextArea(gfx::HorizontalAlignment align, int min_width)
101 : min_width_(min_width) { 101 : min_width_(min_width) {
102 label_ = new views::Label; 102 label_ = new views::Label;
103 label_->SetHorizontalAlignment(align); 103 label_->SetHorizontalAlignment(align);
104 label_->SetBorder(views::Border::CreateEmptyBorder(2, 2, 2, 4)); 104 label_->SetBorder(views::CreateEmptyBorder(2, 2, 2, 4));
105 105
106 SetLayoutManager(new views::FillLayout()); 106 SetLayoutManager(new views::FillLayout());
107 AddChildView(label_); 107 AddChildView(label_);
108 set_background(views::Background::CreateSolidBackground( 108 set_background(views::Background::CreateSolidBackground(
109 color_utils::AlphaBlend(SK_ColorBLACK, 109 color_utils::AlphaBlend(SK_ColorBLACK,
110 GetNativeTheme()->GetSystemColor( 110 GetNativeTheme()->GetSystemColor(
111 ui::NativeTheme::kColorId_WindowBackground), 111 ui::NativeTheme::kColorId_WindowBackground),
112 0x10))); 112 0x10)));
113 } 113 }
114 114
115 // Sets the text alignment. 115 // Sets the text alignment.
116 void SetAlignment(gfx::HorizontalAlignment alignment) { 116 void SetAlignment(gfx::HorizontalAlignment alignment) {
117 label_->SetHorizontalAlignment(alignment); 117 label_->SetHorizontalAlignment(alignment);
118 } 118 }
119 119
120 // Sets the displayed text. 120 // Sets the displayed text.
121 void SetText(const base::string16& text) { 121 void SetText(const base::string16& text) {
122 label_->SetText(text); 122 label_->SetText(text);
123 } 123 }
124 124
125 // Sets the border thickness for top/bottom. 125 // Sets the border thickness for top/bottom.
126 void SetBorderFromPosition(BorderPosition position) { 126 void SetBorderFromPosition(BorderPosition position) {
127 SetBorder(views::Border::CreateSolidSidedBorder( 127 SetBorder(views::CreateSolidSidedBorder(
128 (position == TOP) ? 1 : 0, 128 (position == TOP) ? 1 : 0, 0, (position == BOTTOM) ? 1 : 0, 0,
129 0,
130 (position == BOTTOM) ? 1 : 0,
131 0,
132 GetNativeTheme()->GetSystemColor( 129 GetNativeTheme()->GetSystemColor(
133 ui::NativeTheme::kColorId_MenuBorderColor))); 130 ui::NativeTheme::kColorId_MenuBorderColor)));
134 } 131 }
135 132
136 protected: 133 protected:
137 gfx::Size GetPreferredSize() const override { 134 gfx::Size GetPreferredSize() const override {
138 gfx::Size size = views::View::GetPreferredSize(); 135 gfx::Size size = views::View::GetPreferredSize();
139 size.SetToMax(gfx::Size(min_width_, 0)); 136 size.SetToMax(gfx::Size(min_width_, 0));
140 return size; 137 return size;
141 } 138 }
(...skipping 12 matching lines...) Expand all
154 was_candidate_window_open_(false) { 151 was_candidate_window_open_(false) {
155 set_can_activate(false); 152 set_can_activate(false);
156 set_parent_window(parent); 153 set_parent_window(parent);
157 set_margins(gfx::Insets()); 154 set_margins(gfx::Insets());
158 155
159 // Set the background and the border of the view. 156 // Set the background and the border of the view.
160 ui::NativeTheme* theme = GetNativeTheme(); 157 ui::NativeTheme* theme = GetNativeTheme();
161 set_background( 158 set_background(
162 views::Background::CreateSolidBackground(theme->GetSystemColor( 159 views::Background::CreateSolidBackground(theme->GetSystemColor(
163 ui::NativeTheme::kColorId_WindowBackground))); 160 ui::NativeTheme::kColorId_WindowBackground)));
164 SetBorder(views::Border::CreateSolidBorder( 161 SetBorder(views::CreateSolidBorder(
165 1, theme->GetSystemColor(ui::NativeTheme::kColorId_MenuBorderColor))); 162 1, theme->GetSystemColor(ui::NativeTheme::kColorId_MenuBorderColor)));
166 163
167 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 164 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
168 auxiliary_text_ = new InformationTextArea(gfx::ALIGN_RIGHT, 0); 165 auxiliary_text_ = new InformationTextArea(gfx::ALIGN_RIGHT, 0);
169 preedit_ = new InformationTextArea(gfx::ALIGN_LEFT, kMinPreeditAreaWidth); 166 preedit_ = new InformationTextArea(gfx::ALIGN_LEFT, kMinPreeditAreaWidth);
170 candidate_area_ = new views::View; 167 candidate_area_ = new views::View;
171 auxiliary_text_->SetVisible(false); 168 auxiliary_text_->SetVisible(false);
172 preedit_->SetVisible(false); 169 preedit_->SetVisible(false);
173 candidate_area_->SetVisible(false); 170 candidate_area_->SetVisible(false);
174 preedit_->SetBorderFromPosition(InformationTextArea::BOTTOM); 171 preedit_->SetBorderFromPosition(InformationTextArea::BOTTOM);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 if (sender == candidate_views_[i].get()) { 409 if (sender == candidate_views_[i].get()) {
413 for (Observer& observer : observers_) 410 for (Observer& observer : observers_)
414 observer.OnCandidateCommitted(i); 411 observer.OnCandidateCommitted(i);
415 return; 412 return;
416 } 413 }
417 } 414 }
418 } 415 }
419 416
420 } // namespace ime 417 } // namespace ime
421 } // namespace ui 418 } // namespace ui
OLDNEW
« no previous file with comments | « ui/chromeos/ime/candidate_view.cc ('k') | ui/chromeos/ime/infolist_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698