| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 // Radius of the folder dropping preview circle. | 41 // Radius of the folder dropping preview circle. |
| 42 const int kFolderPreviewRadius = 40; | 42 const int kFolderPreviewRadius = 40; |
| 43 | 43 |
| 44 const int kLeftRightPaddingChars = 1; | 44 const int kLeftRightPaddingChars = 1; |
| 45 | 45 |
| 46 // Scale to transform the icon when a drag starts. | 46 // Scale to transform the icon when a drag starts. |
| 47 const float kDraggingIconScale = 1.5f; | 47 const float kDraggingIconScale = 1.5f; |
| 48 | 48 |
| 49 // Delay in milliseconds of when the dragging UI should be shown for mouse drag. | 49 // Delay in milliseconds of when the dragging UI should be shown for mouse drag. |
| 50 const int kMouseDragUIDelayInMs = 100; | 50 const int kMouseDragUIDelayInMs = 200; |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 // static | 54 // static |
| 55 const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView"; | 55 const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView"; |
| 56 | 56 |
| 57 AppListItemView::AppListItemView(AppsGridView* apps_grid_view, | 57 AppListItemView::AppListItemView(AppsGridView* apps_grid_view, |
| 58 AppListItem* item) | 58 AppListItem* item) |
| 59 : CustomButton(apps_grid_view), | 59 : CustomButton(apps_grid_view), |
| 60 item_(item), | 60 item_(item), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage(icon, | 122 gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage(icon, |
| 123 skia::ImageOperations::RESIZE_BEST, icon_size_)); | 123 skia::ImageOperations::RESIZE_BEST, icon_size_)); |
| 124 if (item_->has_shadow()) { | 124 if (item_->has_shadow()) { |
| 125 gfx::ImageSkia shadow( | 125 gfx::ImageSkia shadow( |
| 126 gfx::ImageSkiaOperations::CreateImageWithDropShadow(resized, | 126 gfx::ImageSkiaOperations::CreateImageWithDropShadow(resized, |
| 127 icon_shadows_)); | 127 icon_shadows_)); |
| 128 icon_->SetImage(shadow); | 128 icon_->SetImage(shadow); |
| 129 return; | 129 return; |
| 130 }; | 130 } |
| 131 | 131 |
| 132 icon_->SetImage(resized); | 132 icon_->SetImage(resized); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void AppListItemView::UpdateTooltip() { | 135 void AppListItemView::UpdateTooltip() { |
| 136 title_->SetTooltipText(item_->title() == item_->full_name() ? base::string16() | 136 title_->SetTooltipText(item_->title() == item_->full_name() ? base::string16() |
| 137 : base::UTF8ToUTF16(item_->full_name())); | 137 : base::UTF8ToUTF16(item_->full_name())); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void AppListItemView::SetUIState(UIState state) { | 140 void AppListItemView::SetUIState(UIState state) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 gfx::Rect rect(GetContentsBounds()); | 262 gfx::Rect rect(GetContentsBounds()); |
| 263 | 263 |
| 264 const int left_right_padding = | 264 const int left_right_padding = |
| 265 title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars); | 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 | |
| 273 const gfx::Size title_size = title_->GetPreferredSize(); | 272 const gfx::Size title_size = title_->GetPreferredSize(); |
| 274 gfx::Rect title_bounds(rect.x() + (rect.width() - title_size.width()) / 2, | 273 gfx::Rect title_bounds(rect.x() + (rect.width() - title_size.width()) / 2, |
| 275 y + icon_size_.height() + kIconTitleSpacing, | 274 y + icon_size_.height() + kIconTitleSpacing, |
| 276 title_size.width(), | 275 title_size.width(), |
| 277 title_size.height()); | 276 title_size.height()); |
| 278 title_bounds.Intersect(rect); | 277 title_bounds.Intersect(rect); |
| 279 title_->SetBoundsRect(title_bounds); | 278 title_->SetBoundsRect(title_bounds); |
| 280 | 279 |
| 281 gfx::Rect progress_bar_bounds(progress_bar_->GetPreferredSize()); | 280 gfx::Rect progress_bar_bounds(progress_bar_->GetPreferredSize()); |
| 282 progress_bar_bounds.set_x(GetContentsBounds().x() + | 281 progress_bar_bounds.set_x(GetContentsBounds().x() + |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 break; | 455 break; |
| 457 } | 456 } |
| 458 if (!event->handled()) | 457 if (!event->handled()) |
| 459 CustomButton::OnGestureEvent(event); | 458 CustomButton::OnGestureEvent(event); |
| 460 } | 459 } |
| 461 | 460 |
| 462 void AppListItemView::OnSyncDragEnd() { | 461 void AppListItemView::OnSyncDragEnd() { |
| 463 SetUIState(UI_STATE_NORMAL); | 462 SetUIState(UI_STATE_NORMAL); |
| 464 } | 463 } |
| 465 | 464 |
| 465 const gfx::Rect& AppListItemView::GetIconBounds() const { |
| 466 return icon_->bounds(); |
| 467 } |
| 468 |
| 466 } // namespace app_list | 469 } // namespace app_list |
| OLD | NEW |