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/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/events/event_constants.h" | 10 #include "ui/events/event_constants.h" |
11 #include "ui/gfx/animation/animation_delegate.h" | 11 #include "ui/gfx/animation/animation_delegate.h" |
12 #include "ui/gfx/animation/throb_animation.h" | 12 #include "ui/gfx/animation/throb_animation.h" |
| 13 #include "ui/views/animation/ink_drop_host.h" |
13 #include "ui/views/animation/ink_drop_state.h" | 14 #include "ui/views/animation/ink_drop_state.h" |
14 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
15 | 16 |
16 namespace views { | 17 namespace views { |
17 | 18 |
18 class InkDropDelegate; | 19 class InkDropDelegate; |
19 | 20 |
20 // A button with custom rendering. The base of ImageButton and LabelButton. | 21 // A button with custom rendering. The base of ImageButton and LabelButton. |
21 // 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 |
22 // 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 |
23 // focus chain. | 24 // focus chain. |
24 class VIEWS_EXPORT CustomButton : public Button, | 25 class VIEWS_EXPORT CustomButton : public Button, |
25 public gfx::AnimationDelegate { | 26 public gfx::AnimationDelegate, |
| 27 public views::InkDropHost { |
26 public: | 28 public: |
27 // An enum describing the events on which a button should notify its listener. | 29 // An enum describing the events on which a button should notify its listener. |
28 enum NotifyAction { | 30 enum NotifyAction { |
29 NOTIFY_ON_PRESS, | 31 NOTIFY_ON_PRESS, |
30 NOTIFY_ON_RELEASE, | 32 NOTIFY_ON_RELEASE, |
31 }; | 33 }; |
32 | 34 |
33 // The menu button's class name. | 35 // The menu button's class name. |
34 static const char kViewClassName[]; | 36 static const char kViewClassName[]; |
35 | 37 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 95 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
94 void ShowContextMenu(const gfx::Point& p, | 96 void ShowContextMenu(const gfx::Point& p, |
95 ui::MenuSourceType source_type) override; | 97 ui::MenuSourceType source_type) override; |
96 void OnDragDone() override; | 98 void OnDragDone() override; |
97 void GetAccessibleState(ui::AXViewState* state) override; | 99 void GetAccessibleState(ui::AXViewState* state) override; |
98 void VisibilityChanged(View* starting_from, bool is_visible) override; | 100 void VisibilityChanged(View* starting_from, bool is_visible) override; |
99 | 101 |
100 // Overridden from gfx::AnimationDelegate: | 102 // Overridden from gfx::AnimationDelegate: |
101 void AnimationProgressed(const gfx::Animation* animation) override; | 103 void AnimationProgressed(const gfx::Animation* animation) override; |
102 | 104 |
| 105 // Overridden from views::InkDropHost: |
| 106 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; |
| 107 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; |
| 108 gfx::Point CalculateInkDropCenter() const override; |
| 109 |
103 protected: | 110 protected: |
104 // Construct the Button with a Listener. See comment for Button's ctor. | 111 // Construct the Button with a Listener. See comment for Button's ctor. |
105 explicit CustomButton(ButtonListener* listener); | 112 explicit CustomButton(ButtonListener* listener); |
106 | 113 |
107 // Invoked from SetState() when SetState() is passed a value that differs from | 114 // Invoked from SetState() when SetState() is passed a value that differs from |
108 // the current state. CustomButton's implementation of StateChanged() does | 115 // the current state. CustomButton's implementation of StateChanged() does |
109 // nothing; this method is provided for subclasses that wish to do something | 116 // nothing; this method is provided for subclasses that wish to do something |
110 // on state changes. | 117 // on state changes. |
111 virtual void StateChanged(); | 118 virtual void StateChanged(); |
112 | 119 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // The animation action to trigger on the |ink_drop_delegate_| when the button | 193 // The animation action to trigger on the |ink_drop_delegate_| when the button |
187 // is clicked. | 194 // is clicked. |
188 InkDropState ink_drop_action_on_click_; | 195 InkDropState ink_drop_action_on_click_; |
189 | 196 |
190 DISALLOW_COPY_AND_ASSIGN(CustomButton); | 197 DISALLOW_COPY_AND_ASSIGN(CustomButton); |
191 }; | 198 }; |
192 | 199 |
193 } // namespace views | 200 } // namespace views |
194 | 201 |
195 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 202 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
OLD | NEW |