| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void OnMouseExited(const ui::MouseEvent& event) override; | 100 void OnMouseExited(const ui::MouseEvent& event) override; |
| 101 void OnMouseMoved(const ui::MouseEvent& event) override; | 101 void OnMouseMoved(const ui::MouseEvent& event) override; |
| 102 bool OnKeyPressed(const ui::KeyEvent& event) override; | 102 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 103 bool OnKeyReleased(const ui::KeyEvent& event) override; | 103 bool OnKeyReleased(const ui::KeyEvent& event) override; |
| 104 void OnGestureEvent(ui::GestureEvent* event) override; | 104 void OnGestureEvent(ui::GestureEvent* event) override; |
| 105 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 105 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 106 bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) override; | 106 bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) override; |
| 107 void ShowContextMenu(const gfx::Point& p, | 107 void ShowContextMenu(const gfx::Point& p, |
| 108 ui::MenuSourceType source_type) override; | 108 ui::MenuSourceType source_type) override; |
| 109 void OnDragDone() override; | 109 void OnDragDone() override; |
| 110 void GetAccessibleState(ui::AXViewState* state) override; | 110 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 111 void VisibilityChanged(View* starting_from, bool is_visible) override; | 111 void VisibilityChanged(View* starting_from, bool is_visible) override; |
| 112 std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const override; | 112 std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const override; |
| 113 SkColor GetInkDropBaseColor() const override; | 113 SkColor GetInkDropBaseColor() const override; |
| 114 | 114 |
| 115 // Overridden from gfx::AnimationDelegate: | 115 // Overridden from gfx::AnimationDelegate: |
| 116 void AnimationProgressed(const gfx::Animation* animation) override; | 116 void AnimationProgressed(const gfx::Animation* animation) override; |
| 117 | 117 |
| 118 // Overridden from View: | 118 // Overridden from View: |
| 119 void ViewHierarchyChanged( | 119 void ViewHierarchyChanged( |
| 120 const ViewHierarchyChangedDetails& details) override; | 120 const ViewHierarchyChangedDetails& details) override; |
| 121 void OnBlur() override; | 121 void OnBlur() override; |
| 122 bool ShouldShowInkDropForFocus() const override; | 122 bool ShouldShowInkDropForFocus() const override; |
| 123 | 123 |
| 124 protected: | 124 protected: |
| 125 // Construct the Button with a Listener. See comment for Button's ctor. | 125 // Construct the Button with a Listener. See comment for Button's ctor. |
| 126 explicit CustomButton(ButtonListener* listener); | 126 explicit CustomButton(ButtonListener* listener); |
| 127 | 127 |
| 128 // Invoked from SetState() when SetState() is passed a value that differs from | 128 // Invoked from SetState() when SetState() is passed a value that differs from |
| 129 // the current state. CustomButton's implementation of StateChanged() does | 129 // the current node_data. CustomButton's implementation of StateChanged() does |
| 130 // nothing; this method is provided for subclasses that wish to do something | 130 // nothing; this method is provided for subclasses that wish to do something |
| 131 // on state changes. | 131 // on state changes. |
| 132 virtual void StateChanged(); | 132 virtual void StateChanged(); |
| 133 | 133 |
| 134 // Returns true if the event is one that can trigger notifying the listener. | 134 // Returns true if the event is one that can trigger notifying the listener. |
| 135 // This implementation returns true if the left mouse button is down. | 135 // This implementation returns true if the left mouse button is down. |
| 136 virtual bool IsTriggerableEvent(const ui::Event& event); | 136 virtual bool IsTriggerableEvent(const ui::Event& event); |
| 137 | 137 |
| 138 // Returns true if the button should become pressed when the user | 138 // Returns true if the button should become pressed when the user |
| 139 // holds the mouse down over the button. For this implementation, | 139 // holds the mouse down over the button. For this implementation, |
| 140 // we simply return IsTriggerableEvent(event). | 140 // we simply return IsTriggerableEvent(event). |
| 141 virtual bool ShouldEnterPushedState(const ui::Event& event); | 141 virtual bool ShouldEnterPushedState(const ui::Event& event); |
| 142 | 142 |
| 143 // Returns true if highlight effect should be visible. | 143 // Returns true if highlight effect should be visible. |
| 144 virtual bool ShouldShowInkDropHighlight() const; | 144 virtual bool ShouldShowInkDropHighlight() const; |
| 145 | 145 |
| 146 void set_has_ink_drop_action_on_click(bool has_ink_drop_action_on_click) { | 146 void set_has_ink_drop_action_on_click(bool has_ink_drop_action_on_click) { |
| 147 has_ink_drop_action_on_click_ = has_ink_drop_action_on_click; | 147 has_ink_drop_action_on_click_ = has_ink_drop_action_on_click; |
| 148 } | 148 } |
| 149 | 149 |
| 150 // Returns true if the button should enter hovered state; that is, if the | 150 // Returns true if the button should enter hovered state; that is, if the |
| 151 // mouse is over the button, and no other window has capture (which would | 151 // mouse is over the button, and no other window has capture (which would |
| 152 // prevent the button from receiving MouseExited events and updating its | 152 // prevent the button from receiving MouseExited events and updating its |
| 153 // state). This does not take into account enabled state. | 153 // node_data). This does not take into account enabled node_data. |
| 154 bool ShouldEnterHoveredState(); | 154 bool ShouldEnterHoveredState(); |
| 155 | 155 |
| 156 // Overridden from Button: | 156 // Overridden from Button: |
| 157 void NotifyClick(const ui::Event& event) override; | 157 void NotifyClick(const ui::Event& event) override; |
| 158 void OnClickCanceled(const ui::Event& event) override; | 158 void OnClickCanceled(const ui::Event& event) override; |
| 159 | 159 |
| 160 const gfx::ThrobAnimation& hover_animation() const { | 160 const gfx::ThrobAnimation& hover_animation() const { |
| 161 return hover_animation_; | 161 return hover_animation_; |
| 162 } | 162 } |
| 163 | 163 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 191 | 191 |
| 192 // The color of the ripple and hover. | 192 // The color of the ripple and hover. |
| 193 SkColor ink_drop_base_color_; | 193 SkColor ink_drop_base_color_; |
| 194 | 194 |
| 195 DISALLOW_COPY_AND_ASSIGN(CustomButton); | 195 DISALLOW_COPY_AND_ASSIGN(CustomButton); |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 } // namespace views | 198 } // namespace views |
| 199 | 199 |
| 200 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 200 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
| OLD | NEW |