Chromium Code Reviews| 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..2511d4b551e76cb71be1664f138265a884ede03a |
| --- /dev/null |
| +++ b/ui/views/animation/ink_drop_delegate.h |
| @@ -0,0 +1,65 @@ |
| +// 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 { |
|
jonross
2015/08/07 17:14:31
Can you change the similarity setting on your revi
bruthig
2015/08/07 22:00:45
I will have to try playing around with this...
|
| + 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; |
| + |
| + protected: |
|
jonross
2015/08/07 17:14:31
Curious as to why we have these protected accessor
bruthig
2015/08/07 22:00:45
Whoops, this was left over from experimental work.
|
| + SkColor color() { return color_; } |
| + |
| + ui::Layer* layer() { return layer_; } |
| + |
| + private: |
| + // 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 |