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" |
11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 class ThrobAnimation; | 14 class ThrobAnimation; |
15 } | 15 } |
16 | 16 |
17 namespace views { | 17 namespace views { |
18 | 18 |
19 class InkDropDelegate; | |
20 | |
19 // A button with custom rendering. The base of ImageButton and LabelButton. | 21 // A button with custom rendering. The base of ImageButton and LabelButton. |
20 // Note that this type of button is not focusable by default and will not be | 22 // Note that this type of button is not focusable by default and will not be |
21 // part of the focus chain. Call SetFocusable(true) to make it part of the | 23 // part of the focus chain. Call SetFocusable(true) to make it part of the |
22 // focus chain. | 24 // focus chain. |
23 class VIEWS_EXPORT CustomButton : public Button, | 25 class VIEWS_EXPORT CustomButton : public Button, |
24 public gfx::AnimationDelegate { | 26 public gfx::AnimationDelegate { |
25 public: | 27 public: |
26 // An enum describing the events on which a button should notify its listener. | 28 // An enum describing the events on which a button should notify its listener. |
27 enum NotifyAction { | 29 enum NotifyAction { |
28 NOTIFY_ON_PRESS, | 30 NOTIFY_ON_PRESS, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 // we simply return IsTriggerableEvent(event). | 119 // we simply return IsTriggerableEvent(event). |
118 virtual bool ShouldEnterPushedState(const ui::Event& event); | 120 virtual bool ShouldEnterPushedState(const ui::Event& event); |
119 | 121 |
120 // Returns true if the button should enter hovered state; that is, if the | 122 // Returns true if the button should enter hovered state; that is, if the |
121 // mouse is over the button, and no other window has capture (which would | 123 // mouse is over the button, and no other window has capture (which would |
122 // prevent the button from receiving MouseExited events and updating its | 124 // prevent the button from receiving MouseExited events and updating its |
123 // state). This does not take into account enabled state. | 125 // state). This does not take into account enabled state. |
124 bool ShouldEnterHoveredState(); | 126 bool ShouldEnterHoveredState(); |
125 | 127 |
126 // Overridden from View: | 128 // Overridden from View: |
129 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | |
127 void ViewHierarchyChanged( | 130 void ViewHierarchyChanged( |
128 const ViewHierarchyChangedDetails& details) override; | 131 const ViewHierarchyChangedDetails& details) override; |
129 void OnBlur() override; | 132 void OnBlur() override; |
130 | 133 |
134 InkDropDelegate* ink_drop_delegate() const { | |
135 return ink_drop_delegate_.get(); | |
136 } | |
sadrul
2015/11/25 22:38:58
non-overrides before overrides. So this should mov
varkha
2015/11/26 00:05:47
Done.
| |
137 | |
131 // The button state (defined in implementation) | 138 // The button state (defined in implementation) |
132 ButtonState state_; | 139 ButtonState state_; |
133 | 140 |
134 // Hover animation. | 141 // Hover animation. |
135 scoped_ptr<gfx::ThrobAnimation> hover_animation_; | 142 scoped_ptr<gfx::ThrobAnimation> hover_animation_; |
136 | 143 |
144 // Animation delegate for the ink drop ripple effect. | |
145 scoped_ptr<InkDropDelegate> ink_drop_delegate_; | |
sadrul
2015/11/25 22:38:58
Should be a private member.
varkha
2015/11/26 00:05:47
Done.
| |
146 | |
137 private: | 147 private: |
138 // Returns true if this is not a top level widget. Virtual for tests. | 148 // Returns true if this is not a top level widget. Virtual for tests. |
139 virtual bool IsChildWidget() const; | 149 virtual bool IsChildWidget() const; |
140 // Returns true if the focus is not in a top level widget. Virtual for tests. | 150 // Returns true if the focus is not in a top level widget. Virtual for tests. |
141 virtual bool FocusInChildWidget() const; | 151 virtual bool FocusInChildWidget() const; |
142 | 152 |
143 // Should we animate when the state changes? Defaults to true. | 153 // Should we animate when the state changes? Defaults to true. |
144 bool animate_on_state_change_; | 154 bool animate_on_state_change_; |
145 | 155 |
146 // Is the hover animation running because StartThrob was invoked? | 156 // Is the hover animation running because StartThrob was invoked? |
147 bool is_throbbing_; | 157 bool is_throbbing_; |
148 | 158 |
149 // Mouse event flags which can trigger button actions. | 159 // Mouse event flags which can trigger button actions. |
150 int triggerable_event_flags_; | 160 int triggerable_event_flags_; |
151 | 161 |
152 // See description above setter. | 162 // See description above setter. |
153 bool request_focus_on_press_; | 163 bool request_focus_on_press_; |
154 | 164 |
155 // The event on which the button should notify its listener. | 165 // The event on which the button should notify its listener. |
156 NotifyAction notify_action_; | 166 NotifyAction notify_action_; |
157 | 167 |
158 DISALLOW_COPY_AND_ASSIGN(CustomButton); | 168 DISALLOW_COPY_AND_ASSIGN(CustomButton); |
159 }; | 169 }; |
160 | 170 |
161 } // namespace views | 171 } // namespace views |
162 | 172 |
163 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 173 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
OLD | NEW |