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

Unified Diff: ui/views/animation/ink_drop_host_view.cc

Issue 2001843002: Use ink drop hover for focus states on toolbar buttons and location (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: layout Created 4 years, 7 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/animation/ink_drop_host_view.h ('k') | ui/views/animation/ink_drop_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/ink_drop_host_view.cc
diff --git a/ui/views/animation/ink_drop_host_view.cc b/ui/views/animation/ink_drop_host_view.cc
index faf32b07d816bab75fed2fe7b3ae2dd0148570d4..dc7f67e92c6f4439e9ce396826e5a39ec17b7c16 100644
--- a/ui/views/animation/ink_drop_host_view.cc
+++ b/ui/views/animation/ink_drop_host_view.cc
@@ -6,6 +6,7 @@
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/size_conversions.h"
+#include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_hover.h"
#include "ui/views/animation/square_ink_drop_ripple.h"
@@ -30,9 +31,13 @@ gfx::Size CalculateLargeInkDropSize(const gfx::Size small_size) {
const int InkDropHostView::kInkDropSmallCornerRadius = 2;
InkDropHostView::InkDropHostView()
- : ink_drop_size_(kInkDropSize, kInkDropSize) {}
+ : ink_drop_size_(kInkDropSize, kInkDropSize), destroying_(false) {}
-InkDropHostView::~InkDropHostView() {}
+InkDropHostView::~InkDropHostView() {
+ // TODO(bruthig): Improve InkDropImpl to be safer about calling back to
+ // potentially destroyed InkDropHosts and remove |destroying_|.
+ destroying_ = true;
+}
void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
SetPaintToLayer(true);
@@ -42,6 +47,11 @@ void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
}
void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
+ // No need to do anything when called during shutdown, and if a derived
+ // class has overridden Add/RemoveInkDropLayer, running this implementation
+ // would be wrong.
+ if (destroying_)
+ return;
layer()->Remove(ink_drop_layer);
SetPaintToLayer(false);
}
@@ -62,6 +72,18 @@ std::unique_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const {
return hover;
}
+void InkDropHostView::OnFocus() {
+ views::View::OnFocus();
+ if (ink_drop_delegate() && ShouldShowInkDropForFocus())
+ ink_drop_delegate()->GetInkDrop()->SetFocused(true);
+}
+
+void InkDropHostView::OnBlur() {
+ views::View::OnBlur();
+ if (ink_drop_delegate() && ShouldShowInkDropForFocus())
+ ink_drop_delegate()->GetInkDrop()->SetFocused(false);
+}
+
gfx::Point InkDropHostView::GetInkDropCenter() const {
return GetLocalBounds().CenterPoint();
}
@@ -71,4 +93,8 @@ SkColor InkDropHostView::GetInkDropBaseColor() const {
return gfx::kPlaceholderColor;
}
+bool InkDropHostView::ShouldShowInkDropForFocus() const {
+ return false;
+}
+
} // namespace views
« no previous file with comments | « ui/views/animation/ink_drop_host_view.h ('k') | ui/views/animation/ink_drop_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698