| 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/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "ui/views/drag_controller.h" | 34 #include "ui/views/drag_controller.h" |
| 35 | 35 |
| 36 namespace app_list { | 36 namespace app_list { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 const int kTopPadding = 20; | 40 const int kTopPadding = 20; |
| 41 const int kIconTitleSpacing = 7; | 41 const int kIconTitleSpacing = 7; |
| 42 const int kProgressBarHorizontalPadding = 12; | 42 const int kProgressBarHorizontalPadding = 12; |
| 43 | 43 |
| 44 // The font is different on each platform. The font size is adjusted on some | |
| 45 // platforms to keep a consistent look. | |
| 46 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 47 // Reducing the font size by 2 makes it the same as the Windows font size. | |
| 48 const int kFontSizeDelta = -2; | |
| 49 #else | |
| 50 const int kFontSizeDelta = 0; | |
| 51 #endif | |
| 52 | |
| 53 // Radius of the folder dropping preview circle. | 44 // Radius of the folder dropping preview circle. |
| 54 const int kFolderPreviewRadius = 40; | 45 const int kFolderPreviewRadius = 40; |
| 55 | 46 |
| 56 const int kLeftRightPaddingChars = 1; | 47 const int kLeftRightPaddingChars = 1; |
| 57 | 48 |
| 58 // Scale to transform the icon when a drag starts. | 49 // Scale to transform the icon when a drag starts. |
| 59 const float kDraggingIconScale = 1.5f; | 50 const float kDraggingIconScale = 1.5f; |
| 60 | 51 |
| 61 // Delay in milliseconds of when the dragging UI should be shown for mouse drag. | 52 // Delay in milliseconds of when the dragging UI should be shown for mouse drag. |
| 62 const int kMouseDragUIDelayInMs = 200; | 53 const int kMouseDragUIDelayInMs = 200; |
| 63 | 54 |
| 64 const gfx::ShadowValues& GetIconShadows() { | 55 const gfx::ShadowValues& GetIconShadows() { |
| 65 CR_DEFINE_STATIC_LOCAL( | 56 CR_DEFINE_STATIC_LOCAL( |
| 66 const gfx::ShadowValues, | 57 const gfx::ShadowValues, |
| 67 icon_shadows, | 58 icon_shadows, |
| 68 (1, | 59 (1, |
| 69 gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x24, 0, 0, 0)))); | 60 gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x24, 0, 0, 0)))); |
| 70 return icon_shadows; | 61 return icon_shadows; |
| 71 } | 62 } |
| 72 | 63 |
| 64 gfx::FontList GetFontList() { |
| 65 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 66 const gfx::FontList& font_list = rb.GetFontList(kItemTextFontStyle); |
| 67 // The font is different on each platform. The font size is adjusted on some |
| 68 // platforms to keep a consistent look. |
| 69 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 70 // Reducing the font size by 2 makes it the same as the Windows font size. |
| 71 const int kFontSizeDelta = -2; |
| 72 return font_list.DeriveWithSizeDelta(kFontSizeDelta); |
| 73 #else |
| 74 return font_list; |
| 75 #endif |
| 76 } |
| 77 |
| 73 } // namespace | 78 } // namespace |
| 74 | 79 |
| 75 // static | 80 // static |
| 76 const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView"; | 81 const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView"; |
| 77 | 82 |
| 78 AppListItemView::AppListItemView(AppsGridView* apps_grid_view, | 83 AppListItemView::AppListItemView(AppsGridView* apps_grid_view, |
| 79 AppListItem* item) | 84 AppListItem* item) |
| 80 : CustomButton(apps_grid_view), | 85 : CustomButton(apps_grid_view), |
| 81 is_folder_(item->GetItemType() == AppListFolderItem::kItemType), | 86 is_folder_(item->GetItemType() == AppListFolderItem::kItemType), |
| 82 is_in_folder_(item->IsInFolder()), | 87 is_in_folder_(item->IsInFolder()), |
| 83 item_weak_(item), | 88 item_weak_(item), |
| 84 apps_grid_view_(apps_grid_view), | 89 apps_grid_view_(apps_grid_view), |
| 85 icon_(new views::ImageView), | 90 icon_(new views::ImageView), |
| 86 title_(new CachedLabel), | 91 title_(new CachedLabel), |
| 87 progress_bar_(new ProgressBarView), | 92 progress_bar_(new ProgressBarView), |
| 88 ui_state_(UI_STATE_NORMAL), | 93 ui_state_(UI_STATE_NORMAL), |
| 89 touch_dragging_(false), | 94 touch_dragging_(false), |
| 90 is_installing_(false), | 95 is_installing_(false), |
| 91 is_highlighted_(false) { | 96 is_highlighted_(false) { |
| 92 icon_->set_interactive(false); | 97 icon_->set_interactive(false); |
| 93 | 98 |
| 94 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 95 title_->SetBackgroundColor(0); | 99 title_->SetBackgroundColor(0); |
| 96 title_->SetAutoColorReadabilityEnabled(false); | 100 title_->SetAutoColorReadabilityEnabled(false); |
| 97 title_->SetEnabledColor(kGridTitleColor); | 101 title_->SetEnabledColor(kGridTitleColor); |
| 98 title_->SetFontList( | 102 |
| 99 rb.GetFontList(kItemTextFontStyle).DeriveWithSizeDelta(kFontSizeDelta)); | 103 static const gfx::FontList font_list = GetFontList(); |
| 104 title_->SetFontList(font_list); |
| 100 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 105 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 101 title_->Invalidate(); | 106 title_->Invalidate(); |
| 102 SetTitleSubpixelAA(); | 107 SetTitleSubpixelAA(); |
| 103 | 108 |
| 104 AddChildView(icon_); | 109 AddChildView(icon_); |
| 105 AddChildView(title_); | 110 AddChildView(title_); |
| 106 AddChildView(progress_bar_); | 111 AddChildView(progress_bar_); |
| 107 | 112 |
| 108 SetIcon(item->icon(), item->has_shadow()); | 113 SetIcon(item->icon(), item->has_shadow()); |
| 109 SetItemName(base::UTF8ToUTF16(item->GetDisplayName()), | 114 SetItemName(base::UTF8ToUTF16(item->GetDisplayName()), |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 SetItemPercentDownloaded(item_weak_->percent_downloaded()); | 555 SetItemPercentDownloaded(item_weak_->percent_downloaded()); |
| 551 } | 556 } |
| 552 | 557 |
| 553 void AppListItemView::ItemBeingDestroyed() { | 558 void AppListItemView::ItemBeingDestroyed() { |
| 554 DCHECK(item_weak_); | 559 DCHECK(item_weak_); |
| 555 item_weak_->RemoveObserver(this); | 560 item_weak_->RemoveObserver(this); |
| 556 item_weak_ = NULL; | 561 item_weak_ = NULL; |
| 557 } | 562 } |
| 558 | 563 |
| 559 } // namespace app_list | 564 } // namespace app_list |
| OLD | NEW |