| 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/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 class ThrobAnimation; | |
| 17 } | |
| 18 | |
| 19 namespace views { | 16 namespace views { |
| 20 | 17 |
| 21 class InkDropDelegate; | 18 class InkDropDelegate; |
| 22 | 19 |
| 23 // A button with custom rendering. The base of ImageButton and LabelButton. | 20 // 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 | 21 // 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 | 22 // part of the focus chain. Call SetFocusable(true) to make it part of the |
| 26 // focus chain. | 23 // focus chain. |
| 27 class VIEWS_EXPORT CustomButton : public Button, | 24 class VIEWS_EXPORT CustomButton : public Button, |
| 28 public gfx::AnimationDelegate { | 25 public gfx::AnimationDelegate { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // Overridden from View: | 137 // Overridden from View: |
| 141 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 138 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 142 void ViewHierarchyChanged( | 139 void ViewHierarchyChanged( |
| 143 const ViewHierarchyChangedDetails& details) override; | 140 const ViewHierarchyChangedDetails& details) override; |
| 144 void OnBlur() override; | 141 void OnBlur() override; |
| 145 | 142 |
| 146 // Overridden from Button: | 143 // Overridden from Button: |
| 147 void NotifyClick(const ui::Event& event) override; | 144 void NotifyClick(const ui::Event& event) override; |
| 148 void OnClickCanceled(const ui::Event& event) override; | 145 void OnClickCanceled(const ui::Event& event) override; |
| 149 | 146 |
| 150 // The button state (defined in implementation) | 147 const gfx::ThrobAnimation& hover_animation() const { |
| 151 ButtonState state_; | 148 return hover_animation_; |
| 152 | 149 } |
| 153 // Hover animation. | |
| 154 scoped_ptr<gfx::ThrobAnimation> hover_animation_; | |
| 155 | 150 |
| 156 private: | 151 private: |
| 157 // Returns true if this is not a top level widget. Virtual for tests. | 152 // Returns true if this is not a top level widget. Virtual for tests. |
| 158 virtual bool IsChildWidget() const; | 153 virtual bool IsChildWidget() const; |
| 159 // Returns true if the focus is not in a top level widget. Virtual for tests. | 154 // Returns true if the focus is not in a top level widget. Virtual for tests. |
| 160 virtual bool FocusInChildWidget() const; | 155 virtual bool FocusInChildWidget() const; |
| 161 | 156 |
| 157 ButtonState state_; |
| 158 |
| 159 gfx::ThrobAnimation hover_animation_; |
| 160 |
| 162 // Should we animate when the state changes? Defaults to true. | 161 // Should we animate when the state changes? Defaults to true. |
| 163 bool animate_on_state_change_; | 162 bool animate_on_state_change_; |
| 164 | 163 |
| 165 // Is the hover animation running because StartThrob was invoked? | 164 // Is the hover animation running because StartThrob was invoked? |
| 166 bool is_throbbing_; | 165 bool is_throbbing_; |
| 167 | 166 |
| 168 // Mouse event flags which can trigger button actions. | 167 // Mouse event flags which can trigger button actions. |
| 169 int triggerable_event_flags_; | 168 int triggerable_event_flags_; |
| 170 | 169 |
| 171 // See description above setter. | 170 // See description above setter. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 187 // The animation action to trigger on the |ink_drop_delegate_| when the button | 186 // The animation action to trigger on the |ink_drop_delegate_| when the button |
| 188 // is clicked. | 187 // is clicked. |
| 189 InkDropState ink_drop_action_on_click_; | 188 InkDropState ink_drop_action_on_click_; |
| 190 | 189 |
| 191 DISALLOW_COPY_AND_ASSIGN(CustomButton); | 190 DISALLOW_COPY_AND_ASSIGN(CustomButton); |
| 192 }; | 191 }; |
| 193 | 192 |
| 194 } // namespace views | 193 } // namespace views |
| 195 | 194 |
| 196 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 195 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
| OLD | NEW |