Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: ui/views/controls/button/custom_button.h

Issue 1390113006: Added material design mouse hover feedback support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved MouseEntered/Exit() to hover handling in to the ButtonInkDropDelegate. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 void GetAccessibleState(ui::AXViewState* state) override; 99 void GetAccessibleState(ui::AXViewState* state) override;
100 void VisibilityChanged(View* starting_from, bool is_visible) override; 100 void VisibilityChanged(View* starting_from, bool is_visible) override;
101 101
102 // Overridden from gfx::AnimationDelegate: 102 // Overridden from gfx::AnimationDelegate:
103 void AnimationProgressed(const gfx::Animation* animation) override; 103 void AnimationProgressed(const gfx::Animation* animation) override;
104 104
105 // Overridden from views::InkDropHost: 105 // Overridden from views::InkDropHost:
106 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; 106 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
107 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; 107 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
108 gfx::Point CalculateInkDropCenter() const override; 108 gfx::Point CalculateInkDropCenter() const override;
109 bool ShouldShowInkDropHover() const override;
109 110
110 protected: 111 protected:
111 // Construct the Button with a Listener. See comment for Button's ctor. 112 // Construct the Button with a Listener. See comment for Button's ctor.
112 explicit CustomButton(ButtonListener* listener); 113 explicit CustomButton(ButtonListener* listener);
113 114
114 // Invoked from SetState() when SetState() is passed a value that differs from 115 // Invoked from SetState() when SetState() is passed a value that differs from
115 // the current state. CustomButton's implementation of StateChanged() does 116 // the current state. CustomButton's implementation of StateChanged() does
116 // nothing; this method is provided for subclasses that wish to do something 117 // nothing; this method is provided for subclasses that wish to do something
117 // on state changes. 118 // on state changes.
118 virtual void StateChanged(); 119 virtual void StateChanged();
(...skipping 10 matching lines...) Expand all
129 void set_has_ink_drop_action_on_click(bool has_ink_drop_action_on_click) { 130 void set_has_ink_drop_action_on_click(bool has_ink_drop_action_on_click) {
130 has_ink_drop_action_on_click_ = has_ink_drop_action_on_click; 131 has_ink_drop_action_on_click_ = has_ink_drop_action_on_click;
131 } 132 }
132 133
133 // Returns true if the button should enter hovered state; that is, if the 134 // Returns true if the button should enter hovered state; that is, if the
134 // mouse is over the button, and no other window has capture (which would 135 // mouse is over the button, and no other window has capture (which would
135 // prevent the button from receiving MouseExited events and updating its 136 // prevent the button from receiving MouseExited events and updating its
136 // state). This does not take into account enabled state. 137 // state). This does not take into account enabled state.
137 bool ShouldEnterHoveredState(); 138 bool ShouldEnterHoveredState();
138 139
140 // Updates the |ink_drop_delegate_|'s hover state.
141 void UpdateInkDropHoverState();
142
139 InkDropDelegate* ink_drop_delegate() const { return ink_drop_delegate_; } 143 InkDropDelegate* ink_drop_delegate() const { return ink_drop_delegate_; }
140 void set_ink_drop_delegate(InkDropDelegate* ink_drop_delegate) { 144 void set_ink_drop_delegate(InkDropDelegate* ink_drop_delegate) {
141 ink_drop_delegate_ = ink_drop_delegate; 145 ink_drop_delegate_ = ink_drop_delegate;
142 } 146 }
143 147
144 // Overridden from View: 148 // Overridden from View:
145 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; 149 void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
146 void ViewHierarchyChanged( 150 void ViewHierarchyChanged(
147 const ViewHierarchyChangedDetails& details) override; 151 const ViewHierarchyChangedDetails& details) override;
148 void OnBlur() override; 152 void OnBlur() override;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // The animation action to trigger on the |ink_drop_delegate_| when the button 197 // The animation action to trigger on the |ink_drop_delegate_| when the button
194 // is clicked. 198 // is clicked.
195 InkDropState ink_drop_action_on_click_; 199 InkDropState ink_drop_action_on_click_;
196 200
197 DISALLOW_COPY_AND_ASSIGN(CustomButton); 201 DISALLOW_COPY_AND_ASSIGN(CustomButton);
198 }; 202 };
199 203
200 } // namespace views 204 } // namespace views
201 205
202 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ 206 #endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698