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

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

Issue 142523003: Renames gfx::FontList::Derive* family. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 6 years, 10 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/infolist_window.h ('k') | ash/sticky_keys/sticky_keys_overlay.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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "grit/ash_strings.h" 12 #include "grit/ash_strings.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/gfx/color_utils.h" 14 #include "ui/gfx/color_utils.h"
15 #include "ui/gfx/font.h"
16 #include "ui/native_theme/native_theme.h" 15 #include "ui/native_theme/native_theme.h"
17 #include "ui/views/background.h" 16 #include "ui/views/background.h"
18 #include "ui/views/border.h" 17 #include "ui/views/border.h"
19 #include "ui/views/bubble/bubble_border.h" 18 #include "ui/views/bubble/bubble_border.h"
20 #include "ui/views/bubble/bubble_frame_view.h" 19 #include "ui/views/bubble/bubble_frame_view.h"
21 #include "ui/views/controls/label.h" 20 #include "ui/views/controls/label.h"
22 #include "ui/views/corewm/window_animations.h" 21 #include "ui/views/corewm/window_animations.h"
23 #include "ui/views/layout/box_layout.h" 22 #include "ui/views/layout/box_layout.h"
24 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
25 24
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // window without the gap. 79 // window without the gap.
81 return gfx::Insets(); 80 return gfx::Insets();
82 } 81 }
83 82
84 } // namespace 83 } // namespace
85 84
86 // InfolistRow renderes a row of a infolist. 85 // InfolistRow renderes a row of a infolist.
87 class InfolistEntryView : public views::View { 86 class InfolistEntryView : public views::View {
88 public: 87 public:
89 InfolistEntryView(const ui::InfolistEntry& entry, 88 InfolistEntryView(const ui::InfolistEntry& entry,
90 const gfx::FontList& title_font, 89 const gfx::FontList& title_font_list,
91 const gfx::FontList& description_font); 90 const gfx::FontList& description_font_list);
92 virtual ~InfolistEntryView(); 91 virtual ~InfolistEntryView();
93 92
94 void SetEntry(const ui::InfolistEntry& entry); 93 void SetEntry(const ui::InfolistEntry& entry);
95 94
96 private: 95 private:
97 // views::View implementation. 96 // views::View implementation.
98 virtual gfx::Size GetPreferredSize() OVERRIDE; 97 virtual gfx::Size GetPreferredSize() OVERRIDE;
99 98
100 void UpdateBackground(); 99 void UpdateBackground();
101 100
102 ui::InfolistEntry entry_; 101 ui::InfolistEntry entry_;
103 102
104 // The title label. Owned by views hierarchy. 103 // The title label. Owned by views hierarchy.
105 views::Label* title_label_; 104 views::Label* title_label_;
106 105
107 // The description label. Owned by views hierarchy. 106 // The description label. Owned by views hierarchy.
108 views::Label* description_label_; 107 views::Label* description_label_;
109 108
110 DISALLOW_COPY_AND_ASSIGN(InfolistEntryView); 109 DISALLOW_COPY_AND_ASSIGN(InfolistEntryView);
111 }; 110 };
112 111
113 InfolistEntryView::InfolistEntryView(const ui::InfolistEntry& entry, 112 InfolistEntryView::InfolistEntryView(const ui::InfolistEntry& entry,
114 const gfx::FontList& title_font, 113 const gfx::FontList& title_font_list,
115 const gfx::FontList& description_font) 114 const gfx::FontList& description_font_list)
116 : entry_(entry) { 115 : entry_(entry) {
117 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 116 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
118 117
119 title_label_ = new views::Label(entry.title); 118 title_label_ = new views::Label(entry.title, title_font_list);
120 title_label_->SetPosition(gfx::Point(0, 0)); 119 title_label_->SetPosition(gfx::Point(0, 0));
121 title_label_->SetFontList(title_font);
122 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 120 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
123 title_label_->SetBorder(views::Border::CreateEmptyBorder(4, 7, 2, 4)); 121 title_label_->SetBorder(views::Border::CreateEmptyBorder(4, 7, 2, 4));
124 122
125 description_label_ = new views::Label(entry.body); 123 description_label_ = new views::Label(entry.body, description_font_list);
126 description_label_->SetPosition(gfx::Point(0, 0)); 124 description_label_->SetPosition(gfx::Point(0, 0));
127 description_label_->SetFontList(description_font);
128 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 125 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
129 description_label_->SetMultiLine(true); 126 description_label_->SetMultiLine(true);
130 description_label_->SizeToFit(kInfolistEntryWidth); 127 description_label_->SizeToFit(kInfolistEntryWidth);
131 description_label_->SetBorder(views::Border::CreateEmptyBorder(2, 17, 4, 4)); 128 description_label_->SetBorder(views::Border::CreateEmptyBorder(2, 17, 4, 4));
132 AddChildView(title_label_); 129 AddChildView(title_label_);
133 AddChildView(description_label_); 130 AddChildView(description_label_);
134 UpdateBackground(); 131 UpdateBackground();
135 } 132 }
136 133
137 InfolistEntryView::~InfolistEntryView() {} 134 InfolistEntryView::~InfolistEntryView() {}
(...skipping 27 matching lines...) Expand all
165 } 162 }
166 SchedulePaint(); 163 SchedulePaint();
167 } 164 }
168 165
169 /////////////////////////////////////////////////////////////////////////////// 166 ///////////////////////////////////////////////////////////////////////////////
170 // InfolistWindow 167 // InfolistWindow
171 168
172 InfolistWindow::InfolistWindow(views::View* candidate_window, 169 InfolistWindow::InfolistWindow(views::View* candidate_window,
173 const std::vector<ui::InfolistEntry>& entries) 170 const std::vector<ui::InfolistEntry>& entries)
174 : views::BubbleDelegateView(candidate_window, views::BubbleBorder::NONE), 171 : views::BubbleDelegateView(candidate_window, views::BubbleBorder::NONE),
175 title_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)), 172 title_font_list_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)),
176 description_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 11)) { 173 description_font_list_(gfx::Font(kJapaneseFontName,
174 kFontSizeDelta + 11)) {
177 set_move_with_anchor(true); 175 set_move_with_anchor(true);
178 set_margins(gfx::Insets()); 176 set_margins(gfx::Insets());
179 177
180 set_background( 178 set_background(
181 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 179 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
182 ui::NativeTheme::kColorId_WindowBackground))); 180 ui::NativeTheme::kColorId_WindowBackground)));
183 SetBorder(views::Border::CreateSolidBorder( 181 SetBorder(views::Border::CreateSolidBorder(
184 1, 182 1,
185 GetNativeTheme()->GetSystemColor( 183 GetNativeTheme()->GetSystemColor(
186 ui::NativeTheme::kColorId_MenuBorderColor))); 184 ui::NativeTheme::kColorId_MenuBorderColor)));
187 185
188 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 186 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
189 187
190 views::Label* caption_label = new views::Label( 188 views::Label* caption_label = new views::Label(
191 l10n_util::GetStringUTF16(IDS_ASH_IME_INFOLIST_WINDOW_TITLE)); 189 l10n_util::GetStringUTF16(IDS_ASH_IME_INFOLIST_WINDOW_TITLE));
192 caption_label->SetFontList(
193 caption_label->font_list().DeriveFontList(kFontSizeDelta - 2));
194 caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 190 caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
195 caption_label->SetEnabledColor(GetNativeTheme()->GetSystemColor( 191 caption_label->SetEnabledColor(GetNativeTheme()->GetSystemColor(
196 ui::NativeTheme::kColorId_LabelEnabledColor)); 192 ui::NativeTheme::kColorId_LabelEnabledColor));
197 caption_label->SetBorder(views::Border::CreateEmptyBorder(2, 2, 2, 2)); 193 caption_label->SetBorder(views::Border::CreateEmptyBorder(2, 2, 2, 2));
198 caption_label->set_background(views::Background::CreateSolidBackground( 194 caption_label->set_background(views::Background::CreateSolidBackground(
199 color_utils::AlphaBlend(SK_ColorBLACK, 195 color_utils::AlphaBlend(SK_ColorBLACK,
200 GetNativeTheme()->GetSystemColor( 196 GetNativeTheme()->GetSystemColor(
201 ui::NativeTheme::kColorId_WindowBackground), 197 ui::NativeTheme::kColorId_WindowBackground),
202 0x10))); 198 0x10)));
203 199
204 AddChildView(caption_label); 200 AddChildView(caption_label);
205 201
206 for (size_t i = 0; i < entries.size(); ++i) { 202 for (size_t i = 0; i < entries.size(); ++i) {
207 entry_views_.push_back( 203 entry_views_.push_back(new InfolistEntryView(
208 new InfolistEntryView(entries[i], title_font_, description_font_)); 204 entries[i], title_font_list_, description_font_list_));
209 AddChildView(entry_views_.back()); 205 AddChildView(entry_views_.back());
210 } 206 }
211 } 207 }
212 208
213 InfolistWindow::~InfolistWindow() { 209 InfolistWindow::~InfolistWindow() {
214 } 210 }
215 211
216 void InfolistWindow::InitWidget() { 212 void InfolistWindow::InitWidget() {
217 views::Widget* widget = views::BubbleDelegateView::CreateBubble(this); 213 views::Widget* widget = views::BubbleDelegateView::CreateBubble(this);
218 views::corewm::SetWindowVisibilityAnimationType( 214 views::corewm::SetWindowVisibilityAnimationType(
219 widget->GetNativeView(), 215 widget->GetNativeView(),
220 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 216 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
221 217
222 // BubbleFrameView will be initialized through CreateBubble. 218 // BubbleFrameView will be initialized through CreateBubble.
223 GetBubbleFrameView()->SetBubbleBorder( 219 GetBubbleFrameView()->SetBubbleBorder(
224 scoped_ptr<views::BubbleBorder>(new InfolistBorder())); 220 scoped_ptr<views::BubbleBorder>(new InfolistBorder()));
225 SizeToContents(); 221 SizeToContents();
226 } 222 }
227 223
228 void InfolistWindow::Relayout(const std::vector<ui::InfolistEntry>& entries) { 224 void InfolistWindow::Relayout(const std::vector<ui::InfolistEntry>& entries) {
229 size_t i = 0; 225 size_t i = 0;
230 for (; i < entries.size(); ++i) { 226 for (; i < entries.size(); ++i) {
231 if (i < entry_views_.size()) { 227 if (i < entry_views_.size()) {
232 entry_views_[i]->SetEntry(entries[i]); 228 entry_views_[i]->SetEntry(entries[i]);
233 } else { 229 } else {
234 InfolistEntryView* new_entry = new InfolistEntryView( 230 InfolistEntryView* new_entry = new InfolistEntryView(
235 entries[i], title_font_, description_font_); 231 entries[i], title_font_list_, description_font_list_);
236 AddChildView(new_entry); 232 AddChildView(new_entry);
237 entry_views_.push_back(new_entry); 233 entry_views_.push_back(new_entry);
238 } 234 }
239 } 235 }
240 236
241 if (i < entry_views_.size()) { 237 if (i < entry_views_.size()) {
242 for (; i < entry_views_.size(); ++i) 238 for (; i < entry_views_.size(); ++i)
243 delete entry_views_[i]; 239 delete entry_views_[i];
244 entry_views_.resize(entries.size()); 240 entry_views_.resize(entries.size());
245 } 241 }
(...skipping 28 matching lines...) Expand all
274 show_hide_timer_.Stop(); 270 show_hide_timer_.Stop();
275 GetWidget()->Close(); 271 GetWidget()->Close();
276 } 272 }
277 273
278 void InfolistWindow::WindowClosing() { 274 void InfolistWindow::WindowClosing() {
279 show_hide_timer_.Stop(); 275 show_hide_timer_.Stop();
280 } 276 }
281 277
282 } // namespace ime 278 } // namespace ime
283 } // namespace ash 279 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ime/infolist_window.h ('k') | ash/sticky_keys/sticky_keys_overlay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698