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

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: Merge with master. 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..e63619e6711613c27be17149b296994cde863f57 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 {
@@ -193,12 +196,14 @@ void CustomButton::OnMouseCaptureLost() {
void CustomButton::OnMouseEntered(const ui::MouseEvent& event) {
if (state_ != STATE_DISABLED)
SetState(STATE_HOVERED);
+ UpdateInkDropHoverState();
}
void CustomButton::OnMouseExited(const ui::MouseEvent& event) {
// Starting a drag results in a MouseExited, we need to ignore it.
if (state_ != STATE_DISABLED && !InDrag())
SetState(STATE_NORMAL);
+ UpdateInkDropHoverState();
sadrul 2016/01/12 15:55:38 Can ButtonInkDropDelegate take care of updating th
bruthig 2016/01/12 16:27:17 Done.
}
void CustomButton::OnMouseMoved(const ui::MouseEvent& event) {
@@ -352,6 +357,10 @@ gfx::Point CustomButton::CalculateInkDropCenter() const {
return GetLocalBounds().CenterPoint();
}
+bool CustomButton::ShouldShowInkDropHover() const {
+ return enabled() && IsMouseHovered() && !InDrag();
+}
+
////////////////////////////////////////////////////////////////////////////////
// CustomButton, protected:
@@ -408,6 +417,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