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

Side by Side 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 unified diff | Download patch
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_painted_layer_delegates.h"
6
7 #include "third_party/skia/include/core/SkPaint.h"
8 #include "ui/compositor/paint_recorder.h"
9 #include "ui/gfx/geometry/point.h"
10
11 namespace views {
12
13 ////////////////////////////////////////////////////////////////////////////////
14 //
15 // BasePaintedLayerDelegate
16 //
17
18 BasePaintedLayerDelegate::BasePaintedLayerDelegate(SkColor color)
19 : color_(color) {}
20
21 BasePaintedLayerDelegate::~BasePaintedLayerDelegate() {}
22
23 void BasePaintedLayerDelegate::OnDelegatedFrameDamage(
24 const gfx::Rect& damage_rect_in_dip) {}
25
26 void BasePaintedLayerDelegate::OnDeviceScaleFactorChanged(
27 float device_scale_factor) {}
28
29 base::Closure BasePaintedLayerDelegate::PrepareForLayerBoundsChange() {
30 return base::Closure();
31 }
32
33 ////////////////////////////////////////////////////////////////////////////////
34 //
35 // CircleLayerDelegate
36 //
37
38 CircleLayerDelegate::CircleLayerDelegate(SkColor color, int radius)
39 : BasePaintedLayerDelegate(color), radius_(radius) {}
40
41 CircleLayerDelegate::~CircleLayerDelegate() {}
42
43 void CircleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
44 SkPaint paint;
45 paint.setColor(color());
46 paint.setFlags(SkPaint::kAntiAlias_Flag);
47 paint.setStyle(SkPaint::kFill_Style);
48
49 ui::PaintRecorder recorder(context, gfx::Size(radius_, radius_));
50 gfx::Canvas* canvas = recorder.canvas();
51
52 gfx::Point center_point = gfx::Point(radius_, radius_);
53 canvas->DrawCircle(center_point, radius_, paint);
54 }
55
56 ////////////////////////////////////////////////////////////////////////////////
57 //
58 // RectangleLayerDelegate
59 //
60
61 RectangleLayerDelegate::RectangleLayerDelegate(SkColor color, gfx::Size size)
62 : BasePaintedLayerDelegate(color), size_(size) {}
63
64 RectangleLayerDelegate::~RectangleLayerDelegate() {}
65
66 void RectangleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
67 SkPaint paint;
68 paint.setColor(color());
69 paint.setFlags(SkPaint::kAntiAlias_Flag);
70 paint.setStyle(SkPaint::kFill_Style);
71
72 ui::PaintRecorder recorder(context, size_);
73 gfx::Canvas* canvas = recorder.canvas();
74 canvas->DrawRect(gfx::Rect(size_), paint);
75 }
76
77 ////////////////////////////////////////////////////////////////////////////////
78 //
79 // RoundedRectangleLayerDelegate
80 //
81
82 RoundedRectangleLayerDelegate::RoundedRectangleLayerDelegate(SkColor color,
83 gfx::Size size,
84 int corner_radius)
85 : BasePaintedLayerDelegate(color),
86 size_(size),
87 corner_radius_(corner_radius) {}
88
89 RoundedRectangleLayerDelegate::~RoundedRectangleLayerDelegate() {}
90
91 void RoundedRectangleLayerDelegate::OnPaintLayer(
92 const ui::PaintContext& context) {
93 SkPaint paint;
94 paint.setColor(color());
95 paint.setFlags(SkPaint::kAntiAlias_Flag);
96 paint.setStyle(SkPaint::kFill_Style);
97
98 ui::PaintRecorder recorder(context, size_);
99 gfx::Canvas* canvas = recorder.canvas();
100 canvas->DrawRoundRect(gfx::Rect(size_), corner_radius_, paint);
101 }
102
103 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698