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