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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = | 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 icon_->SetBoundsRect(GetIconBoundsForTargetViewBounds(GetContentsBounds())); |
270 icon_bounds.Inset(gfx::ShadowValue::GetMargin(icon_shadows_)); | |
271 icon_->SetBoundsRect(icon_bounds); | |
272 const gfx::Size title_size = title_->GetPreferredSize(); | 270 const gfx::Size title_size = title_->GetPreferredSize(); |
273 gfx::Rect title_bounds(rect.x() + (rect.width() - title_size.width()) / 2, | 271 gfx::Rect title_bounds(rect.x() + (rect.width() - title_size.width()) / 2, |
274 y + icon_size_.height() + kIconTitleSpacing, | 272 y + icon_size_.height() + kIconTitleSpacing, |
275 title_size.width(), | 273 title_size.width(), |
276 title_size.height()); | 274 title_size.height()); |
277 title_bounds.Intersect(rect); | 275 title_bounds.Intersect(rect); |
278 title_->SetBoundsRect(title_bounds); | 276 title_->SetBoundsRect(title_bounds); |
279 | 277 |
280 gfx::Rect progress_bar_bounds(progress_bar_->GetPreferredSize()); | 278 gfx::Rect progress_bar_bounds(progress_bar_->GetPreferredSize()); |
281 progress_bar_bounds.set_x(GetContentsBounds().x() + | 279 progress_bar_bounds.set_x(GetContentsBounds().x() + |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 457 } |
460 | 458 |
461 void AppListItemView::OnSyncDragEnd() { | 459 void AppListItemView::OnSyncDragEnd() { |
462 SetUIState(UI_STATE_NORMAL); | 460 SetUIState(UI_STATE_NORMAL); |
463 } | 461 } |
464 | 462 |
465 const gfx::Rect& AppListItemView::GetIconBounds() const { | 463 const gfx::Rect& AppListItemView::GetIconBounds() const { |
466 return icon_->bounds(); | 464 return icon_->bounds(); |
467 } | 465 } |
468 | 466 |
| 467 void AppListItemView::SetDragUIState() { |
| 468 SetUIState(UI_STATE_DRAGGING); |
| 469 } |
| 470 |
| 471 gfx::Rect AppListItemView::GetIconBoundsForTargetViewBounds( |
| 472 const gfx::Rect& target_bounds) { |
| 473 gfx::Rect rect(target_bounds); |
| 474 |
| 475 const int left_right_padding = |
| 476 title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars); |
| 477 rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0); |
| 478 |
| 479 gfx::Rect icon_bounds(rect.x(), rect.y(), rect.width(), icon_size_.height()); |
| 480 icon_bounds.Inset(gfx::ShadowValue::GetMargin(icon_shadows_)); |
| 481 return icon_bounds; |
| 482 } |
| 483 |
469 } // namespace app_list | 484 } // namespace app_list |
OLD | NEW |