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

Side by Side Diff: ash/ime/infolist_window.cc

Issue 145033006: views: Make View::set_border() take a scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Further renaming Created 6 years, 11 months 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 | Annotate | Revision Log
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 "ash/ime/infolist_window.h" 5 #include "ash/ime/infolist_window.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ime/candidate_window_constants.h" 10 #include "ash/ime/candidate_window_constants.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 InfolistEntryView::InfolistEntryView(const ui::InfolistEntry& entry, 113 InfolistEntryView::InfolistEntryView(const ui::InfolistEntry& entry,
114 const gfx::FontList& title_font, 114 const gfx::FontList& title_font,
115 const gfx::FontList& description_font) 115 const gfx::FontList& description_font)
116 : entry_(entry) { 116 : entry_(entry) {
117 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 117 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
118 118
119 title_label_ = new views::Label(entry.title); 119 title_label_ = new views::Label(entry.title);
120 title_label_->SetPosition(gfx::Point(0, 0)); 120 title_label_->SetPosition(gfx::Point(0, 0));
121 title_label_->SetFontList(title_font); 121 title_label_->SetFontList(title_font);
122 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 122 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
123 title_label_->set_border( 123 title_label_->SetBorder(
124 views::Border::CreateEmptyBorder(4, 7, 2, 4)); 124 views::Border::CreateEmptyBorder(4, 7, 2, 4));
125 125
126 description_label_ = new views::Label(entry.body); 126 description_label_ = new views::Label(entry.body);
127 description_label_->SetPosition(gfx::Point(0, 0)); 127 description_label_->SetPosition(gfx::Point(0, 0));
128 description_label_->SetFontList(description_font); 128 description_label_->SetFontList(description_font);
129 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 129 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
130 description_label_->SetMultiLine(true); 130 description_label_->SetMultiLine(true);
131 description_label_->SizeToFit(kInfolistEntryWidth); 131 description_label_->SizeToFit(kInfolistEntryWidth);
132 description_label_->set_border( 132 description_label_->SetBorder(
133 views::Border::CreateEmptyBorder(2, 17, 4, 4)); 133 views::Border::CreateEmptyBorder(2, 17, 4, 4));
134 AddChildView(title_label_); 134 AddChildView(title_label_);
135 AddChildView(description_label_); 135 AddChildView(description_label_);
136 UpdateBackground(); 136 UpdateBackground();
137 } 137 }
138 138
139 InfolistEntryView::~InfolistEntryView() {} 139 InfolistEntryView::~InfolistEntryView() {}
140 140
141 void InfolistEntryView::SetEntry(const ui::InfolistEntry& entry) { 141 void InfolistEntryView::SetEntry(const ui::InfolistEntry& entry) {
142 if (entry_ == entry) 142 if (entry_ == entry)
143 return; 143 return;
144 144
145 entry_ = entry; 145 entry_ = entry;
146 title_label_->SetText(entry_.title); 146 title_label_->SetText(entry_.title);
147 description_label_->SetText(entry_.body); 147 description_label_->SetText(entry_.body);
148 UpdateBackground(); 148 UpdateBackground();
149 } 149 }
150 150
151 gfx::Size InfolistEntryView::GetPreferredSize() { 151 gfx::Size InfolistEntryView::GetPreferredSize() {
152 return gfx::Size(kInfolistEntryWidth, GetHeightForWidth(kInfolistEntryWidth)); 152 return gfx::Size(kInfolistEntryWidth, GetHeightForWidth(kInfolistEntryWidth));
153 } 153 }
154 154
155 void InfolistEntryView::UpdateBackground() { 155 void InfolistEntryView::UpdateBackground() {
156 if (entry_.highlighted) { 156 if (entry_.highlighted) {
157 set_background( 157 set_background(
158 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 158 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
159 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); 159 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused)));
160 set_border( 160 SetBorder(
161 views::Border::CreateSolidBorder(1, GetNativeTheme()->GetSystemColor( 161 views::Border::CreateSolidBorder(1, GetNativeTheme()->GetSystemColor(
162 ui::NativeTheme::kColorId_FocusedBorderColor))); 162 ui::NativeTheme::kColorId_FocusedBorderColor)));
163 } else { 163 } else {
164 set_background(NULL); 164 set_background(NULL);
165 set_border(views::Border::CreateEmptyBorder(1, 1, 1, 1)); 165 SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1));
166 } 166 }
167 SchedulePaint(); 167 SchedulePaint();
168 } 168 }
169 169
170 /////////////////////////////////////////////////////////////////////////////// 170 ///////////////////////////////////////////////////////////////////////////////
171 // InfolistWindow 171 // InfolistWindow
172 172
173 InfolistWindow::InfolistWindow(views::View* candidate_window, 173 InfolistWindow::InfolistWindow(views::View* candidate_window,
174 const std::vector<ui::InfolistEntry>& entries) 174 const std::vector<ui::InfolistEntry>& entries)
175 : views::BubbleDelegateView(candidate_window, views::BubbleBorder::NONE), 175 : views::BubbleDelegateView(candidate_window, views::BubbleBorder::NONE),
176 title_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)), 176 title_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)),
177 description_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 11)) { 177 description_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 11)) {
178 set_move_with_anchor(true); 178 set_move_with_anchor(true);
179 set_margins(gfx::Insets()); 179 set_margins(gfx::Insets());
180 180
181 set_background( 181 set_background(
182 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 182 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
183 ui::NativeTheme::kColorId_WindowBackground))); 183 ui::NativeTheme::kColorId_WindowBackground)));
184 set_border( 184 SetBorder(
185 views::Border::CreateSolidBorder(1, GetNativeTheme()->GetSystemColor( 185 views::Border::CreateSolidBorder(1, GetNativeTheme()->GetSystemColor(
186 ui::NativeTheme::kColorId_MenuBorderColor))); 186 ui::NativeTheme::kColorId_MenuBorderColor)));
187 187
188 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 188 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
189 189
190 views::Label* caption_label = new views::Label( 190 views::Label* caption_label = new views::Label(
191 l10n_util::GetStringUTF16(IDS_ASH_IME_INFOLIST_WINDOW_TITLE)); 191 l10n_util::GetStringUTF16(IDS_ASH_IME_INFOLIST_WINDOW_TITLE));
192 caption_label->SetFontList( 192 caption_label->SetFontList(
193 caption_label->font_list().DeriveFontList(kFontSizeDelta - 2)); 193 caption_label->font_list().DeriveFontList(kFontSizeDelta - 2));
194 caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 194 caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
195 caption_label->SetEnabledColor(GetNativeTheme()->GetSystemColor( 195 caption_label->SetEnabledColor(GetNativeTheme()->GetSystemColor(
196 ui::NativeTheme::kColorId_LabelEnabledColor)); 196 ui::NativeTheme::kColorId_LabelEnabledColor));
197 caption_label->set_border(views::Border::CreateEmptyBorder(2, 2, 2, 2)); 197 caption_label->SetBorder(views::Border::CreateEmptyBorder(2, 2, 2, 2));
198 caption_label->set_background(views::Background::CreateSolidBackground( 198 caption_label->set_background(views::Background::CreateSolidBackground(
199 color_utils::AlphaBlend(SK_ColorBLACK, 199 color_utils::AlphaBlend(SK_ColorBLACK,
200 GetNativeTheme()->GetSystemColor( 200 GetNativeTheme()->GetSystemColor(
201 ui::NativeTheme::kColorId_WindowBackground), 201 ui::NativeTheme::kColorId_WindowBackground),
202 0x10))); 202 0x10)));
203 203
204 AddChildView(caption_label); 204 AddChildView(caption_label);
205 205
206 for (size_t i = 0; i < entries.size(); ++i) { 206 for (size_t i = 0; i < entries.size(); ++i) {
207 entry_views_.push_back( 207 entry_views_.push_back(
208 new InfolistEntryView(entries[i], title_font_, description_font_)); 208 new InfolistEntryView(entries[i], title_font_, description_font_));
209 AddChildView(entry_views_.back()); 209 AddChildView(entry_views_.back());
210 } 210 }
211 } 211 }
212 212
213 InfolistWindow::~InfolistWindow() { 213 InfolistWindow::~InfolistWindow() {
214 } 214 }
215 215
216 void InfolistWindow::InitWidget() { 216 void InfolistWindow::InitWidget() {
217 views::Widget* widget = views::BubbleDelegateView::CreateBubble(this); 217 views::Widget* widget = views::BubbleDelegateView::CreateBubble(this);
218 views::corewm::SetWindowVisibilityAnimationType( 218 views::corewm::SetWindowVisibilityAnimationType(
219 widget->GetNativeView(), 219 widget->GetNativeView(),
220 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 220 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
221 221
222 // BubbleFrameView will be initialized through CreateBubble. 222 // BubbleFrameView will be initialized through CreateBubble.
223 GetBubbleFrameView()->SetBubbleBorder(new InfolistBorder()); 223 GetBubbleFrameView()->SetBubbleBorder(scoped_ptr<views::BubbleBorder>(
224 new InfolistBorder()));
224 SizeToContents(); 225 SizeToContents();
225 } 226 }
226 227
227 void InfolistWindow::Relayout(const std::vector<ui::InfolistEntry>& entries) { 228 void InfolistWindow::Relayout(const std::vector<ui::InfolistEntry>& entries) {
228 size_t i = 0; 229 size_t i = 0;
229 for (; i < entries.size(); ++i) { 230 for (; i < entries.size(); ++i) {
230 if (i < entry_views_.size()) { 231 if (i < entry_views_.size()) {
231 entry_views_[i]->SetEntry(entries[i]); 232 entry_views_[i]->SetEntry(entries[i]);
232 } else { 233 } else {
233 InfolistEntryView* new_entry = new InfolistEntryView( 234 InfolistEntryView* new_entry = new InfolistEntryView(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 show_hide_timer_.Stop(); 274 show_hide_timer_.Stop();
274 GetWidget()->Close(); 275 GetWidget()->Close();
275 } 276 }
276 277
277 void InfolistWindow::WindowClosing() { 278 void InfolistWindow::WindowClosing() {
278 show_hide_timer_.Stop(); 279 show_hide_timer_.Stop();
279 } 280 }
280 281
281 } // namespace ime 282 } // namespace ime
282 } // namespace ash 283 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698