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

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

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: Fixed minor typo. 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
« no previous file with comments | « ui/views/animation/ink_drop_delegate.h ('k') | ui/views/animation/ink_drop_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/ink_drop_delegate.cc
diff --git a/ui/views/animation/ink_drop_delegate.cc b/ui/views/animation/ink_drop_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d2b3c7124cf474dbe86a04e956c74b9e0341d9a4
--- /dev/null
+++ b/ui/views/animation/ink_drop_delegate.cc
@@ -0,0 +1,53 @@
+// 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_delegate.h"
+
+#include "third_party/skia/include/core/SkPaint.h"
+#include "ui/compositor/layer.h"
+#include "ui/compositor/paint_recorder.h"
+#include "ui/gfx/canvas.h"
+
+namespace views {
+
+InkDropDelegate::InkDropDelegate(ui::Layer* layer,
+ SkColor color,
+ int circle_radius,
+ int rounded_rect_corner_radius)
+ : layer_(layer),
+ color_(color),
+ should_render_circle_(true),
+ circle_radius_(circle_radius),
+ rounded_rect_corner_radius_(rounded_rect_corner_radius) {}
+
+InkDropDelegate::~InkDropDelegate() {}
+
+void InkDropDelegate::OnPaintLayer(const ui::PaintContext& context) {
+ SkPaint paint;
+ paint.setColor(color_);
+ paint.setFlags(SkPaint::kAntiAlias_Flag);
+ paint.setStyle(SkPaint::kFill_Style);
+
+ gfx::Rect bounds = layer_->bounds();
+
+ ui::PaintRecorder recorder(context, layer_->size());
+ gfx::Canvas* canvas = recorder.canvas();
+ if (should_render_circle()) {
+ gfx::Point midpoint(bounds.width() * 0.5f, bounds.height() * 0.5f);
+ canvas->DrawCircle(midpoint, circle_radius_, paint);
+ } else {
+ canvas->DrawRoundRect(bounds, rounded_rect_corner_radius_, paint);
+ }
+}
+
+void InkDropDelegate::OnDelegatedFrameDamage(
+ const gfx::Rect& damage_rect_in_dip) {}
+
+void InkDropDelegate::OnDeviceScaleFactorChanged(float device_scale_factor) {}
+
+base::Closure InkDropDelegate::PrepareForLayerBoundsChange() {
+ return base::Closure();
+}
+
+} // namespace views
« no previous file with comments | « ui/views/animation/ink_drop_delegate.h ('k') | ui/views/animation/ink_drop_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698