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_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
6 #define UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "ui/base/animation/animation_delegate.h" | 9 #include "ui/base/animation/animation_delegate.h" |
10 #include "ui/base/events/event_constants.h" | 10 #include "ui/base/events/event_constants.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // part of the focus chain. Call set_focusable(true) to make it part of the | 24 // part of the focus chain. Call set_focusable(true) to make it part of the |
25 // focus chain. | 25 // focus chain. |
26 class VIEWS_EXPORT CustomButton : public Button, | 26 class VIEWS_EXPORT CustomButton : public Button, |
27 public ui::AnimationDelegate { | 27 public ui::AnimationDelegate { |
28 public: | 28 public: |
29 // The menu button's class name. | 29 // The menu button's class name. |
30 static const char kViewClassName[]; | 30 static const char kViewClassName[]; |
31 | 31 |
32 virtual ~CustomButton(); | 32 virtual ~CustomButton(); |
33 | 33 |
34 // Possible states | |
35 enum ButtonState { | |
36 STATE_NORMAL = 0, | |
37 STATE_HOVERED, | |
38 STATE_PRESSED, | |
39 STATE_DISABLED, | |
40 STATE_COUNT | |
41 }; | |
42 | |
43 // Get/sets the current display state of the button. | 34 // Get/sets the current display state of the button. |
44 ButtonState state() const { return state_; } | 35 ButtonState state() const { return state_; } |
45 void SetState(ButtonState state); | 36 void SetState(ButtonState state); |
46 | 37 |
47 // Starts throbbing. See HoverAnimation for a description of cycles_til_stop. | 38 // Starts throbbing. See HoverAnimation for a description of cycles_til_stop. |
48 void StartThrobbing(int cycles_til_stop); | 39 void StartThrobbing(int cycles_til_stop); |
49 | 40 |
50 // Stops throbbing immediately. | 41 // Stops throbbing immediately. |
51 void StopThrobbing(); | 42 void StopThrobbing(); |
52 | 43 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 142 |
152 scoped_ptr<CustomButtonStateChangedDelegate> state_changed_delegate_; | 143 scoped_ptr<CustomButtonStateChangedDelegate> state_changed_delegate_; |
153 | 144 |
154 DISALLOW_COPY_AND_ASSIGN(CustomButton); | 145 DISALLOW_COPY_AND_ASSIGN(CustomButton); |
155 }; | 146 }; |
156 | 147 |
157 // Delegate for actions taken on state changes by CustomButton. | 148 // Delegate for actions taken on state changes by CustomButton. |
158 class VIEWS_EXPORT CustomButtonStateChangedDelegate { | 149 class VIEWS_EXPORT CustomButtonStateChangedDelegate { |
159 public: | 150 public: |
160 virtual ~CustomButtonStateChangedDelegate() {} | 151 virtual ~CustomButtonStateChangedDelegate() {} |
161 virtual void StateChanged(CustomButton::ButtonState state) = 0; | 152 virtual void StateChanged(Button::ButtonState state) = 0; |
162 | 153 |
163 protected: | 154 protected: |
164 CustomButtonStateChangedDelegate() {} | 155 CustomButtonStateChangedDelegate() {} |
165 | 156 |
166 private: | 157 private: |
167 DISALLOW_COPY_AND_ASSIGN(CustomButtonStateChangedDelegate); | 158 DISALLOW_COPY_AND_ASSIGN(CustomButtonStateChangedDelegate); |
168 }; | 159 }; |
169 | 160 |
170 } // namespace views | 161 } // namespace views |
171 | 162 |
172 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 163 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
OLD | NEW |