Correct blacklist entry message
[chromium-blink-merge.git] / ui / app_list / views / app_list_item_view.h
blob08fe244297b6d1e0a37b504f1b39971e7fdc9978
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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_ITEM_VIEW_H_
6 #define UI_APP_LIST_VIEWS_APP_LIST_ITEM_VIEW_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/timer/timer.h"
13 #include "ui/app_list/app_list_export.h"
14 #include "ui/app_list/app_list_item_model_observer.h"
15 #include "ui/app_list/views/cached_label.h"
16 #include "ui/gfx/shadow_value.h"
17 #include "ui/views/context_menu_controller.h"
18 #include "ui/views/controls/button/custom_button.h"
20 class SkBitmap;
22 namespace views {
23 class ImageView;
24 class Label;
25 class MenuRunner;
28 namespace app_list {
30 class AppListItemModel;
31 class AppsGridView;
32 class ProgressBarView;
34 class APP_LIST_EXPORT AppListItemView : public views::CustomButton,
35 public views::ContextMenuController,
36 public AppListItemModelObserver {
37 public:
38 // Internal class name.
39 static const char kViewClassName[];
41 AppListItemView(AppsGridView* apps_grid_view, AppListItemModel* model);
42 virtual ~AppListItemView();
44 void SetIconSize(const gfx::Size& size);
46 void Prerender();
48 void CancelContextMenu();
50 AppListItemModel* model() const { return model_; }
52 const views::Label* title() const { return title_; }
54 gfx::ImageSkia GetDragImage();
56 private:
57 enum UIState {
58 UI_STATE_NORMAL, // Normal UI (icon + label)
59 UI_STATE_DRAGGING, // Dragging UI (scaled icon only)
62 // Get icon from model and schedule background processing.
63 void UpdateIcon();
65 // Update the tooltip text from the model.
66 void UpdateTooltip();
68 void SetUIState(UIState state);
70 // Sets |touch_dragging_| flag and updates UI.
71 void SetTouchDragging(bool touch_dragging);
73 // Invoked when |mouse_drag_timer_| fires to show dragging UI.
74 void OnMouseDragTimer();
76 // AppListItemModelObserver overrides:
77 virtual void ItemIconChanged() OVERRIDE;
78 virtual void ItemTitleChanged() OVERRIDE;
79 virtual void ItemHighlightedChanged() OVERRIDE;
80 virtual void ItemIsInstallingChanged() OVERRIDE;
81 virtual void ItemPercentDownloadedChanged() OVERRIDE;
83 // views::View overrides:
84 virtual const char* GetClassName() const OVERRIDE;
85 virtual void Layout() OVERRIDE;
86 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
87 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
89 // views::ContextMenuController overrides:
90 virtual void ShowContextMenuForView(views::View* source,
91 const gfx::Point& point,
92 ui::MenuSourceType source_type) OVERRIDE;
94 // views::CustomButton overrides:
95 virtual void StateChanged() OVERRIDE;
96 virtual bool ShouldEnterPushedState(const ui::Event& event) OVERRIDE;
98 // views::View overrides:
99 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
100 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
101 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
102 virtual void OnMouseCaptureLost() OVERRIDE;
103 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
105 // ui::EventHandler overrides:
106 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
108 AppListItemModel* model_; // Owned by AppListModel.
110 AppsGridView* apps_grid_view_; // Owned by views hierarchy.
111 views::ImageView* icon_; // Owned by views hierarchy.
112 CachedLabel* title_; // Owned by views hierarchy.
113 ProgressBarView* progress_bar_; // Owned by views hierarchy.
115 scoped_ptr<views::MenuRunner> context_menu_runner_;
117 gfx::Size icon_size_;
118 gfx::ShadowValues icon_shadows_;
120 UIState ui_state_;
122 // True if scroll gestures should contribute to dragging.
123 bool touch_dragging_;
125 // A timer to defer showing drag UI when mouse is pressed.
126 base::OneShotTimer<AppListItemView> mouse_drag_timer_;
128 DISALLOW_COPY_AND_ASSIGN(AppListItemView);
131 } // namespace app_list
133 #endif // UI_APP_LIST_VIEWS_APP_LIST_ITEM_VIEW_H_