| 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_VIEWS_APP_LIST_ITEM_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_ITEM_VIEW_H_ |
| 6 #define UI_APP_LIST_VIEWS_APP_LIST_ITEM_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_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/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "ui/app_list/app_list_export.h" | 13 #include "ui/app_list/app_list_export.h" |
| 14 #include "ui/app_list/app_list_item_observer.h" | 14 #include "ui/app_list/app_list_item_observer.h" |
| 15 #include "ui/app_list/views/cached_label.h" | |
| 16 #include "ui/gfx/shadow_value.h" | 15 #include "ui/gfx/shadow_value.h" |
| 17 #include "ui/views/context_menu_controller.h" | 16 #include "ui/views/context_menu_controller.h" |
| 18 #include "ui/views/controls/button/custom_button.h" | 17 #include "ui/views/controls/button/custom_button.h" |
| 19 | 18 |
| 20 class SkBitmap; | 19 class SkBitmap; |
| 21 | 20 |
| 22 namespace views { | 21 namespace views { |
| 23 class ImageView; | 22 class ImageView; |
| 24 class Label; | 23 class Label; |
| 25 class MenuRunner; | 24 class MenuRunner; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 public AppListItemObserver { | 35 public AppListItemObserver { |
| 37 public: | 36 public: |
| 38 // Internal class name. | 37 // Internal class name. |
| 39 static const char kViewClassName[]; | 38 static const char kViewClassName[]; |
| 40 | 39 |
| 41 AppListItemView(AppsGridView* apps_grid_view, AppListItem* item); | 40 AppListItemView(AppsGridView* apps_grid_view, AppListItem* item); |
| 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 void Prerender(); | |
| 47 | |
| 48 void CancelContextMenu(); | 45 void CancelContextMenu(); |
| 49 | 46 |
| 50 gfx::ImageSkia GetDragImage(); | 47 gfx::ImageSkia GetDragImage(); |
| 51 void OnDragEnded(); | 48 void OnDragEnded(); |
| 52 gfx::Point GetDragImageOffset(); | 49 gfx::Point GetDragImageOffset(); |
| 53 | 50 |
| 54 void SetAsAttemptedFolderTarget(bool is_target_folder); | 51 void SetAsAttemptedFolderTarget(bool is_target_folder); |
| 55 | 52 |
| 56 AppListItem* item() const { return item_; } | 53 AppListItem* item() const { return item_; } |
| 57 | 54 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 85 void UpdateTooltip(); | 82 void UpdateTooltip(); |
| 86 | 83 |
| 87 void SetUIState(UIState state); | 84 void SetUIState(UIState state); |
| 88 | 85 |
| 89 // Sets |touch_dragging_| flag and updates UI. | 86 // Sets |touch_dragging_| flag and updates UI. |
| 90 void SetTouchDragging(bool touch_dragging); | 87 void SetTouchDragging(bool touch_dragging); |
| 91 | 88 |
| 92 // Invoked when |mouse_drag_timer_| fires to show dragging UI. | 89 // Invoked when |mouse_drag_timer_| fires to show dragging UI. |
| 93 void OnMouseDragTimer(); | 90 void OnMouseDragTimer(); |
| 94 | 91 |
| 95 // If the item is not in a folder, not highlighted, not being dragged, and not | |
| 96 // having something dropped onto it, enables subpixel AA for the title. | |
| 97 void SetTitleSubpixelAA(); | |
| 98 | |
| 99 // AppListItemObserver overrides: | 92 // AppListItemObserver overrides: |
| 100 virtual void ItemIconChanged() OVERRIDE; | 93 virtual void ItemIconChanged() OVERRIDE; |
| 101 virtual void ItemNameChanged() OVERRIDE; | 94 virtual void ItemNameChanged() OVERRIDE; |
| 102 virtual void ItemHighlightedChanged() OVERRIDE; | 95 virtual void ItemHighlightedChanged() OVERRIDE; |
| 103 virtual void ItemIsInstallingChanged() OVERRIDE; | 96 virtual void ItemIsInstallingChanged() OVERRIDE; |
| 104 virtual void ItemPercentDownloadedChanged() OVERRIDE; | 97 virtual void ItemPercentDownloadedChanged() OVERRIDE; |
| 105 | 98 |
| 106 // views::View overrides: | 99 // views::View overrides: |
| 107 virtual const char* GetClassName() const OVERRIDE; | 100 virtual const char* GetClassName() const OVERRIDE; |
| 108 virtual void Layout() OVERRIDE; | 101 virtual void Layout() OVERRIDE; |
| 109 virtual void SchedulePaintInRect(const gfx::Rect& r) OVERRIDE; | |
| 110 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 102 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 111 | 103 |
| 112 // views::ContextMenuController overrides: | 104 // views::ContextMenuController overrides: |
| 113 virtual void ShowContextMenuForView(views::View* source, | 105 virtual void ShowContextMenuForView(views::View* source, |
| 114 const gfx::Point& point, | 106 const gfx::Point& point, |
| 115 ui::MenuSourceType source_type) OVERRIDE; | 107 ui::MenuSourceType source_type) OVERRIDE; |
| 116 | 108 |
| 117 // views::CustomButton overrides: | 109 // views::CustomButton overrides: |
| 118 virtual void StateChanged() OVERRIDE; | 110 virtual void StateChanged() OVERRIDE; |
| 119 virtual bool ShouldEnterPushedState(const ui::Event& event) OVERRIDE; | 111 virtual bool ShouldEnterPushedState(const ui::Event& event) OVERRIDE; |
| 120 | 112 |
| 121 // views::View overrides: | 113 // views::View overrides: |
| 122 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 114 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
| 123 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 115 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 124 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 116 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| 125 virtual void OnMouseCaptureLost() OVERRIDE; | 117 virtual void OnMouseCaptureLost() OVERRIDE; |
| 126 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; | 118 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
| 127 | 119 |
| 128 // ui::EventHandler overrides: | 120 // ui::EventHandler overrides: |
| 129 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 121 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 130 | 122 |
| 131 AppListItem* item_; // Owned by AppListModel. | 123 AppListItem* item_; // Owned by AppListModel. |
| 132 | 124 |
| 133 AppsGridView* apps_grid_view_; // Owned by views hierarchy. | 125 AppsGridView* apps_grid_view_; // Owned by views hierarchy. |
| 134 views::ImageView* icon_; // Owned by views hierarchy. | 126 views::ImageView* icon_; // Owned by views hierarchy. |
| 135 CachedLabel* title_; // Owned by views hierarchy. | 127 views::Label* title_; // Owned by views hierarchy. |
| 136 ProgressBarView* progress_bar_; // Owned by views hierarchy. | 128 ProgressBarView* progress_bar_; // Owned by views hierarchy. |
| 137 | 129 |
| 138 scoped_ptr<views::MenuRunner> context_menu_runner_; | 130 scoped_ptr<views::MenuRunner> context_menu_runner_; |
| 139 | 131 |
| 140 gfx::Size icon_size_; | 132 gfx::Size icon_size_; |
| 141 gfx::ShadowValues icon_shadows_; | 133 gfx::ShadowValues icon_shadows_; |
| 142 | 134 |
| 143 UIState ui_state_; | 135 UIState ui_state_; |
| 144 | 136 |
| 145 // True if scroll gestures should contribute to dragging. | 137 // True if scroll gestures should contribute to dragging. |
| 146 bool touch_dragging_; | 138 bool touch_dragging_; |
| 147 | 139 |
| 148 // A timer to defer showing drag UI when mouse is pressed. | 140 // A timer to defer showing drag UI when mouse is pressed. |
| 149 base::OneShotTimer<AppListItemView> mouse_drag_timer_; | 141 base::OneShotTimer<AppListItemView> mouse_drag_timer_; |
| 150 | 142 |
| 151 DISALLOW_COPY_AND_ASSIGN(AppListItemView); | 143 DISALLOW_COPY_AND_ASSIGN(AppListItemView); |
| 152 }; | 144 }; |
| 153 | 145 |
| 154 } // namespace app_list | 146 } // namespace app_list |
| 155 | 147 |
| 156 #endif // UI_APP_LIST_VIEWS_APP_LIST_ITEM_VIEW_H_ | 148 #endif // UI_APP_LIST_VIEWS_APP_LIST_ITEM_VIEW_H_ |
| OLD | NEW |