| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 GetAccessibleNodeData(ui::AXNodeData* node_data) 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 |
| 113 // Overridden from InkDropHostView: |
| 114 std::unique_ptr<InkDrop> CreateInkDrop() override; |
| 113 SkColor GetInkDropBaseColor() const override; | 115 SkColor GetInkDropBaseColor() const override; |
| 114 | 116 |
| 115 // Overridden from gfx::AnimationDelegate: | 117 // Overridden from gfx::AnimationDelegate: |
| 116 void AnimationProgressed(const gfx::Animation* animation) override; | 118 void AnimationProgressed(const gfx::Animation* animation) override; |
| 117 | 119 |
| 118 // Overridden from View: | 120 // Overridden from View: |
| 119 void ViewHierarchyChanged( | 121 void ViewHierarchyChanged( |
| 120 const ViewHierarchyChangedDetails& details) override; | 122 const ViewHierarchyChangedDetails& details) override; |
| 121 void OnBlur() override; | 123 void OnBlur() override; |
| 122 bool ShouldShowInkDropForFocus() const override; | |
| 123 | 124 |
| 124 protected: | 125 protected: |
| 125 // Construct the Button with a Listener. See comment for Button's ctor. | 126 // Construct the Button with a Listener. See comment for Button's ctor. |
| 126 explicit CustomButton(ButtonListener* listener); | 127 explicit CustomButton(ButtonListener* listener); |
| 127 | 128 |
| 128 // Invoked from SetState() when SetState() is passed a value that differs from | 129 // Invoked from SetState() when SetState() is passed a value that differs from |
| 129 // the current node_data. CustomButton's implementation of StateChanged() does | 130 // the current node_data. CustomButton's implementation of StateChanged() does |
| 130 // nothing; this method is provided for subclasses that wish to do something | 131 // nothing; this method is provided for subclasses that wish to do something |
| 131 // on state changes. | 132 // on state changes. |
| 132 virtual void StateChanged(); | 133 virtual void StateChanged(); |
| 133 | 134 |
| 134 // Returns true if the event is one that can trigger notifying the listener. | 135 // 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. | 136 // This implementation returns true if the left mouse button is down. |
| 136 virtual bool IsTriggerableEvent(const ui::Event& event); | 137 virtual bool IsTriggerableEvent(const ui::Event& event); |
| 137 | 138 |
| 138 // Returns true if the button should become pressed when the user | 139 // Returns true if the button should become pressed when the user |
| 139 // holds the mouse down over the button. For this implementation, | 140 // holds the mouse down over the button. For this implementation, |
| 140 // we simply return IsTriggerableEvent(event). | 141 // we simply return IsTriggerableEvent(event). |
| 141 virtual bool ShouldEnterPushedState(const ui::Event& event); | 142 virtual bool ShouldEnterPushedState(const ui::Event& event); |
| 142 | 143 |
| 143 // Returns true if highlight effect should be visible. | |
| 144 virtual bool ShouldShowInkDropHighlight() const; | |
| 145 | |
| 146 void set_has_ink_drop_action_on_click(bool has_ink_drop_action_on_click) { | 144 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; | 145 has_ink_drop_action_on_click_ = has_ink_drop_action_on_click; |
| 148 } | 146 } |
| 149 | 147 |
| 150 // Returns true if the button should enter hovered state; that is, if the | 148 // 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 | 149 // mouse is over the button, and no other window has capture (which would |
| 152 // prevent the button from receiving MouseExited events and updating its | 150 // prevent the button from receiving MouseExited events and updating its |
| 153 // node_data). This does not take into account enabled node_data. | 151 // node_data). This does not take into account enabled node_data. |
| 154 bool ShouldEnterHoveredState(); | 152 bool ShouldEnterHoveredState(); |
| 155 | 153 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 189 |
| 192 // The color of the ripple and hover. | 190 // The color of the ripple and hover. |
| 193 SkColor ink_drop_base_color_; | 191 SkColor ink_drop_base_color_; |
| 194 | 192 |
| 195 DISALLOW_COPY_AND_ASSIGN(CustomButton); | 193 DISALLOW_COPY_AND_ASSIGN(CustomButton); |
| 196 }; | 194 }; |
| 197 | 195 |
| 198 } // namespace views | 196 } // namespace views |
| 199 | 197 |
| 200 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 198 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
| OLD | NEW |