| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace app_list { | 27 namespace app_list { |
| 28 | 28 |
| 29 class AppListItemModel; | 29 class AppListItemModel; |
| 30 class AppsGridView; | 30 class AppsGridView; |
| 31 class DropShadowLabel; | 31 class DropShadowLabel; |
| 32 | 32 |
| 33 class APP_LIST_EXPORT AppListItemView : public views::CustomButton, | 33 class APP_LIST_EXPORT AppListItemView : public views::CustomButton, |
| 34 public views::ContextMenuController, | 34 public views::ContextMenuController, |
| 35 public AppListItemModelObserver { | 35 public AppListItemModelObserver { |
| 36 public: | 36 public: |
| 37 // Internal class name. |
| 38 static const char kViewClassName[]; |
| 39 |
| 37 AppListItemView(AppsGridView* apps_grid_view, | 40 AppListItemView(AppsGridView* apps_grid_view, |
| 38 AppListItemModel* model, | 41 AppListItemModel* model, |
| 39 views::ButtonListener* listener); | 42 views::ButtonListener* listener); |
| 40 virtual ~AppListItemView(); | 43 virtual ~AppListItemView(); |
| 41 | 44 |
| 42 static gfx::Size GetPreferredSizeForIconSize(const gfx::Size& icon_size); | |
| 43 | |
| 44 // For testing. Testing calls this function to set minimum title width in | |
| 45 // pixels to get rid dependency on default font width. | |
| 46 static void SetMinTitleWidth(int width); | |
| 47 | |
| 48 void SetSelected(bool selected); | |
| 49 bool selected() const { | |
| 50 return selected_; | |
| 51 } | |
| 52 | |
| 53 void SetIconSize(const gfx::Size& size); | 45 void SetIconSize(const gfx::Size& size); |
| 54 | 46 |
| 55 AppListItemModel* model() const { | 47 AppListItemModel* model() const { return model_; } |
| 56 return model_; | |
| 57 } | |
| 58 | |
| 59 // Internal class name. | |
| 60 static const char kViewClassName[]; | |
| 61 | 48 |
| 62 private: | 49 private: |
| 63 class IconOperation; | 50 class IconOperation; |
| 64 | 51 |
| 65 // Returns true for v2 UI. | |
| 66 bool IsV2() const; | |
| 67 | |
| 68 // Get icon from model and schedule background processing. | 52 // Get icon from model and schedule background processing. |
| 69 void UpdateIcon(); | 53 void UpdateIcon(); |
| 70 | 54 |
| 71 // Cancel pending icon operation and reply callback. | 55 // Cancel pending icon operation and reply callback. |
| 72 void CancelPendingIconOperation(); | 56 void CancelPendingIconOperation(); |
| 73 | 57 |
| 74 // Reply callback from background shadow generation. |op| is the finished | 58 // Reply callback from background shadow generation. |op| is the finished |
| 75 // operation and holds the result image. | 59 // operation and holds the result image. |
| 76 void ApplyShadow(scoped_refptr<IconOperation> op); | 60 void ApplyShadow(scoped_refptr<IconOperation> op); |
| 77 | 61 |
| 78 // AppListItemModelObserver overrides: | 62 // AppListItemModelObserver overrides: |
| 79 virtual void ItemIconChanged() OVERRIDE; | 63 virtual void ItemIconChanged() OVERRIDE; |
| 80 virtual void ItemTitleChanged() OVERRIDE; | 64 virtual void ItemTitleChanged() OVERRIDE; |
| 81 virtual void ItemHighlightedChanged() OVERRIDE; | 65 virtual void ItemHighlightedChanged() OVERRIDE; |
| 82 | 66 |
| 83 // views::View overrides: | 67 // views::View overrides: |
| 84 virtual std::string GetClassName() const OVERRIDE; | 68 virtual std::string GetClassName() const OVERRIDE; |
| 85 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 86 virtual void Layout() OVERRIDE; | 69 virtual void Layout() OVERRIDE; |
| 87 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 70 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 88 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 71 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 89 | 72 |
| 90 // views::ContextMenuController overrides: | 73 // views::ContextMenuController overrides: |
| 91 virtual void ShowContextMenuForView(views::View* source, | 74 virtual void ShowContextMenuForView(views::View* source, |
| 92 const gfx::Point& point) OVERRIDE; | 75 const gfx::Point& point) OVERRIDE; |
| 93 | 76 |
| 94 // views::CustomButton overrides: | 77 // views::CustomButton overrides: |
| 95 virtual void StateChanged() OVERRIDE; | 78 virtual void StateChanged() OVERRIDE; |
| 96 | 79 |
| 97 AppListItemModel* model_; | 80 AppListItemModel* model_; |
| 98 | 81 |
| 99 AppsGridView* apps_grid_view_; | 82 AppsGridView* apps_grid_view_; |
| 100 views::ImageView* icon_; | 83 views::ImageView* icon_; |
| 101 DropShadowLabel* title_; | 84 DropShadowLabel* title_; |
| 102 | 85 |
| 103 scoped_ptr<views::MenuRunner> context_menu_runner_; | 86 scoped_ptr<views::MenuRunner> context_menu_runner_; |
| 104 | 87 |
| 105 gfx::Size icon_size_; | 88 gfx::Size icon_size_; |
| 106 bool selected_; | |
| 107 | 89 |
| 108 scoped_refptr<IconOperation> icon_op_; | 90 scoped_refptr<IconOperation> icon_op_; |
| 109 base::WeakPtrFactory<AppListItemView> apply_shadow_factory_; | 91 base::WeakPtrFactory<AppListItemView> apply_shadow_factory_; |
| 110 gfx::ShadowValues icon_shadows_; | 92 gfx::ShadowValues icon_shadows_; |
| 111 | 93 |
| 112 DISALLOW_COPY_AND_ASSIGN(AppListItemView); | 94 DISALLOW_COPY_AND_ASSIGN(AppListItemView); |
| 113 }; | 95 }; |
| 114 | 96 |
| 115 } // namespace app_list | 97 } // namespace app_list |
| 116 | 98 |
| 117 #endif // UI_APP_LIST_APP_LIST_ITEM_VIEW_H_ | 99 #endif // UI_APP_LIST_APP_LIST_ITEM_VIEW_H_ |
| OLD | NEW |