| 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 "ash/app_list/app_list_item_view.h" | 5 #include "ui/app_list/app_list_item_view.h" |
| 6 | 6 |
| 7 #include "ash/app_list/app_list.h" | 7 #include <algorithm> |
| 8 #include "ash/app_list/app_list_item_model.h" | 8 |
| 9 #include "ash/app_list/app_list_model_view.h" | |
| 10 #include "ash/app_list/drop_shadow_label.h" | |
| 11 #include "ash/app_list/icon_cache.h" | |
| 12 #include "base/bind.h" | 9 #include "base/bind.h" |
| 13 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 14 #include "base/synchronization/cancellation_flag.h" | 11 #include "base/synchronization/cancellation_flag.h" |
| 15 #include "base/threading/worker_pool.h" | 12 #include "base/threading/worker_pool.h" |
| 16 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "ui/app_list/app_list_item_model.h" |
| 15 #include "ui/app_list/app_list_model_view.h" |
| 16 #include "ui/app_list/drop_shadow_label.h" |
| 17 #include "ui/app_list/icon_cache.h" |
| 17 #include "ui/base/accessibility/accessible_view_state.h" | 18 #include "ui/base/accessibility/accessible_view_state.h" |
| 18 #include "ui/base/animation/throb_animation.h" | 19 #include "ui/base/animation/throb_animation.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/font.h" | 22 #include "ui/gfx/font.h" |
| 22 #include "ui/gfx/shadow_value.h" | 23 #include "ui/gfx/shadow_value.h" |
| 23 #include "ui/gfx/skbitmap_operations.h" | 24 #include "ui/gfx/skbitmap_operations.h" |
| 24 #include "ui/views/controls/image_view.h" | 25 #include "ui/views/controls/image_view.h" |
| 25 #include "ui/views/controls/menu/menu_item_view.h" | 26 #include "ui/views/controls/menu/menu_item_view.h" |
| 26 #include "ui/views/controls/menu/menu_model_adapter.h" | 27 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 27 #include "ui/views/controls/menu/menu_runner.h" | 28 #include "ui/views/controls/menu/menu_runner.h" |
| 28 | 29 |
| 29 namespace ash { | 30 namespace app_list { |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 const int kTopBottomPadding = 10; | 34 const int kTopBottomPadding = 10; |
| 34 const int kIconTitleSpacing = 10; | 35 const int kIconTitleSpacing = 10; |
| 35 | 36 |
| 36 const SkColor kTitleColor = SK_ColorWHITE; | 37 const SkColor kTitleColor = SK_ColorWHITE; |
| 37 const SkColor kTitleColorV2 = SkColorSetARGB(0xFF, 0x88, 0x88, 0x88); | 38 const SkColor kTitleColorV2 = SkColorSetARGB(0xFF, 0x88, 0x88, 0x88); |
| 38 | 39 |
| 39 // 0.33 black | 40 // 0.33 black |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 DISALLOW_COPY_AND_ASSIGN(StaticImageView); | 96 DISALLOW_COPY_AND_ASSIGN(StaticImageView); |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 // A minimum title width set by test to override the default logic that derives | 99 // A minimum title width set by test to override the default logic that derives |
| 99 // the min width from font. | 100 // the min width from font. |
| 100 int g_min_title_width = 0; | 101 int g_min_title_width = 0; |
| 101 | 102 |
| 102 } // namespace | 103 } // namespace |
| 103 | 104 |
| 104 // static | 105 // static |
| 105 const char AppListItemView::kViewClassName[] = "ash/app_list/AppListItemView"; | 106 const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView"; |
| 106 | 107 |
| 107 // AppListItemView::IconOperation wraps background icon processing. | 108 // AppListItemView::IconOperation wraps background icon processing. |
| 108 class AppListItemView::IconOperation | 109 class AppListItemView::IconOperation |
| 109 : public base::RefCountedThreadSafe<AppListItemView::IconOperation> { | 110 : public base::RefCountedThreadSafe<AppListItemView::IconOperation> { |
| 110 public: | 111 public: |
| 111 IconOperation(const SkBitmap& bitmap, const gfx::Size& size) | 112 IconOperation(const SkBitmap& bitmap, const gfx::Size& size) |
| 112 : bitmap_(bitmap), | 113 : bitmap_(bitmap), |
| 113 size_(size) { | 114 size_(size) { |
| 114 } | 115 } |
| 115 | 116 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 views::ButtonListener* listener) | 182 views::ButtonListener* listener) |
| 182 : CustomButton(listener), | 183 : CustomButton(listener), |
| 183 model_(model), | 184 model_(model), |
| 184 list_model_view_(list_model_view), | 185 list_model_view_(list_model_view), |
| 185 icon_(new StaticImageView), | 186 icon_(new StaticImageView), |
| 186 title_(new DropShadowLabel), | 187 title_(new DropShadowLabel), |
| 187 selected_(false), | 188 selected_(false), |
| 188 ALLOW_THIS_IN_INITIALIZER_LIST(apply_shadow_factory_(this)) { | 189 ALLOW_THIS_IN_INITIALIZER_LIST(apply_shadow_factory_(this)) { |
| 189 title_->SetBackgroundColor(0); | 190 title_->SetBackgroundColor(0); |
| 190 | 191 |
| 191 if (internal::AppList::UseAppListV2()) { | 192 if (list_model_view_->fixed_layout()) { |
| 192 title_->SetEnabledColor(kTitleColorV2); | 193 title_->SetEnabledColor(kTitleColorV2); |
| 193 } else { | 194 } else { |
| 194 title_->SetEnabledColor(kTitleColor); | 195 title_->SetEnabledColor(kTitleColor); |
| 195 const gfx::ShadowValue kTitleShadows[] = { | 196 const gfx::ShadowValue kTitleShadows[] = { |
| 196 gfx::ShadowValue(gfx::Point(0, 0), 1, SkColorSetARGB(0x66, 0, 0, 0)), | 197 gfx::ShadowValue(gfx::Point(0, 0), 1, SkColorSetARGB(0x66, 0, 0, 0)), |
| 197 gfx::ShadowValue(gfx::Point(0, 0), 10, SkColorSetARGB(0x66, 0, 0, 0)), | 198 gfx::ShadowValue(gfx::Point(0, 0), 10, SkColorSetARGB(0x66, 0, 0, 0)), |
| 198 gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x66, 0, 0, 0)), | 199 gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x66, 0, 0, 0)), |
| 199 gfx::ShadowValue(gfx::Point(0, 2), 4, SkColorSetARGB(0x66, 0, 0, 0)), | 200 gfx::ShadowValue(gfx::Point(0, 2), 4, SkColorSetARGB(0x66, 0, 0, 0)), |
| 200 }; | 201 }; |
| 201 title_->SetTextShadows(arraysize(kTitleShadows), kTitleShadows); | 202 title_->SetTextShadows(arraysize(kTitleShadows), kTitleShadows); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 394 |
| 394 void AppListItemView::StateChanged() { | 395 void AppListItemView::StateChanged() { |
| 395 if (state() == BS_HOT || state() == BS_PUSHED) { | 396 if (state() == BS_HOT || state() == BS_PUSHED) { |
| 396 list_model_view_->SetSelectedItem(this); | 397 list_model_view_->SetSelectedItem(this); |
| 397 } else { | 398 } else { |
| 398 list_model_view_->ClearSelectedItem(this); | 399 list_model_view_->ClearSelectedItem(this); |
| 399 model_->SetHighlighted(false); | 400 model_->SetHighlighted(false); |
| 400 } | 401 } |
| 401 } | 402 } |
| 402 | 403 |
| 403 } // namespace ash | 404 } // namespace app_list |
| OLD | NEW |