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

Side by Side Diff: ui/chromeos/ime/infolist_window.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 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/infolist_window.h" 5 #include "ui/chromeos/ime/infolist_window.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 InfolistEntryView::InfolistEntryView(const ui::InfolistEntry& entry, 115 InfolistEntryView::InfolistEntryView(const ui::InfolistEntry& entry,
116 const gfx::FontList& title_font_list, 116 const gfx::FontList& title_font_list,
117 const gfx::FontList& description_font_list) 117 const gfx::FontList& description_font_list)
118 : entry_(entry) { 118 : entry_(entry) {
119 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 119 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
120 120
121 title_label_ = new views::Label(entry.title, title_font_list); 121 title_label_ = new views::Label(entry.title, title_font_list);
122 title_label_->SetPosition(gfx::Point(0, 0)); 122 title_label_->SetPosition(gfx::Point(0, 0));
123 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 123 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
124 title_label_->SetBorder(views::Border::CreateEmptyBorder(4, 7, 2, 4)); 124 title_label_->SetBorder(views::CreateEmptyBorder(4, 7, 2, 4));
125 125
126 description_label_ = new views::Label(entry.body, description_font_list); 126 description_label_ = new views::Label(entry.body, description_font_list);
127 description_label_->SetPosition(gfx::Point(0, 0)); 127 description_label_->SetPosition(gfx::Point(0, 0));
128 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 128 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
129 description_label_->SetMultiLine(true); 129 description_label_->SetMultiLine(true);
130 description_label_->SizeToFit(kInfolistEntryWidth); 130 description_label_->SizeToFit(kInfolistEntryWidth);
131 description_label_->SetBorder(views::Border::CreateEmptyBorder(2, 17, 4, 4)); 131 description_label_->SetBorder(views::CreateEmptyBorder(2, 17, 4, 4));
132 AddChildView(title_label_); 132 AddChildView(title_label_);
133 AddChildView(description_label_); 133 AddChildView(description_label_);
134 UpdateBackground(); 134 UpdateBackground();
135 } 135 }
136 136
137 InfolistEntryView::~InfolistEntryView() {} 137 InfolistEntryView::~InfolistEntryView() {}
138 138
139 void InfolistEntryView::SetEntry(const ui::InfolistEntry& entry) { 139 void InfolistEntryView::SetEntry(const ui::InfolistEntry& entry) {
140 if (entry_ == entry) 140 if (entry_ == entry)
141 return; 141 return;
142 142
143 entry_ = entry; 143 entry_ = entry;
144 title_label_->SetText(entry_.title); 144 title_label_->SetText(entry_.title);
145 description_label_->SetText(entry_.body); 145 description_label_->SetText(entry_.body);
146 UpdateBackground(); 146 UpdateBackground();
147 } 147 }
148 148
149 gfx::Size InfolistEntryView::GetPreferredSize() const { 149 gfx::Size InfolistEntryView::GetPreferredSize() const {
150 return gfx::Size(kInfolistEntryWidth, GetHeightForWidth(kInfolistEntryWidth)); 150 return gfx::Size(kInfolistEntryWidth, GetHeightForWidth(kInfolistEntryWidth));
151 } 151 }
152 152
153 void InfolistEntryView::UpdateBackground() { 153 void InfolistEntryView::UpdateBackground() {
154 if (entry_.highlighted) { 154 if (entry_.highlighted) {
155 set_background( 155 set_background(
156 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 156 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
157 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); 157 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused)));
158 SetBorder(views::Border::CreateSolidBorder( 158 SetBorder(views::CreateSolidBorder(
159 1, 159 1, GetNativeTheme()->GetSystemColor(
160 GetNativeTheme()->GetSystemColor( 160 ui::NativeTheme::kColorId_FocusedBorderColor)));
161 ui::NativeTheme::kColorId_FocusedBorderColor)));
162 } else { 161 } else {
163 set_background(NULL); 162 set_background(NULL);
164 SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); 163 SetBorder(views::CreateEmptyBorder(1, 1, 1, 1));
165 } 164 }
166 SchedulePaint(); 165 SchedulePaint();
167 } 166 }
168 167
169 /////////////////////////////////////////////////////////////////////////////// 168 ///////////////////////////////////////////////////////////////////////////////
170 // InfolistWindow 169 // InfolistWindow
171 170
172 InfolistWindow::InfolistWindow(views::View* candidate_window, 171 InfolistWindow::InfolistWindow(views::View* candidate_window,
173 const std::vector<ui::InfolistEntry>& entries) 172 const std::vector<ui::InfolistEntry>& entries)
174 : views::BubbleDialogDelegateView(candidate_window, 173 : views::BubbleDialogDelegateView(candidate_window,
175 views::BubbleBorder::NONE), 174 views::BubbleBorder::NONE),
176 title_font_list_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)), 175 title_font_list_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)),
177 description_font_list_( 176 description_font_list_(
178 gfx::Font(kJapaneseFontName, kFontSizeDelta + 11)) { 177 gfx::Font(kJapaneseFontName, kFontSizeDelta + 11)) {
179 set_can_activate(false); 178 set_can_activate(false);
180 set_accept_events(false); 179 set_accept_events(false);
181 set_margins(gfx::Insets()); 180 set_margins(gfx::Insets());
182 181
183 set_background( 182 set_background(
184 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 183 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
185 ui::NativeTheme::kColorId_WindowBackground))); 184 ui::NativeTheme::kColorId_WindowBackground)));
186 SetBorder(views::Border::CreateSolidBorder( 185 SetBorder(views::CreateSolidBorder(
187 1, 186 1, GetNativeTheme()->GetSystemColor(
188 GetNativeTheme()->GetSystemColor( 187 ui::NativeTheme::kColorId_MenuBorderColor)));
189 ui::NativeTheme::kColorId_MenuBorderColor)));
190 188
191 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 189 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
192 190
193 views::Label* caption_label = new views::Label( 191 views::Label* caption_label = new views::Label(
194 l10n_util::GetStringUTF16(IDS_CHROMEOS_IME_INFOLIST_WINDOW_TITLE)); 192 l10n_util::GetStringUTF16(IDS_CHROMEOS_IME_INFOLIST_WINDOW_TITLE));
195 caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 193 caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
196 caption_label->SetEnabledColor(GetNativeTheme()->GetSystemColor( 194 caption_label->SetEnabledColor(GetNativeTheme()->GetSystemColor(
197 ui::NativeTheme::kColorId_LabelEnabledColor)); 195 ui::NativeTheme::kColorId_LabelEnabledColor));
198 caption_label->SetBorder(views::Border::CreateEmptyBorder(2, 2, 2, 2)); 196 caption_label->SetBorder(views::CreateEmptyBorder(2, 2, 2, 2));
199 caption_label->set_background(views::Background::CreateSolidBackground( 197 caption_label->set_background(views::Background::CreateSolidBackground(
200 color_utils::AlphaBlend(SK_ColorBLACK, 198 color_utils::AlphaBlend(SK_ColorBLACK,
201 GetNativeTheme()->GetSystemColor( 199 GetNativeTheme()->GetSystemColor(
202 ui::NativeTheme::kColorId_WindowBackground), 200 ui::NativeTheme::kColorId_WindowBackground),
203 0x10))); 201 0x10)));
204 202
205 AddChildView(caption_label); 203 AddChildView(caption_label);
206 204
207 for (size_t i = 0; i < entries.size(); ++i) { 205 for (size_t i = 0; i < entries.size(); ++i) {
208 entry_views_.push_back(new InfolistEntryView( 206 entry_views_.push_back(new InfolistEntryView(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 int InfolistWindow::GetDialogButtons() const { 281 int InfolistWindow::GetDialogButtons() const {
284 return ui::DIALOG_BUTTON_NONE; 282 return ui::DIALOG_BUTTON_NONE;
285 } 283 }
286 284
287 void InfolistWindow::WindowClosing() { 285 void InfolistWindow::WindowClosing() {
288 show_hide_timer_.Stop(); 286 show_hide_timer_.Stop();
289 } 287 }
290 288
291 } // namespace ime 289 } // namespace ime
292 } // namespace ui 290 } // namespace ui
OLDNEW
« no previous file with comments | « ui/chromeos/ime/candidate_window_view.cc ('k') | ui/message_center/views/message_center_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698