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/events/event_constants.h" | 9 #include "ui/events/event_constants.h" |
10 #include "ui/gfx/animation/animation_delegate.h" | 10 #include "ui/gfx/animation/animation_delegate.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 // See description above field. | 61 // See description above field. |
62 void set_animate_on_state_change(bool value) { | 62 void set_animate_on_state_change(bool value) { |
63 animate_on_state_change_ = value; | 63 animate_on_state_change_ = value; |
64 } | 64 } |
65 | 65 |
66 void SetHotTracked(bool is_hot_tracked); | 66 void SetHotTracked(bool is_hot_tracked); |
67 bool IsHotTracked() const; | 67 bool IsHotTracked() const; |
68 | 68 |
69 // Overridden from View: | 69 // Overridden from View: |
70 virtual void OnEnabledChanged() OVERRIDE; | 70 virtual void OnEnabledChanged() override; |
71 virtual const char* GetClassName() const OVERRIDE; | 71 virtual const char* GetClassName() const override; |
72 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 72 virtual bool OnMousePressed(const ui::MouseEvent& event) override; |
73 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; | 73 virtual bool OnMouseDragged(const ui::MouseEvent& event) override; |
74 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 74 virtual void OnMouseReleased(const ui::MouseEvent& event) override; |
75 virtual void OnMouseCaptureLost() OVERRIDE; | 75 virtual void OnMouseCaptureLost() override; |
76 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 76 virtual void OnMouseEntered(const ui::MouseEvent& event) override; |
77 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 77 virtual void OnMouseExited(const ui::MouseEvent& event) override; |
78 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; | 78 virtual void OnMouseMoved(const ui::MouseEvent& event) override; |
79 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 79 virtual bool OnKeyPressed(const ui::KeyEvent& event) override; |
80 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; | 80 virtual bool OnKeyReleased(const ui::KeyEvent& event) override; |
81 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 81 virtual void OnGestureEvent(ui::GestureEvent* event) override; |
82 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 82 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
83 virtual void ShowContextMenu(const gfx::Point& p, | 83 virtual void ShowContextMenu(const gfx::Point& p, |
84 ui::MenuSourceType source_type) OVERRIDE; | 84 ui::MenuSourceType source_type) override; |
85 virtual void OnDragDone() OVERRIDE; | 85 virtual void OnDragDone() override; |
86 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 86 virtual void GetAccessibleState(ui::AXViewState* state) override; |
87 virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE; | 87 virtual void VisibilityChanged(View* starting_from, bool is_visible) override; |
88 | 88 |
89 // Overridden from gfx::AnimationDelegate: | 89 // Overridden from gfx::AnimationDelegate: |
90 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 90 virtual void AnimationProgressed(const gfx::Animation* animation) override; |
91 | 91 |
92 // Takes ownership of the delegate. | 92 // Takes ownership of the delegate. |
93 void set_state_changed_delegate(CustomButtonStateChangedDelegate* delegate) { | 93 void set_state_changed_delegate(CustomButtonStateChangedDelegate* delegate) { |
94 state_changed_delegate_.reset(delegate); | 94 state_changed_delegate_.reset(delegate); |
95 } | 95 } |
96 | 96 |
97 protected: | 97 protected: |
98 // Construct the Button with a Listener. See comment for Button's ctor. | 98 // Construct the Button with a Listener. See comment for Button's ctor. |
99 explicit CustomButton(ButtonListener* listener); | 99 explicit CustomButton(ButtonListener* listener); |
100 | 100 |
101 // Invoked from SetState() when SetState() is passed a value that differs from | 101 // Invoked from SetState() when SetState() is passed a value that differs from |
102 // the current state. CustomButton's implementation of StateChanged() does | 102 // the current state. CustomButton's implementation of StateChanged() does |
103 // nothing; this method is provided for subclasses that wish to do something | 103 // nothing; this method is provided for subclasses that wish to do something |
104 // on state changes. | 104 // on state changes. |
105 virtual void StateChanged(); | 105 virtual void StateChanged(); |
106 | 106 |
107 // Returns true if the event is one that can trigger notifying the listener. | 107 // Returns true if the event is one that can trigger notifying the listener. |
108 // This implementation returns true if the left mouse button is down. | 108 // This implementation returns true if the left mouse button is down. |
109 virtual bool IsTriggerableEvent(const ui::Event& event); | 109 virtual bool IsTriggerableEvent(const ui::Event& event); |
110 | 110 |
111 // Returns true if the button should become pressed when the user | 111 // Returns true if the button should become pressed when the user |
112 // holds the mouse down over the button. For this implementation, | 112 // holds the mouse down over the button. For this implementation, |
113 // we simply return IsTriggerableEvent(event). | 113 // we simply return IsTriggerableEvent(event). |
114 virtual bool ShouldEnterPushedState(const ui::Event& event); | 114 virtual bool ShouldEnterPushedState(const ui::Event& event); |
115 | 115 |
116 // Overridden from View: | 116 // Overridden from View: |
117 virtual void ViewHierarchyChanged( | 117 virtual void ViewHierarchyChanged( |
118 const ViewHierarchyChangedDetails& details) OVERRIDE; | 118 const ViewHierarchyChangedDetails& details) override; |
119 virtual void OnBlur() OVERRIDE; | 119 virtual void OnBlur() override; |
120 | 120 |
121 // The button state (defined in implementation) | 121 // The button state (defined in implementation) |
122 ButtonState state_; | 122 ButtonState state_; |
123 | 123 |
124 // Hover animation. | 124 // Hover animation. |
125 scoped_ptr<gfx::ThrobAnimation> hover_animation_; | 125 scoped_ptr<gfx::ThrobAnimation> hover_animation_; |
126 | 126 |
127 private: | 127 private: |
128 // Should we animate when the state changes? Defaults to true. | 128 // Should we animate when the state changes? Defaults to true. |
129 bool animate_on_state_change_; | 129 bool animate_on_state_change_; |
(...skipping 21 matching lines...) Expand all Loading... |
151 protected: | 151 protected: |
152 CustomButtonStateChangedDelegate() {} | 152 CustomButtonStateChangedDelegate() {} |
153 | 153 |
154 private: | 154 private: |
155 DISALLOW_COPY_AND_ASSIGN(CustomButtonStateChangedDelegate); | 155 DISALLOW_COPY_AND_ASSIGN(CustomButtonStateChangedDelegate); |
156 }; | 156 }; |
157 | 157 |
158 } // namespace views | 158 } // namespace views |
159 | 159 |
160 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 160 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
OLD | NEW |