| 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 #ifndef UI_APP_LIST_APP_LIST_ITEM_VIEW_H_ | 5 #ifndef UI_APP_LIST_APP_LIST_ITEM_VIEW_H_ |
| 6 #define UI_APP_LIST_APP_LIST_ITEM_VIEW_H_ | 6 #define UI_APP_LIST_APP_LIST_ITEM_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "ui/app_list/app_list_export.h" | 12 #include "ui/app_list/app_list_export.h" |
| 14 #include "ui/app_list/app_list_item_model_observer.h" | 13 #include "ui/app_list/app_list_item_model_observer.h" |
| 15 #include "ui/gfx/shadow_value.h" | 14 #include "ui/gfx/shadow_value.h" |
| 16 #include "ui/views/context_menu_controller.h" | 15 #include "ui/views/context_menu_controller.h" |
| 17 #include "ui/views/controls/button/custom_button.h" | 16 #include "ui/views/controls/button/custom_button.h" |
| 18 | 17 |
| 19 class SkBitmap; | 18 class SkBitmap; |
| 20 | 19 |
| 21 namespace views { | 20 namespace views { |
| 22 class ImageView; | 21 class ImageView; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 AppListItemView(AppsGridView* apps_grid_view, | 38 AppListItemView(AppsGridView* apps_grid_view, |
| 40 AppListItemModel* model, | 39 AppListItemModel* model, |
| 41 views::ButtonListener* listener); | 40 views::ButtonListener* listener); |
| 42 virtual ~AppListItemView(); | 41 virtual ~AppListItemView(); |
| 43 | 42 |
| 44 void SetIconSize(const gfx::Size& size); | 43 void SetIconSize(const gfx::Size& size); |
| 45 | 44 |
| 46 AppListItemModel* model() const { return model_; } | 45 AppListItemModel* model() const { return model_; } |
| 47 | 46 |
| 48 private: | 47 private: |
| 49 class IconOperation; | |
| 50 | |
| 51 // Get icon from model and schedule background processing. | 48 // Get icon from model and schedule background processing. |
| 52 void UpdateIcon(); | 49 void UpdateIcon(); |
| 53 | 50 |
| 54 // Cancel pending icon operation and reply callback. | |
| 55 void CancelPendingIconOperation(); | |
| 56 | |
| 57 // Reply callback from background shadow generation. |op| is the finished | |
| 58 // operation and holds the result image. | |
| 59 void ApplyShadow(scoped_refptr<IconOperation> op); | |
| 60 | |
| 61 // AppListItemModelObserver overrides: | 51 // AppListItemModelObserver overrides: |
| 62 virtual void ItemIconChanged() OVERRIDE; | 52 virtual void ItemIconChanged() OVERRIDE; |
| 63 virtual void ItemTitleChanged() OVERRIDE; | 53 virtual void ItemTitleChanged() OVERRIDE; |
| 64 virtual void ItemHighlightedChanged() OVERRIDE; | 54 virtual void ItemHighlightedChanged() OVERRIDE; |
| 65 | 55 |
| 66 // views::View overrides: | 56 // views::View overrides: |
| 67 virtual std::string GetClassName() const OVERRIDE; | 57 virtual std::string GetClassName() const OVERRIDE; |
| 68 virtual void Layout() OVERRIDE; | 58 virtual void Layout() OVERRIDE; |
| 69 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 59 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 70 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 60 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 71 | 61 |
| 72 // views::ContextMenuController overrides: | 62 // views::ContextMenuController overrides: |
| 73 virtual void ShowContextMenuForView(views::View* source, | 63 virtual void ShowContextMenuForView(views::View* source, |
| 74 const gfx::Point& point) OVERRIDE; | 64 const gfx::Point& point) OVERRIDE; |
| 75 | 65 |
| 76 // views::CustomButton overrides: | 66 // views::CustomButton overrides: |
| 77 virtual void StateChanged() OVERRIDE; | 67 virtual void StateChanged() OVERRIDE; |
| 78 virtual bool ShouldEnterPushedState(const ui::Event& event) OVERRIDE; | 68 virtual bool ShouldEnterPushedState(const ui::Event& event) OVERRIDE; |
| 79 | 69 |
| 80 AppListItemModel* model_; // Owned by AppListModel::Apps. | 70 AppListItemModel* model_; // Owned by AppListModel::Apps. |
| 81 | 71 |
| 82 AppsGridView* apps_grid_view_; // Owned by views hierarchy. | 72 AppsGridView* apps_grid_view_; // Owned by views hierarchy. |
| 83 views::ImageView* icon_; // Owned by views hierarchy. | 73 views::ImageView* icon_; // Owned by views hierarchy. |
| 84 DropShadowLabel* title_; // Owned by views hierarchy. | 74 DropShadowLabel* title_; // Owned by views hierarchy. |
| 85 | 75 |
| 86 scoped_ptr<views::MenuRunner> context_menu_runner_; | 76 scoped_ptr<views::MenuRunner> context_menu_runner_; |
| 87 | 77 |
| 88 gfx::Size icon_size_; | 78 gfx::Size icon_size_; |
| 89 | |
| 90 scoped_refptr<IconOperation> icon_op_; | |
| 91 base::WeakPtrFactory<AppListItemView> apply_shadow_factory_; | |
| 92 gfx::ShadowValues icon_shadows_; | 79 gfx::ShadowValues icon_shadows_; |
| 93 | 80 |
| 94 DISALLOW_COPY_AND_ASSIGN(AppListItemView); | 81 DISALLOW_COPY_AND_ASSIGN(AppListItemView); |
| 95 }; | 82 }; |
| 96 | 83 |
| 97 } // namespace app_list | 84 } // namespace app_list |
| 98 | 85 |
| 99 #endif // UI_APP_LIST_APP_LIST_ITEM_VIEW_H_ | 86 #endif // UI_APP_LIST_APP_LIST_ITEM_VIEW_H_ |
| OLD | NEW |