| 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 "ui/gfx/shadow_value.h" | 8 #include "ui/gfx/shadow_value.h" |
| 9 #include "ui/views/controls/button/custom_button.h" | 9 #include "ui/views/controls/button/custom_button.h" |
| 10 #include "ui/views/controls/image_view.h" | 10 #include "ui/views/controls/image_view.h" |
| 11 | 11 |
| 12 namespace ash { | 12 namespace ash { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 class LauncherButtonHost; | 15 class LauncherButtonHost; |
| 16 class ShelfLayoutManager; |
| 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 STATE_FOCUSED = 1 << 4, |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 virtual ~LauncherButton(); | 38 virtual ~LauncherButton(); |
| 38 | 39 |
| 39 // Called to create an instance of a LauncherButton. | 40 // Called to create an instance of a LauncherButton. |
| 40 static LauncherButton* Create(views::ButtonListener* listener, | 41 static LauncherButton* Create(views::ButtonListener* listener, |
| 41 LauncherButtonHost* host); | 42 LauncherButtonHost* host, |
| 43 ShelfLayoutManager* shelf_layout_manager); |
| 42 | 44 |
| 43 // Sets the image to display for this entry. | 45 // Sets the image to display for this entry. |
| 44 void SetImage(const gfx::ImageSkia& image); | 46 void SetImage(const gfx::ImageSkia& image); |
| 45 | 47 |
| 46 // |state| is or'd into the current state. | 48 // |state| is or'd into the current state. |
| 47 void AddState(State state); | 49 void AddState(State state); |
| 48 void ClearState(State state); | 50 void ClearState(State state); |
| 49 int state() const { return state_; } | 51 int state() const { return state_; } |
| 50 | 52 |
| 51 // Returns the bounds of the icon. | 53 // Returns the bounds of the icon. |
| 52 gfx::Rect GetIconBounds() const; | 54 gfx::Rect GetIconBounds() const; |
| 53 | 55 |
| 54 protected: | 56 protected: |
| 55 LauncherButton(views::ButtonListener* listener, LauncherButtonHost* host); | 57 LauncherButton(views::ButtonListener* listener, |
| 58 LauncherButtonHost* host, |
| 59 ShelfLayoutManager* shelf_layout_manager); |
| 56 | 60 |
| 57 // Class that draws the icon part of a button, so it can be animated | 61 // Class that draws the icon part of a button, so it can be animated |
| 58 // independently of the rest. This can be subclassed to provide a custom | 62 // independently of the rest. This can be subclassed to provide a custom |
| 59 // implementation, by overriding CreateIconView(). | 63 // implementation, by overriding CreateIconView(). |
| 60 class IconView : public views::ImageView { | 64 class IconView : public views::ImageView { |
| 61 public: | 65 public: |
| 62 IconView(); | 66 IconView(); |
| 63 virtual ~IconView(); | 67 virtual ~IconView(); |
| 64 | 68 |
| 65 void set_icon_size(int icon_size) { icon_size_ = icon_size; } | 69 void set_icon_size(int icon_size) { icon_size_ = icon_size; } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 void UpdateState(); | 118 void UpdateState(); |
| 115 | 119 |
| 116 LauncherButtonHost* host_; | 120 LauncherButtonHost* host_; |
| 117 IconView* icon_view_; | 121 IconView* icon_view_; |
| 118 // 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. |
| 119 BarView* bar_; | 123 BarView* bar_; |
| 120 // 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 |
| 121 // together. | 125 // together. |
| 122 int state_; | 126 int state_; |
| 123 | 127 |
| 128 ShelfLayoutManager* shelf_layout_manager_; |
| 129 |
| 124 gfx::ShadowValues icon_shadows_; | 130 gfx::ShadowValues icon_shadows_; |
| 125 | 131 |
| 126 DISALLOW_COPY_AND_ASSIGN(LauncherButton); | 132 DISALLOW_COPY_AND_ASSIGN(LauncherButton); |
| 127 }; | 133 }; |
| 128 | 134 |
| 129 } // namespace internal | 135 } // namespace internal |
| 130 } // namespace ash | 136 } // namespace ash |
| 131 | 137 |
| 132 #endif // ASH_LAUNCHER_LAUNCHER_BUTTON_H_ | 138 #endif // ASH_LAUNCHER_LAUNCHER_BUTTON_H_ |
| OLD | NEW |