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

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

Issue 1280953003: Enhance the material design ripple API so the ripple's state can be controlled by it's owning View. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed some comments from patch set 1. Created 5 years, 4 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_delegate.h
diff --git a/ui/views/animation/ink_drop_delegate.h b/ui/views/animation/ink_drop_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..096e4bd93da0011c3b87407d3322ff7e3079f503
--- /dev/null
+++ b/ui/views/animation/ink_drop_delegate.h
@@ -0,0 +1,64 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/compositor/layer_delegate.h"
+#include "ui/compositor/paint_context.h"
+#include "ui/gfx/geometry/rect.h"
+
+namespace ui {
+class Layer;
+} // namespace ui
+
+namespace views {
+
+// Renders the visual feedback for an ink drop animation. Will render a circle
+// if |circle_| is true, otherwise renders a rounded rectangle.
+class InkDropDelegate : public ui::LayerDelegate {
tdanderson 2015/08/10 16:31:01 Would it ever be necessary to introduce subclasses
bruthig 2015/08/10 21:57:15 Perhaps why do you ask? If the states are the sam
tdanderson 2015/08/11 12:57:37 I don't see any problems, I was just curious. Look
+ public:
+ InkDropDelegate(ui::Layer* layer,
+ SkColor color,
+ int circle_radius,
+ int rounded_rect_corner_radius);
+ ~InkDropDelegate() override;
+
+ // Sets the visual style of the feedback.
+ void set_should_render_circle(bool should_render_circle) {
+ should_render_circle_ = should_render_circle;
+ }
+
+ bool should_render_circle() { return should_render_circle_; }
+
+ // ui::LayerDelegate:
+ void OnPaintLayer(const ui::PaintContext& context) override;
+ void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override;
+ void OnDeviceScaleFactorChanged(float device_scale_factor) override;
+ base::Closure PrepareForLayerBoundsChange() override;
+
+ private:
+ SkColor color() { return color_; }
+
+ ui::Layer* layer() { return layer_; }
tdanderson 2015/08/10 16:31:01 What's the point of having the private accessors c
bruthig 2015/08/10 21:57:15 Whoops, this was left over from experimental work
+
+ // The ui::Layer being rendered to.
+ ui::Layer* layer_;
+
+ // The color to paint.
+ SkColor color_;
+
+ // When true renders a circle, otherwise renders a rounded rectangle.
+ bool should_render_circle_;
+
+ // The radius of the circle.
+ const int circle_radius_;
+
+ // The radius of the rounded rectangles corners.
+ const int rounded_rect_corner_radius_;
+
+ DISALLOW_COPY_AND_ASSIGN(InkDropDelegate);
+};
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698