OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/app_list/search_result_view.h" | 5 #include "ui/app_list/search_result_view.h" |
6 | 6 |
7 #include "ui/app_list/app_list_constants.h" | 7 #include "ui/app_list/app_list_constants.h" |
8 #include "ui/app_list/search_result.h" | 8 #include "ui/app_list/search_result.h" |
9 #include "ui/app_list/search_result_list_view.h" | 9 #include "ui/app_list/search_result_list_view.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 void SearchResultView::Layout() { | 163 void SearchResultView::Layout() { |
164 gfx::Rect rect(GetContentsBounds()); | 164 gfx::Rect rect(GetContentsBounds()); |
165 if (rect.IsEmpty()) | 165 if (rect.IsEmpty()) |
166 return; | 166 return; |
167 | 167 |
168 gfx::Rect icon_bounds(rect); | 168 gfx::Rect icon_bounds(rect); |
169 icon_bounds.set_width(kIconViewWidth); | 169 icon_bounds.set_width(kIconViewWidth); |
170 icon_bounds.Inset(kIconPadding, (rect.height() - kIconDimension) / 2); | 170 icon_bounds.Inset(kIconPadding, (rect.height() - kIconDimension) / 2); |
171 icon_->SetBoundsRect(icon_bounds.Intersect(rect)); | 171 icon_bounds.Intersect(rect); |
| 172 icon_->SetBoundsRect(icon_bounds); |
172 | 173 |
173 size_t num_buttons = action_buttons_.size(); | 174 size_t num_buttons = action_buttons_.size(); |
174 for (size_t i = 0; i < num_buttons; ++i) { | 175 for (size_t i = 0; i < num_buttons; ++i) { |
175 views::ImageButton* button = action_buttons_[i]; | 176 views::ImageButton* button = action_buttons_[i]; |
176 gfx::Rect button_bounds( | 177 gfx::Rect button_bounds( |
177 rect.right() - kActionButtonRightMargin - | 178 rect.right() - kActionButtonRightMargin - |
178 (num_buttons - i) * kActionButtonWidth, | 179 (num_buttons - i) * kActionButtonWidth, |
179 (rect.y() + rect.height() - kActionIconDimension) / 2, | 180 (rect.y() + rect.height() - kActionIconDimension) / 2, |
180 kActionButtonWidth, kActionIconDimension); | 181 kActionButtonWidth, kActionIconDimension); |
181 button->SetBoundsRect(button_bounds); | 182 button->SetBoundsRect(button_bounds); |
(...skipping 10 matching lines...) Expand all Loading... |
192 | 193 |
193 canvas->FillRect(content_rect, kContentsBackgroundColor); | 194 canvas->FillRect(content_rect, kContentsBackgroundColor); |
194 | 195 |
195 bool selected = list_view_->IsResultViewSelected(this); | 196 bool selected = list_view_->IsResultViewSelected(this); |
196 if (selected) { | 197 if (selected) { |
197 canvas->FillRect(content_rect, kSelectedBackgroundColor); | 198 canvas->FillRect(content_rect, kSelectedBackgroundColor); |
198 } else if (state() == BS_HOT || state() == BS_PUSHED) { | 199 } else if (state() == BS_HOT || state() == BS_PUSHED) { |
199 canvas->FillRect(content_rect, kHoverAndPushedColor); | 200 canvas->FillRect(content_rect, kHoverAndPushedColor); |
200 } | 201 } |
201 | 202 |
202 gfx::Rect border_bottom = rect.Subtract(content_rect); | 203 gfx::Rect border_bottom(rect); |
| 204 border_bottom.Subtract(content_rect); |
203 canvas->FillRect(border_bottom, | 205 canvas->FillRect(border_bottom, |
204 selected ? kSelectedBorderColor : kBorderColor); | 206 selected ? kSelectedBorderColor : kBorderColor); |
205 | 207 |
206 gfx::Rect text_bounds(rect); | 208 gfx::Rect text_bounds(rect); |
207 text_bounds.set_x(kIconViewWidth); | 209 text_bounds.set_x(kIconViewWidth); |
208 text_bounds.set_width( | 210 text_bounds.set_width( |
209 rect.width() - kIconViewWidth - kTextTrailPadding - | 211 rect.width() - kIconViewWidth - kTextTrailPadding - |
210 action_buttons_.size() * kActionButtonWidth - | 212 action_buttons_.size() * kActionButtonWidth - |
211 (!action_buttons_.empty() ? kActionButtonRightMargin : 0)); | 213 (!action_buttons_.empty() ? kActionButtonRightMargin : 0)); |
212 text_bounds.set_x(GetMirroredXWithWidthInView(text_bounds.x(), | 214 text_bounds.set_x(GetMirroredXWithWidthInView(text_bounds.x(), |
(...skipping 11 matching lines...) Expand all Loading... |
224 title_size)); | 226 title_size)); |
225 title_text_->Draw(canvas); | 227 title_text_->Draw(canvas); |
226 | 228 |
227 y += title_size.height(); | 229 y += title_size.height(); |
228 details_text_->SetDisplayRect(gfx::Rect(gfx::Point(text_bounds.x(), y), | 230 details_text_->SetDisplayRect(gfx::Rect(gfx::Point(text_bounds.x(), y), |
229 details_size)); | 231 details_size)); |
230 details_text_->Draw(canvas); | 232 details_text_->Draw(canvas); |
231 } else if (title_text_.get()) { | 233 } else if (title_text_.get()) { |
232 gfx::Size title_size(text_bounds.width(), | 234 gfx::Size title_size(text_bounds.width(), |
233 title_text_->GetStringSize().height()); | 235 title_text_->GetStringSize().height()); |
234 title_text_->SetDisplayRect(text_bounds.Center(title_size)); | 236 gfx::Rect centered_title_rect(text_bounds); |
| 237 centered_title_rect.ClampToCenteredSize(title_size); |
| 238 title_text_->SetDisplayRect(centered_title_rect); |
235 title_text_->Draw(canvas); | 239 title_text_->Draw(canvas); |
236 } | 240 } |
237 } | 241 } |
238 | 242 |
239 void SearchResultView::ButtonPressed(views::Button* sender, | 243 void SearchResultView::ButtonPressed(views::Button* sender, |
240 const ui::Event& event) { | 244 const ui::Event& event) { |
241 if (sender == this) { | 245 if (sender == this) { |
242 delegate_->SearchResultActivated(this, event); | 246 delegate_->SearchResultActivated(this, event); |
243 return; | 247 return; |
244 } | 248 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 views::ImageButton* button = action_buttons_[i]; | 301 views::ImageButton* button = action_buttons_[i]; |
298 button->SetImage(views::CustomButton::BS_NORMAL, &icon.base_image); | 302 button->SetImage(views::CustomButton::BS_NORMAL, &icon.base_image); |
299 button->SetImage(views::CustomButton::BS_HOT, &icon.hover_image); | 303 button->SetImage(views::CustomButton::BS_HOT, &icon.hover_image); |
300 button->SetImage(views::CustomButton::BS_PUSHED, &icon.pressed_image); | 304 button->SetImage(views::CustomButton::BS_PUSHED, &icon.pressed_image); |
301 button->SetTooltipText(icon.tooltip_text); | 305 button->SetTooltipText(icon.tooltip_text); |
302 } | 306 } |
303 } | 307 } |
304 } | 308 } |
305 | 309 |
306 } // namespace app_list | 310 } // namespace app_list |
OLD | NEW |