| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 5 #ifndef VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
| 6 #define VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 6 #define VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/animation_delegate.h" | |
| 10 #include "views/controls/button/button.h" | 9 #include "views/controls/button/button.h" |
| 10 #include "ui/base/animation/animation_delegate.h" |
| 11 | 11 |
| 12 namespace ui { |
| 12 class ThrobAnimation; | 13 class ThrobAnimation; |
| 14 } |
| 13 | 15 |
| 14 namespace views { | 16 namespace views { |
| 15 | 17 |
| 16 // A button with custom rendering. The common base class of ImageButton and | 18 // A button with custom rendering. The common base class of ImageButton and |
| 17 // TextButton. | 19 // TextButton. |
| 18 // Note that this type of button is not focusable by default and will not be | 20 // Note that this type of button is not focusable by default and will not be |
| 19 // part of the focus chain. Call SetFocusable(true) to make it part of the | 21 // part of the focus chain. Call SetFocusable(true) to make it part of the |
| 20 // focus chain. | 22 // focus chain. |
| 21 class CustomButton : public Button, | 23 class CustomButton : public Button, |
| 22 public AnimationDelegate { | 24 public ui::AnimationDelegate { |
| 23 public: | 25 public: |
| 24 // The menu button's class name. | 26 // The menu button's class name. |
| 25 static const char kViewClassName[]; | 27 static const char kViewClassName[]; |
| 26 | 28 |
| 27 virtual ~CustomButton(); | 29 virtual ~CustomButton(); |
| 28 | 30 |
| 29 // Possible states | 31 // Possible states |
| 30 enum ButtonState { | 32 enum ButtonState { |
| 31 BS_NORMAL = 0, | 33 BS_NORMAL = 0, |
| 32 BS_HOT, | 34 BS_HOT, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 virtual void OnMouseExited(const MouseEvent& e); | 99 virtual void OnMouseExited(const MouseEvent& e); |
| 98 virtual bool OnKeyPressed(const KeyEvent& e); | 100 virtual bool OnKeyPressed(const KeyEvent& e); |
| 99 virtual bool OnKeyReleased(const KeyEvent& e); | 101 virtual bool OnKeyReleased(const KeyEvent& e); |
| 100 virtual void OnDragDone(); | 102 virtual void OnDragDone(); |
| 101 virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture); | 103 virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture); |
| 102 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); | 104 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); |
| 103 virtual void SetHotTracked(bool flag); | 105 virtual void SetHotTracked(bool flag); |
| 104 virtual bool IsHotTracked() const; | 106 virtual bool IsHotTracked() const; |
| 105 virtual void WillLoseFocus(); | 107 virtual void WillLoseFocus(); |
| 106 | 108 |
| 107 // Overridden from AnimationDelegate: | 109 // Overridden from ui::AnimationDelegate: |
| 108 virtual void AnimationProgressed(const Animation* animation); | 110 virtual void AnimationProgressed(const ui::Animation* animation); |
| 109 | 111 |
| 110 // Returns true if the button should become pressed when the user | 112 // Returns true if the button should become pressed when the user |
| 111 // holds the mouse down over the button. For this implementation, | 113 // holds the mouse down over the button. For this implementation, |
| 112 // we simply return IsTriggerableEvent(e). | 114 // we simply return IsTriggerableEvent(e). |
| 113 virtual bool ShouldEnterPushedState(const MouseEvent& e); | 115 virtual bool ShouldEnterPushedState(const MouseEvent& e); |
| 114 | 116 |
| 115 // The button state (defined in implementation) | 117 // The button state (defined in implementation) |
| 116 ButtonState state_; | 118 ButtonState state_; |
| 117 | 119 |
| 118 // Hover animation. | 120 // Hover animation. |
| 119 scoped_ptr<ThrobAnimation> hover_animation_; | 121 scoped_ptr<ui::ThrobAnimation> hover_animation_; |
| 120 | 122 |
| 121 private: | 123 private: |
| 122 // Should we animate when the state changes? Defaults to true. | 124 // Should we animate when the state changes? Defaults to true. |
| 123 bool animate_on_state_change_; | 125 bool animate_on_state_change_; |
| 124 | 126 |
| 125 // Is the hover animation running because StartThrob was invoked? | 127 // Is the hover animation running because StartThrob was invoked? |
| 126 bool is_throbbing_; | 128 bool is_throbbing_; |
| 127 | 129 |
| 128 // Mouse event flags which can trigger button actions. | 130 // Mouse event flags which can trigger button actions. |
| 129 int triggerable_event_flags_; | 131 int triggerable_event_flags_; |
| 130 | 132 |
| 131 // See description above setter. | 133 // See description above setter. |
| 132 bool request_focus_on_press_; | 134 bool request_focus_on_press_; |
| 133 | 135 |
| 134 DISALLOW_COPY_AND_ASSIGN(CustomButton); | 136 DISALLOW_COPY_AND_ASSIGN(CustomButton); |
| 135 }; | 137 }; |
| 136 | 138 |
| 137 } // namespace views | 139 } // namespace views |
| 138 | 140 |
| 139 #endif // VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 141 #endif // VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
| OLD | NEW |