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

Unified Diff: ui/views/animation/ink_drop_painted_layer_delegates.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_painted_layer_delegates.cc
diff --git a/ui/views/animation/ink_drop_painted_layer_delegates.cc b/ui/views/animation/ink_drop_painted_layer_delegates.cc
new file mode 100644
index 0000000000000000000000000000000000000000..05065ee02d4d8a74815b517b8758b2b955d9927b
--- /dev/null
+++ b/ui/views/animation/ink_drop_painted_layer_delegates.cc
@@ -0,0 +1,103 @@
+// 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 "ui/views/animation/ink_drop_painted_layer_delegates.h"
+
+#include "third_party/skia/include/core/SkPaint.h"
+#include "ui/compositor/paint_recorder.h"
+#include "ui/gfx/geometry/point.h"
+
+namespace views {
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// RoundedRectangleLayerDelegate
+//
+
+RoundedRectangleLayerDelegate::RoundedRectangleLayerDelegate(SkColor color,
+ gfx::Size size,
+ int corner_radius)
+ : BasePaintedLayerDelegate(color),
+ size_(size),
+ corner_radius_(corner_radius) {}
+
+RoundedRectangleLayerDelegate::~RoundedRectangleLayerDelegate() {}
+
+void RoundedRectangleLayerDelegate::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->DrawRoundRect(gfx::Rect(size_), corner_radius_, paint);
+}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698