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/views/app_list_item_view.h" | 5 #include "ui/app_list/views/app_list_item_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
11 #include "ui/app_list/app_list_item_model.h" | 11 #include "ui/app_list/app_list_item_model.h" |
12 #include "ui/app_list/app_list_switches.h" | 12 #include "ui/app_list/app_list_switches.h" |
13 #include "ui/app_list/views/apps_grid_view.h" | 13 #include "ui/app_list/views/apps_grid_view.h" |
14 #include "ui/app_list/views/cached_label.h" | 14 #include "ui/app_list/views/cached_label.h" |
15 #include "ui/app_list/views/progress_bar_view.h" | 15 #include "ui/app_list/views/progress_bar_view.h" |
16 #include "ui/base/accessibility/accessible_view_state.h" | 16 #include "ui/base/accessibility/accessible_view_state.h" |
17 #include "ui/base/dragdrop/drag_utils.h" | 17 #include "ui/base/dragdrop/drag_utils.h" |
18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/compositor/layer.h" | 19 #include "ui/compositor/layer.h" |
20 #include "ui/compositor/scoped_layer_animation_settings.h" | 20 #include "ui/compositor/scoped_layer_animation_settings.h" |
21 #include "ui/gfx/animation/throb_animation.h" | 21 #include "ui/gfx/animation/throb_animation.h" |
22 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
23 #include "ui/gfx/font.h" | 23 #include "ui/gfx/font_list.h" |
24 #include "ui/gfx/image/image_skia_operations.h" | 24 #include "ui/gfx/image/image_skia_operations.h" |
25 #include "ui/gfx/point.h" | 25 #include "ui/gfx/point.h" |
26 #include "ui/gfx/transform_util.h" | 26 #include "ui/gfx/transform_util.h" |
27 #include "ui/views/controls/image_view.h" | 27 #include "ui/views/controls/image_view.h" |
28 #include "ui/views/controls/label.h" | 28 #include "ui/views/controls/label.h" |
29 #include "ui/views/controls/menu/menu_item_view.h" | 29 #include "ui/views/controls/menu/menu_item_view.h" |
30 #include "ui/views/controls/menu/menu_runner.h" | 30 #include "ui/views/controls/menu/menu_runner.h" |
31 #include "ui/views/drag_controller.h" | 31 #include "ui/views/drag_controller.h" |
32 | 32 |
33 namespace app_list { | 33 namespace app_list { |
(...skipping 29 matching lines...) Expand all Loading... |
63 title_(new CachedLabel), | 63 title_(new CachedLabel), |
64 progress_bar_(new ProgressBarView), | 64 progress_bar_(new ProgressBarView), |
65 ui_state_(UI_STATE_NORMAL), | 65 ui_state_(UI_STATE_NORMAL), |
66 touch_dragging_(false) { | 66 touch_dragging_(false) { |
67 icon_->set_interactive(false); | 67 icon_->set_interactive(false); |
68 | 68 |
69 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 69 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
70 title_->SetBackgroundColor(0); | 70 title_->SetBackgroundColor(0); |
71 title_->SetAutoColorReadabilityEnabled(false); | 71 title_->SetAutoColorReadabilityEnabled(false); |
72 title_->SetEnabledColor(kGridTitleColor); | 72 title_->SetEnabledColor(kGridTitleColor); |
73 title_->SetFont(rb.GetFont(kItemTextFontStyle)); | 73 title_->SetFontList(rb.GetFontList(kItemTextFontStyle)); |
74 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 74 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
75 title_->SetVisible(!model_->is_installing()); | 75 title_->SetVisible(!model_->is_installing()); |
76 title_->Invalidate(); | 76 title_->Invalidate(); |
77 | 77 |
78 const gfx::ShadowValue kIconShadows[] = { | 78 const gfx::ShadowValue kIconShadows[] = { |
79 gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x24, 0, 0, 0)), | 79 gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x24, 0, 0, 0)), |
80 }; | 80 }; |
81 icon_shadows_.assign(kIconShadows, kIconShadows + arraysize(kIconShadows)); | 81 icon_shadows_.assign(kIconShadows, kIconShadows + arraysize(kIconShadows)); |
82 | 82 |
83 AddChildView(icon_); | 83 AddChildView(icon_); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 progress_bar_->SetValue(model_->percent_downloaded() / 100.0); | 254 progress_bar_->SetValue(model_->percent_downloaded() / 100.0); |
255 } | 255 } |
256 | 256 |
257 const char* AppListItemView::GetClassName() const { | 257 const char* AppListItemView::GetClassName() const { |
258 return kViewClassName; | 258 return kViewClassName; |
259 } | 259 } |
260 | 260 |
261 void AppListItemView::Layout() { | 261 void AppListItemView::Layout() { |
262 gfx::Rect rect(GetContentsBounds()); | 262 gfx::Rect rect(GetContentsBounds()); |
263 | 263 |
264 const int left_right_padding = kLeftRightPaddingChars * | 264 const int left_right_padding = |
265 title_->font().GetAverageCharacterWidth(); | 265 title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars); |
266 rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0); | 266 rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0); |
267 const int y = rect.y(); | 267 const int y = rect.y(); |
268 | 268 |
269 gfx::Rect icon_bounds(rect.x(), y, rect.width(), icon_size_.height()); | 269 gfx::Rect icon_bounds(rect.x(), y, rect.width(), icon_size_.height()); |
270 icon_bounds.Inset(gfx::ShadowValue::GetMargin(icon_shadows_)); | 270 icon_bounds.Inset(gfx::ShadowValue::GetMargin(icon_shadows_)); |
271 icon_->SetBoundsRect(icon_bounds); | 271 icon_->SetBoundsRect(icon_bounds); |
272 | 272 |
273 const gfx::Size title_size = title_->GetPreferredSize(); | 273 const gfx::Size title_size = title_->GetPreferredSize(); |
274 gfx::Rect title_bounds(rect.x() + (rect.width() - title_size.width()) / 2, | 274 gfx::Rect title_bounds(rect.x() + (rect.width() - title_size.width()) / 2, |
275 y + icon_size_.height() + kIconTitleSpacing, | 275 y + icon_size_.height() + kIconTitleSpacing, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 457 } |
458 if (!event->handled()) | 458 if (!event->handled()) |
459 CustomButton::OnGestureEvent(event); | 459 CustomButton::OnGestureEvent(event); |
460 } | 460 } |
461 | 461 |
462 void AppListItemView::OnSyncDragEnd() { | 462 void AppListItemView::OnSyncDragEnd() { |
463 SetUIState(UI_STATE_NORMAL); | 463 SetUIState(UI_STATE_NORMAL); |
464 } | 464 } |
465 | 465 |
466 } // namespace app_list | 466 } // namespace app_list |
OLD | NEW |