| 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/app_list_item_view.h" | 5 #include "ui/app_list/app_list_item_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/synchronization/cancellation_flag.h" | 11 #include "base/synchronization/cancellation_flag.h" |
| 12 #include "base/threading/worker_pool.h" | 12 #include "base/threading/worker_pool.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "skia/ext/image_operations.h" |
| 14 #include "ui/app_list/app_list_item_model.h" | 15 #include "ui/app_list/app_list_item_model.h" |
| 15 #include "ui/app_list/apps_grid_view.h" | 16 #include "ui/app_list/apps_grid_view.h" |
| 16 #include "ui/app_list/drop_shadow_label.h" | 17 #include "ui/app_list/drop_shadow_label.h" |
| 17 #include "ui/app_list/icon_cache.h" | 18 #include "ui/app_list/icon_cache.h" |
| 18 #include "ui/base/accessibility/accessible_view_state.h" | 19 #include "ui/base/accessibility/accessible_view_state.h" |
| 19 #include "ui/base/animation/throb_animation.h" | 20 #include "ui/base/animation/throb_animation.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/font.h" | 23 #include "ui/gfx/font.h" |
| 23 #include "ui/gfx/shadow_value.h" | 24 #include "ui/gfx/shadow_value.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 120 |
| 120 static void Run(scoped_refptr<IconOperation> op) { | 121 static void Run(scoped_refptr<IconOperation> op) { |
| 121 op->ResizeAndGenerateShadow(); | 122 op->ResizeAndGenerateShadow(); |
| 122 } | 123 } |
| 123 | 124 |
| 124 // Padding space around icon to contain its shadow. Note it should be at least | 125 // Padding space around icon to contain its shadow. Note it should be at least |
| 125 // the max size of shadow radius + shadow offset in shadow generation code. | 126 // the max size of shadow radius + shadow offset in shadow generation code. |
| 126 static const int kShadowPadding = 15; | 127 static const int kShadowPadding = 15; |
| 127 | 128 |
| 128 void ResizeAndGenerateShadow() { | 129 void ResizeAndGenerateShadow() { |
| 129 // If you change shadow radius and shadow offset, please also update | 130 if (cancel_flag_.IsSet()) |
| 130 // kShadowPaddingAbove. | 131 return; |
| 131 const SkColor kShadowColor[] = { | 132 |
| 132 SkColorSetARGB(0xCC, 0, 0, 0), | 133 if (size_ != gfx::Size(bitmap_.width(), bitmap_.height())) { |
| 133 SkColorSetARGB(0x33, 0, 0, 0), | 134 bitmap_ = skia::ImageOperations::Resize(bitmap_, |
| 134 SkColorSetARGB(0x4C, 0, 0, 0), | 135 skia::ImageOperations::RESIZE_BEST, size_.width(), size_.height()); |
| 135 }; | 136 } |
| 136 const gfx::Point kShadowOffset[] = { | |
| 137 gfx::Point(0, 0), | |
| 138 gfx::Point(0, 4), | |
| 139 gfx::Point(0, 5), | |
| 140 }; | |
| 141 const SkScalar kShadowRadius[] = { | |
| 142 SkIntToScalar(2), | |
| 143 SkIntToScalar(4), | |
| 144 SkIntToScalar(10), | |
| 145 }; | |
| 146 | 137 |
| 147 if (cancel_flag_.IsSet()) | 138 if (cancel_flag_.IsSet()) |
| 148 return; | 139 return; |
| 149 | 140 |
| 150 if (size_ != gfx::Size(bitmap_.width(), bitmap_.height())) | 141 // If you change shadow radius and shadow offset, please also update |
| 151 bitmap_ = SkBitmapOperations::CreateResizedBitmap(bitmap_, size_); | 142 // kShadowPaddingAbove. |
| 152 | 143 const gfx::ShadowValue kShadows[] = { |
| 153 if (cancel_flag_.IsSet()) | 144 gfx::ShadowValue(gfx::Point(0, 0), 2, SkColorSetARGB(0xCC, 0, 0, 0)), |
| 154 return; | 145 gfx::ShadowValue(gfx::Point(0, 4), 4, SkColorSetARGB(0x33, 0, 0, 0)), |
| 146 gfx::ShadowValue(gfx::Point(0, 5), 10, SkColorSetARGB(0x4C, 0, 0, 0)), |
| 147 }; |
| 155 | 148 |
| 156 bitmap_ = SkBitmapOperations::CreateDropShadow( | 149 bitmap_ = SkBitmapOperations::CreateDropShadow( |
| 157 bitmap_, | 150 bitmap_, gfx::ShadowValues(kShadows, kShadows + arraysize(kShadows))); |
| 158 arraysize(kShadowColor), | |
| 159 kShadowColor, | |
| 160 kShadowOffset, | |
| 161 kShadowRadius); | |
| 162 } | 151 } |
| 163 | 152 |
| 164 void Cancel() { | 153 void Cancel() { |
| 165 cancel_flag_.Set(); | 154 cancel_flag_.Set(); |
| 166 } | 155 } |
| 167 | 156 |
| 168 const SkBitmap& bitmap() const { | 157 const SkBitmap& bitmap() const { |
| 169 return bitmap_; | 158 return bitmap_; |
| 170 } | 159 } |
| 171 | 160 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 void AppListItemView::StateChanged() { | 396 void AppListItemView::StateChanged() { |
| 408 if (state() == BS_HOT || state() == BS_PUSHED) { | 397 if (state() == BS_HOT || state() == BS_PUSHED) { |
| 409 list_model_view_->SetSelectedItem(this); | 398 list_model_view_->SetSelectedItem(this); |
| 410 } else { | 399 } else { |
| 411 list_model_view_->ClearSelectedItem(this); | 400 list_model_view_->ClearSelectedItem(this); |
| 412 model_->SetHighlighted(false); | 401 model_->SetHighlighted(false); |
| 413 } | 402 } |
| 414 } | 403 } |
| 415 | 404 |
| 416 } // namespace app_list | 405 } // namespace app_list |
| OLD | NEW |