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

Side by Side Diff: ui/views/animation/ink_drop_mask.h

Issue 2510603003: Add ink drop ripple to status tray (Closed)
Patch Set: Addressed review comments Created 4 years, 1 month 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_host_view.cc ('k') | ui/views/animation/ink_drop_mask.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_MASK_H_ 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_MASK_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_MASK_H_ 6 #define UI_VIEWS_ANIMATION_INK_DROP_MASK_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/compositor/layer.h" 9 #include "ui/compositor/layer.h"
10 #include "ui/compositor/layer_delegate.h" 10 #include "ui/compositor/layer_delegate.h"
11 #include "ui/gfx/geometry/insets.h"
11 #include "ui/gfx/geometry/point.h" 12 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
13 #include "ui/views/views_export.h" 14 #include "ui/views/views_export.h"
14 15
15 namespace views { 16 namespace views {
16 17
17 // Base class for different ink drop masks. It is responsible for creating the 18 // Base class for different ink drop masks. It is responsible for creating the
18 // ui::Layer that can be set as the mask layer for ink drop layer. 19 // ui::Layer that can be set as the mask layer for ink drop layer. Note that the
20 // mask's layer size (passed in the constructor) should always match size of the
21 // layer it is masking.
19 class VIEWS_EXPORT InkDropMask : public ui::LayerDelegate { 22 class VIEWS_EXPORT InkDropMask : public ui::LayerDelegate {
20 public: 23 public:
21 ~InkDropMask() override; 24 ~InkDropMask() override;
22 25
26 // Should be called whenever the masked layer is resized so that the mask
27 // layer size always matches that of the layer it is masking.
28 void UpdateLayerSize(const gfx::Size& new_layer_size);
29
23 ui::Layer* layer() { return &layer_; } 30 ui::Layer* layer() { return &layer_; }
24 31
25 protected: 32 protected:
26 explicit InkDropMask(const gfx::Size& layer_size); 33 explicit InkDropMask(const gfx::Size& layer_size);
27 34
28 private: 35 private:
29 // Overriden from ui::LayerDelegate: 36 // Overriden from ui::LayerDelegate:
30 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; 37 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override;
31 38
32 void OnDeviceScaleFactorChanged(float device_scale_factor) override; 39 void OnDeviceScaleFactorChanged(float device_scale_factor) override;
33 40
34 ui::Layer layer_; 41 ui::Layer layer_;
35 42
36 DISALLOW_COPY_AND_ASSIGN(InkDropMask); 43 DISALLOW_COPY_AND_ASSIGN(InkDropMask);
37 }; 44 };
38 45
39 // A rectangular ink drop mask with rounded corners. 46 // A rectangular ink drop mask with rounded corners.
40 class VIEWS_EXPORT RoundRectInkDropMask : public InkDropMask { 47 class VIEWS_EXPORT RoundRectInkDropMask : public InkDropMask {
41 public: 48 public:
42 RoundRectInkDropMask(const gfx::Size& layer_size, 49 RoundRectInkDropMask(const gfx::Size& layer_size,
43 const gfx::Rect& mask_bounds, 50 const gfx::Insets& mask_insets,
44 int corner_radius); 51 int corner_radius);
45 52
46 private: 53 private:
47 // Overriden from InkDropMask: 54 // Overriden from InkDropMask:
48 void OnPaintLayer(const ui::PaintContext& context) override; 55 void OnPaintLayer(const ui::PaintContext& context) override;
49 56
50 gfx::Rect mask_bounds_; 57 gfx::Insets mask_insets_;
51 int corner_radius_; 58 int corner_radius_;
52 59
53 DISALLOW_COPY_AND_ASSIGN(RoundRectInkDropMask); 60 DISALLOW_COPY_AND_ASSIGN(RoundRectInkDropMask);
54 }; 61 };
55 62
56 // A circular ink drop mask. 63 // A circular ink drop mask.
57 class VIEWS_EXPORT CircleInkDropMask : public InkDropMask { 64 class VIEWS_EXPORT CircleInkDropMask : public InkDropMask {
58 public: 65 public:
59 CircleInkDropMask(const gfx::Size& layer_size, 66 CircleInkDropMask(const gfx::Size& layer_size,
60 const gfx::Point& mask_center, 67 const gfx::Point& mask_center,
61 int mask_radius); 68 int mask_radius);
62 69
63 private: 70 private:
64 // Overriden from InkDropMask: 71 // Overriden from InkDropMask:
65 void OnPaintLayer(const ui::PaintContext& context) override; 72 void OnPaintLayer(const ui::PaintContext& context) override;
66 73
67 gfx::Point mask_center_; 74 gfx::Point mask_center_;
68 int mask_radius_; 75 int mask_radius_;
69 76
70 DISALLOW_COPY_AND_ASSIGN(CircleInkDropMask); 77 DISALLOW_COPY_AND_ASSIGN(CircleInkDropMask);
71 }; 78 };
72 79
73 } // namespace views 80 } // namespace views
74 81
75 #endif // UI_VIEWS_ANIMATION_INK_DROP_MASK_H_ 82 #endif // UI_VIEWS_ANIMATION_INK_DROP_MASK_H_
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_host_view.cc ('k') | ui/views/animation/ink_drop_mask.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698