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

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: Rebase to ToT 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
« no previous file with comments | « ash/ime/candidate_window_view.cc ('k') | ash/shelf/shelf_view.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 "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(views::Border::CreateEmptyBorder(4, 7, 2, 4));
124 views::Border::CreateEmptyBorder(4, 7, 2, 4));
125 124
126 description_label_ = new views::Label(entry.body); 125 description_label_ = new views::Label(entry.body);
127 description_label_->SetPosition(gfx::Point(0, 0)); 126 description_label_->SetPosition(gfx::Point(0, 0));
128 description_label_->SetFontList(description_font); 127 description_label_->SetFontList(description_font);
129 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 128 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
130 description_label_->SetMultiLine(true); 129 description_label_->SetMultiLine(true);
131 description_label_->SizeToFit(kInfolistEntryWidth); 130 description_label_->SizeToFit(kInfolistEntryWidth);
132 description_label_->set_border( 131 description_label_->SetBorder(views::Border::CreateEmptyBorder(2, 17, 4, 4));
133 views::Border::CreateEmptyBorder(2, 17, 4, 4));
134 AddChildView(title_label_); 132 AddChildView(title_label_);
135 AddChildView(description_label_); 133 AddChildView(description_label_);
136 UpdateBackground(); 134 UpdateBackground();
137 } 135 }
138 136
139 InfolistEntryView::~InfolistEntryView() {} 137 InfolistEntryView::~InfolistEntryView() {}
140 138
141 void InfolistEntryView::SetEntry(const ui::InfolistEntry& entry) { 139 void InfolistEntryView::SetEntry(const ui::InfolistEntry& entry) {
142 if (entry_ == entry) 140 if (entry_ == entry)
143 return; 141 return;
144 142
145 entry_ = entry; 143 entry_ = entry;
146 title_label_->SetText(entry_.title); 144 title_label_->SetText(entry_.title);
147 description_label_->SetText(entry_.body); 145 description_label_->SetText(entry_.body);
148 UpdateBackground(); 146 UpdateBackground();
149 } 147 }
150 148
151 gfx::Size InfolistEntryView::GetPreferredSize() { 149 gfx::Size InfolistEntryView::GetPreferredSize() {
152 return gfx::Size(kInfolistEntryWidth, GetHeightForWidth(kInfolistEntryWidth)); 150 return gfx::Size(kInfolistEntryWidth, GetHeightForWidth(kInfolistEntryWidth));
153 } 151 }
154 152
155 void InfolistEntryView::UpdateBackground() { 153 void InfolistEntryView::UpdateBackground() {
156 if (entry_.highlighted) { 154 if (entry_.highlighted) {
157 set_background( 155 set_background(
158 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 156 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
159 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); 157 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused)));
160 set_border( 158 SetBorder(views::Border::CreateSolidBorder(
161 views::Border::CreateSolidBorder(1, GetNativeTheme()->GetSystemColor( 159 1,
160 GetNativeTheme()->GetSystemColor(
162 ui::NativeTheme::kColorId_FocusedBorderColor))); 161 ui::NativeTheme::kColorId_FocusedBorderColor)));
163 } else { 162 } else {
164 set_background(NULL); 163 set_background(NULL);
165 set_border(views::Border::CreateEmptyBorder(1, 1, 1, 1)); 164 SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1));
166 } 165 }
167 SchedulePaint(); 166 SchedulePaint();
168 } 167 }
169 168
170 /////////////////////////////////////////////////////////////////////////////// 169 ///////////////////////////////////////////////////////////////////////////////
171 // InfolistWindow 170 // InfolistWindow
172 171
173 InfolistWindow::InfolistWindow(views::View* candidate_window, 172 InfolistWindow::InfolistWindow(views::View* candidate_window,
174 const std::vector<ui::InfolistEntry>& entries) 173 const std::vector<ui::InfolistEntry>& entries)
175 : views::BubbleDelegateView(candidate_window, views::BubbleBorder::NONE), 174 : views::BubbleDelegateView(candidate_window, views::BubbleBorder::NONE),
176 title_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)), 175 title_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)),
177 description_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 11)) { 176 description_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 11)) {
178 set_move_with_anchor(true); 177 set_move_with_anchor(true);
179 set_margins(gfx::Insets()); 178 set_margins(gfx::Insets());
180 179
181 set_background( 180 set_background(
182 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 181 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
183 ui::NativeTheme::kColorId_WindowBackground))); 182 ui::NativeTheme::kColorId_WindowBackground)));
184 set_border( 183 SetBorder(views::Border::CreateSolidBorder(
185 views::Border::CreateSolidBorder(1, GetNativeTheme()->GetSystemColor( 184 1,
185 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(
224 scoped_ptr<views::BubbleBorder>(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
« no previous file with comments | « ash/ime/candidate_window_view.cc ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698