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

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

Issue 1390113006: Added material design mouse hover feedback support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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_animation.cc
diff --git a/ui/views/animation/ink_drop_animation.cc b/ui/views/animation/ink_drop_animation.cc
index 4826f78adc8349cd667a09482847d387d3c0d669..d33eb43a0589a43d502ea2d666d1a04190f83901 100644
--- a/ui/views/animation/ink_drop_animation.cc
+++ b/ui/views/animation/ink_drop_animation.cc
@@ -9,17 +9,14 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkPaint.h"
#include "ui/base/ui_base_switches.h"
#include "ui/compositor/callback_layer_animation_observer.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_sequence.h"
-#include "ui/compositor/paint_recorder.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
-#include "ui/gfx/canvas.h"
#include "ui/gfx/transform_util.h"
#include "ui/views/animation/ink_drop_animation_observer.h"
-#include "ui/views/view.h"
+#include "ui/views/animation/ink_drop_painted_layer_delegates.h"
namespace {
@@ -123,116 +120,6 @@ gfx::Transform CalculateRectTransform(const gfx::Point& drawn_center_point,
namespace views {
-// Base ui::LayerDelegate stub that can be extended to paint shapes of a
-// specific color.
-class BasePaintedLayerDelegate : public ui::LayerDelegate {
- public:
- ~BasePaintedLayerDelegate() override;
-
- SkColor color() const { return color_; }
-
- // ui::LayerDelegate:
- void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override;
- void OnDeviceScaleFactorChanged(float device_scale_factor) override;
- base::Closure PrepareForLayerBoundsChange() override;
-
- protected:
- explicit BasePaintedLayerDelegate(SkColor color);
-
- private:
- // The color to paint.
- SkColor color_;
-
- DISALLOW_COPY_AND_ASSIGN(BasePaintedLayerDelegate);
-};
-
-BasePaintedLayerDelegate::BasePaintedLayerDelegate(SkColor color)
- : color_(color) {}
-
-BasePaintedLayerDelegate::~BasePaintedLayerDelegate() {}
-
-void BasePaintedLayerDelegate::OnDelegatedFrameDamage(
- const gfx::Rect& damage_rect_in_dip) {}
-
-void BasePaintedLayerDelegate::OnDeviceScaleFactorChanged(
- float device_scale_factor) {}
-
-base::Closure BasePaintedLayerDelegate::PrepareForLayerBoundsChange() {
- return base::Closure();
-}
-
-// A BasePaintedLayerDelegate that paints a circle of a specified color and
-// radius.
-class CircleLayerDelegate : public BasePaintedLayerDelegate {
- public:
- CircleLayerDelegate(SkColor color, int radius);
- ~CircleLayerDelegate() override;
-
- int radius() const { return radius_; }
-
- // ui::LayerDelegate:
- void OnPaintLayer(const ui::PaintContext& context) override;
-
- private:
- // The radius of the circle.
- int radius_;
-
- DISALLOW_COPY_AND_ASSIGN(CircleLayerDelegate);
-};
-
-CircleLayerDelegate::CircleLayerDelegate(SkColor color, int radius)
- : BasePaintedLayerDelegate(color), radius_(radius) {}
-
-CircleLayerDelegate::~CircleLayerDelegate() {}
-
-void CircleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
- SkPaint paint;
- paint.setColor(color());
- paint.setFlags(SkPaint::kAntiAlias_Flag);
- paint.setStyle(SkPaint::kFill_Style);
-
- ui::PaintRecorder recorder(context, gfx::Size(radius_, radius_));
- gfx::Canvas* canvas = recorder.canvas();
-
- gfx::Point center_point = gfx::Point(radius_, radius_);
- canvas->DrawCircle(center_point, radius_, paint);
-}
-
-// A BasePaintedLayerDelegate that paints a rectangle of a specified color and
-// size.
-class RectangleLayerDelegate : public BasePaintedLayerDelegate {
- public:
- RectangleLayerDelegate(SkColor color, gfx::Size size);
- ~RectangleLayerDelegate() override;
-
- const gfx::Size& size() const { return size_; }
-
- // ui::LayerDelegate:
- void OnPaintLayer(const ui::PaintContext& context) override;
-
- private:
- // The size of the rectangle.
- gfx::Size size_;
-
- DISALLOW_COPY_AND_ASSIGN(RectangleLayerDelegate);
-};
-
-RectangleLayerDelegate::RectangleLayerDelegate(SkColor color, gfx::Size size)
- : BasePaintedLayerDelegate(color), size_(size) {}
-
-RectangleLayerDelegate::~RectangleLayerDelegate() {}
-
-void RectangleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
- SkPaint paint;
- paint.setColor(color());
- paint.setFlags(SkPaint::kAntiAlias_Flag);
- paint.setStyle(SkPaint::kFill_Style);
-
- ui::PaintRecorder recorder(context, size_);
- gfx::Canvas* canvas = recorder.canvas();
- canvas->DrawRect(gfx::Rect(size_), paint);
-}
-
InkDropAnimation::InkDropAnimation(const gfx::Size& large_size,
int large_corner_radius,
const gfx::Size& small_size,

Powered by Google App Engine
This is Rietveld 408576698