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

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

Issue 2447523002: [ash-md] Added different highlighting modes to the InkDropImpl. (Closed)
Patch Set: Fixed InkDropHostView::GetInkDrop() to use CreateInkDrop(). Created 4 years, 1 month 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/label_button.h » ('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 0057575333f0aba04e0c6968d481b2fdd29f3b27..4540c1bc52bac0191cad7ba1e2b5204ea6fc6ea5 100644
--- a/ui/views/controls/button/custom_button.cc
+++ b/ui/views/controls/button/custom_button.cc
@@ -12,6 +12,7 @@
#include "ui/gfx/color_palette.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/animation/ink_drop_highlight.h"
+#include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/image_button.h"
@@ -212,6 +213,8 @@ void CustomButton::OnMouseCaptureLost() {
if (state_ != STATE_DISABLED)
SetState(STATE_NORMAL);
AnimateInkDrop(views::InkDropState::HIDDEN, nullptr /* event */);
+ GetInkDrop()->SetHovered(false);
+ Button::OnMouseCaptureLost();
}
void CustomButton::OnMouseEntered(const ui::MouseEvent& event) {
@@ -357,9 +360,10 @@ void CustomButton::VisibilityChanged(View* starting_from, bool visible) {
SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL);
}
-std::unique_ptr<InkDropHighlight> CustomButton::CreateInkDropHighlight() const {
- return ShouldShowInkDropHighlight() ? Button::CreateInkDropHighlight()
- : nullptr;
+std::unique_ptr<InkDrop> CustomButton::CreateInkDrop() {
+ std::unique_ptr<views::InkDropImpl> ink_drop = CreateDefaultInkDropImpl();
+ ink_drop->SetShowHighlightOnFocus(true);
+ return std::move(ink_drop);
}
SkColor CustomButton::GetInkDropBaseColor() const {
@@ -395,10 +399,6 @@ void CustomButton::OnBlur() {
}
}
-bool CustomButton::ShouldShowInkDropForFocus() const {
- return true;
-}
-
////////////////////////////////////////////////////////////////////////////////
// CustomButton, protected:
@@ -430,11 +430,6 @@ bool CustomButton::ShouldEnterPushedState(const ui::Event& event) {
return IsTriggerableEvent(event);
}
-bool CustomButton::ShouldShowInkDropHighlight() const {
- return enabled() && !InDrag() &&
- (IsMouseHovered() || (ShouldShowInkDropForFocus() && HasFocus()));
-}
-
bool CustomButton::ShouldEnterHoveredState() {
if (!visible())
return false;
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/button/label_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698