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