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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/views/animation/ink_drop_delegate.h"
6
7 #include "third_party/skia/include/core/SkPaint.h"
8 #include "ui/compositor/layer.h"
9 #include "ui/compositor/paint_recorder.h"
10 #include "ui/gfx/canvas.h"
11
12 namespace views {
13
14 InkDropDelegate::InkDropDelegate(ui::Layer* layer,
15 SkColor color,
16 int circle_radius,
17 int rounded_rect_corner_radius)
18 : layer_(layer),
19 color_(color),
20 should_render_circle_(true),
21 circle_radius_(circle_radius),
22 rounded_rect_corner_radius_(rounded_rect_corner_radius) {}
23
24 InkDropDelegate::~InkDropDelegate() {}
25
26 void InkDropDelegate::OnPaintLayer(const ui::PaintContext& context) {
27 SkPaint paint;
28 paint.setColor(color_);
29 paint.setFlags(SkPaint::kAntiAlias_Flag);
30 paint.setStyle(SkPaint::kFill_Style);
31
32 gfx::Rect bounds = layer_->bounds();
33
34 ui::PaintRecorder recorder(context, layer_->size());
35 gfx::Canvas* canvas = recorder.canvas();
36 if (should_render_circle()) {
37 gfx::Point midpoint(bounds.width() * 0.5f, bounds.height() * 0.5f);
38 canvas->DrawCircle(midpoint, circle_radius_, paint);
39 } else {
40 canvas->DrawRoundRect(bounds, rounded_rect_corner_radius_, paint);
41 }
42 }
43
44 void InkDropDelegate::OnDelegatedFrameDamage(
45 const gfx::Rect& damage_rect_in_dip) {}
46
47 void InkDropDelegate::OnDeviceScaleFactorChanged(float device_scale_factor) {}
48
49 base::Closure InkDropDelegate::PrepareForLayerBoundsChange() {
50 return base::Closure();
51 }
52
53 } // namespace views
OLDNEW
« 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