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

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

Issue 2042073002: Centered flood fill style ink drop ripples on mouse/touch points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Polished for review. Created 4 years, 6 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
Index: ui/views/animation/ink_drop_host_view.h
diff --git a/ui/views/animation/ink_drop_host_view.h b/ui/views/animation/ink_drop_host_view.h
index d5f3771622a67c54858f2588eb849989b3a66535..651633cfa6145aa10811a69267cf2264e91b7e20 100644
--- a/ui/views/animation/ink_drop_host_view.h
+++ b/ui/views/animation/ink_drop_host_view.h
@@ -8,6 +8,7 @@
#include <memory>
#include "third_party/skia/include/core/SkColor.h"
+#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_host.h"
@@ -25,6 +26,9 @@ class InkDropHighlight;
// A view that provides InkDropHost functionality.
class VIEWS_EXPORT InkDropHostView : public View, public InkDropHost {
public:
+ InkDropHostView();
+ ~InkDropHostView() override;
+
// Overridden from InkDropHost:
void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
@@ -34,11 +38,33 @@ class VIEWS_EXPORT InkDropHostView : public View, public InkDropHost {
void set_ink_drop_size(const gfx::Size& size) { ink_drop_size_ = size; }
protected:
- InkDropHostView();
- ~InkDropHostView() override;
-
static const int kInkDropSmallCornerRadius;
+ const ui::Event* last_ripple_triggering_event() const {
Evan Stade 2016/06/14 21:13:24 is this used somewhere
bruthig 2016/06/14 21:57:01 Removed.
+ return last_ripple_triggering_event_.get();
+ }
+
+ // Returns the default InkDropRipple centered on |center_point|.
+ std::unique_ptr<InkDropRipple> CreateDefaultInkDropRipple(
+ const gfx::Point& center_point) const;
+
+ // Returns the default InkDropHighlight centered on |center_point|.
+ std::unique_ptr<InkDropHighlight> CreateDefaultInkDropHighlight(
+ const gfx::Point& center_point) const;
+
+ // Returns the point of the |last_ripple_triggereing_event_| if it was a
Evan Stade 2016/06/14 21:13:24 nit: spelling
bruthig 2016/06/14 21:57:01 Done.
+ // LocatedEvent, otherwise the center point of the local bounds is returned.
+ gfx::Point GetInkDropCenterBasedOnLastEvent() const;
+
+ // Animates |ink_drop_| to the desired |ink_drop_state|. Caches |event| as the
+ // last_ripple_triggering_event().
+ //
+ // *** NOTE ***: |event| has been plumbed through on a best effort basis for
+ // the purposes of centering ink drop ripples on located Events. Thus nullptr
+ // has been used by clients who do not have an Event instance available to
+ // them.
+ void AnimateInkDrop(InkDropState state, const ui::Event* event);
Evan Stade 2016/06/14 21:13:24 |event| should be a located event to make it more
bruthig 2016/06/14 21:57:01 Done.
+
// View:
void VisibilityChanged(View* starting_from, bool is_visible) override;
void OnFocus() override;
@@ -47,7 +73,6 @@ class VIEWS_EXPORT InkDropHostView : public View, public InkDropHost {
// Overrideable methods to allow views to provide minor tweaks to the default
// ink drop.
- virtual gfx::Point GetInkDropCenter() const;
virtual SkColor GetInkDropBaseColor() const;
// Should return true if the ink drop is also used to depict focus.
@@ -60,17 +85,14 @@ class VIEWS_EXPORT InkDropHostView : public View, public InkDropHost {
// of the InkDrop.
void SetHasInkDrop(bool has_an_ink_drop);
- // Animates |ink_drop_| to the desired |ink_drop_state|.
- //
- // TODO(bruthig): Enhance to accept a ui::Event parameter so InkDrops can be
- // centered (see https://crbug.com/597273) and disabled for touch events on
- // Windows (see https://crbug.com/595315).
- void AnimateInkDrop(InkDropState ink_drop_state);
-
private:
class InkDropGestureHandler;
+ friend class InkDropGestureHandler;
friend class test::InkDropHostViewTestApi;
+ // The last user Event to trigger an ink drop ripple animation.
+ std::unique_ptr<ui::Event> last_ripple_triggering_event_;
+
std::unique_ptr<InkDrop> ink_drop_;
// Intentionally declared after |ink_drop_| so that it doesn't access a

Powered by Google App Engine
This is Rietveld 408576698