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 ASH_LAUNCHER_LAUNCHER_BUTTON_H_ | 5 #ifndef ASH_LAUNCHER_LAUNCHER_BUTTON_H_ |
6 #define ASH_LAUNCHER_LAUNCHER_BUTTON_H_ | 6 #define ASH_LAUNCHER_LAUNCHER_BUTTON_H_ |
7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" |
8 #include "ui/gfx/shadow_value.h" | 9 #include "ui/gfx/shadow_value.h" |
9 #include "ui/views/controls/button/custom_button.h" | 10 #include "ui/views/controls/button/custom_button.h" |
10 #include "ui/views/controls/image_view.h" | 11 #include "ui/views/controls/image_view.h" |
11 | 12 |
12 namespace ash { | 13 namespace ash { |
13 namespace internal { | 14 namespace internal { |
14 | 15 |
15 class LauncherButtonHost; | 16 class LauncherButtonHost; |
16 | 17 |
17 // Button used for items on the launcher, except for the AppList. | 18 // Button used for items on the launcher, except for the AppList. |
18 class LauncherButton : public views::CustomButton { | 19 class LauncherButton : public views::CustomButton { |
19 public: | 20 public: |
20 // Used to indicate the current state of the button. | 21 // Used to indicate the current state of the button. |
21 enum State { | 22 enum State { |
22 // Nothing special. Usually represents an app shortcut item with no running | 23 // Nothing special. Usually represents an app shortcut item with no running |
23 // instance. | 24 // instance. |
24 STATE_NORMAL = 0, | 25 STATE_NORMAL = 0, |
25 // Button has mouse hovering on it. | 26 // Button has mouse hovering on it. |
26 STATE_HOVERED = 1 << 0, | 27 STATE_HOVERED = 1 << 0, |
27 // Underlying LauncherItem has a running instance. | 28 // Underlying LauncherItem has a running instance. |
28 // e.g. A TYPE_TABBED item that has a window. | 29 // e.g. A TYPE_TABBED item that has a window. |
29 STATE_RUNNING = 1 << 1, | 30 STATE_RUNNING = 1 << 1, |
30 // Underlying LauncherItem is active (i.e. has focus). | 31 // Underlying LauncherItem is active (i.e. has focus). |
31 STATE_ACTIVE = 1 << 2, | 32 STATE_ACTIVE = 1 << 2, |
32 // Underlying LauncherItem needs user's attention. | 33 // Underlying LauncherItem needs user's attention. |
33 STATE_ATTENTION = 1 << 3, | 34 STATE_ATTENTION = 1 << 3, |
34 STATE_FOCUSED = 1 << 4, | 35 // Underlying LauncherItem has pending operations. |
| 36 // e.g. A TYPE_APP_SHORTCUT item whose corresponding app is being |
| 37 // installed. |
| 38 STATE_PENDING = 1 << 4, |
| 39 STATE_FOCUSED = 1 << 5, |
35 }; | 40 }; |
36 | 41 |
37 virtual ~LauncherButton(); | 42 virtual ~LauncherButton(); |
38 | 43 |
39 // Called to create an instance of a LauncherButton. | 44 // Called to create an instance of a LauncherButton. |
40 static LauncherButton* Create(views::ButtonListener* listener, | 45 static LauncherButton* Create(views::ButtonListener* listener, |
41 LauncherButtonHost* host); | 46 LauncherButtonHost* host); |
42 | 47 |
43 // Sets the image to display for this entry. | 48 // Sets the image to display for this entry. |
44 void SetImage(const gfx::ImageSkia& image); | 49 void SetImage(const gfx::ImageSkia& image); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 void SetShadowedImage(const gfx::ImageSkia& bitmap); | 100 void SetShadowedImage(const gfx::ImageSkia& bitmap); |
96 // Override for custom initialization. | 101 // Override for custom initialization. |
97 virtual void Init(); | 102 virtual void Init(); |
98 // Override to subclass IconView. | 103 // Override to subclass IconView. |
99 virtual IconView* CreateIconView(); | 104 virtual IconView* CreateIconView(); |
100 IconView* icon_view() const { return icon_view_; } | 105 IconView* icon_view() const { return icon_view_; } |
101 LauncherButtonHost* host() const { return host_; } | 106 LauncherButtonHost* host() const { return host_; } |
102 | 107 |
103 private: | 108 private: |
104 class BarView; | 109 class BarView; |
| 110 class IconPulseAnimation; |
105 | 111 |
106 // Returns true if the shelf is horizontal. If this returns false the shelf is | 112 // Returns true if the shelf is horizontal. If this returns false the shelf is |
107 // vertical. | 113 // vertical. |
108 bool IsShelfHorizontal() const; | 114 bool IsShelfHorizontal() const; |
109 | 115 |
110 // Updates the parts of the button to reflect the current |state_| and | 116 // Updates the parts of the button to reflect the current |state_| and |
111 // alignment. This may add or remove views, layout and paint. | 117 // alignment. This may add or remove views, layout and paint. |
112 void UpdateState(); | 118 void UpdateState(); |
113 | 119 |
114 LauncherButtonHost* host_; | 120 LauncherButtonHost* host_; |
115 IconView* icon_view_; | 121 IconView* icon_view_; |
116 // Draws a bar underneath the image to represent the state of the application. | 122 // Draws a bar underneath the image to represent the state of the application. |
117 BarView* bar_; | 123 BarView* bar_; |
118 // The current state of the application, multiple values of AppState are or'd | 124 // The current state of the application, multiple values of AppState are or'd |
119 // together. | 125 // together. |
120 int state_; | 126 int state_; |
121 | 127 |
| 128 // Runs a pulse animation for |icon_view_|. It is created when button state |
| 129 // has a STATE_PENDING bit and destroyed when that bit is clear. |
| 130 scoped_ptr<IconPulseAnimation> icon_pulse_animation_; |
| 131 |
122 gfx::ShadowValues icon_shadows_; | 132 gfx::ShadowValues icon_shadows_; |
123 | 133 |
124 DISALLOW_COPY_AND_ASSIGN(LauncherButton); | 134 DISALLOW_COPY_AND_ASSIGN(LauncherButton); |
125 }; | 135 }; |
126 | 136 |
127 } // namespace internal | 137 } // namespace internal |
128 } // namespace ash | 138 } // namespace ash |
129 | 139 |
130 #endif // ASH_LAUNCHER_LAUNCHER_BUTTON_H_ | 140 #endif // ASH_LAUNCHER_LAUNCHER_BUTTON_H_ |
OLD | NEW |