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

Unified Diff: ui/views/controls/button/custom_button.cc

Issue 1390113006: Added material design mouse hover feedback support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed the InkDropAnimationControllerImpl to destroy its timer when not running. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/button/custom_button_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/custom_button.cc
diff --git a/ui/views/controls/button/custom_button.cc b/ui/views/controls/button/custom_button.cc
index 3ab8303e9f8821d8dd77e1f7ba7308153cd78a60..3dfc48d6d4519dac0e81db37fc5c65870134c383 100644
--- a/ui/views/controls/button/custom_button.cc
+++ b/ui/views/controls/button/custom_button.cc
@@ -123,6 +123,8 @@ void CustomButton::Layout() {
}
void CustomButton::OnEnabledChanged() {
+ // TODO(bruthig): Is there any reason we are not calling
+ // Button::OnEnabledChanged() here?
if (enabled() ? (state_ != STATE_DISABLED) : (state_ == STATE_DISABLED))
return;
@@ -130,6 +132,7 @@ void CustomButton::OnEnabledChanged() {
SetState(ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL);
else
SetState(STATE_DISABLED);
+ UpdateInkDropHoverState();
}
const char* CustomButton::GetClassName() const {
@@ -352,6 +355,10 @@ gfx::Point CustomButton::CalculateInkDropCenter() const {
return GetLocalBounds().CenterPoint();
}
+bool CustomButton::ShouldShowInkDropHover() const {
+ return enabled() && IsMouseHovered() && !InDrag();
+}
+
////////////////////////////////////////////////////////////////////////////////
// CustomButton, protected:
@@ -408,6 +415,11 @@ bool CustomButton::ShouldEnterHoveredState() {
return check_mouse_position && IsMouseHovered();
}
+void CustomButton::UpdateInkDropHoverState() {
+ if (ink_drop_delegate_)
+ ink_drop_delegate_->SetHovered(ShouldShowInkDropHover());
+}
+
////////////////////////////////////////////////////////////////////////////////
// CustomButton, View overrides (protected):
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/button/custom_button_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698