forked from UnigramDev/Unigram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComposition.DirectRectangleClip.cpp
131 lines (103 loc) · 2.79 KB
/
Composition.DirectRectangleClip.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "pch.h"
#include "Composition.DirectRectangleClip.h"
namespace winrt::Telegram::Native::Composition::implementation
{
float DirectRectangleClip::Left() {
return m_left;
}
void DirectRectangleClip::Left(float value) {
m_left = value;
m_impl->SetLeft(value);
}
float DirectRectangleClip::Top() {
return m_top;
}
void DirectRectangleClip::Top(float value) {
m_top = value;
m_impl->SetTop(value);
}
float DirectRectangleClip::Right() {
return m_right;
}
void DirectRectangleClip::Right(float value) {
m_right = value;
m_impl->SetRight(value);
}
float DirectRectangleClip::Bottom() {
return m_bottom;
}
void DirectRectangleClip::Bottom(float value) {
m_bottom = value;
m_impl->SetBottom(value);
}
float DirectRectangleClip::TopLeft() {
return m_topLeft;
}
void DirectRectangleClip::TopLeft(float value) {
m_topLeft = value;
m_impl->SetTopLeftRadiusX(value);
m_impl->SetTopLeftRadiusY(value);
}
float DirectRectangleClip::TopRight() {
return m_topRight;
}
void DirectRectangleClip::TopRight(float value) {
m_topRight = value;
m_impl->SetTopRightRadiusX(value);
m_impl->SetTopRightRadiusY(value);
}
float DirectRectangleClip::BottomRight() {
return m_bottomRight;
}
void DirectRectangleClip::BottomRight(float value) {
m_bottomRight = value;
m_impl->SetBottomRightRadiusX(value);
m_impl->SetBottomRightRadiusY(value);
}
float DirectRectangleClip::BottomLeft() {
return m_bottomLeft;
}
void DirectRectangleClip::BottomLeft(float value) {
m_bottomLeft = value;
m_impl->SetBottomLeftRadiusX(value);
m_impl->SetBottomLeftRadiusY(value);
}
void DirectRectangleClip::Set(float uniform) {
TopLeft(uniform);
TopRight(uniform);
BottomRight(uniform);
BottomLeft(uniform);
}
void DirectRectangleClip::Set(float topLeft, float topRight, float bottomRight, float bottomLeft) {
TopLeft(topLeft);
TopRight(topRight);
BottomRight(bottomRight);
BottomLeft(bottomLeft);
}
void DirectRectangleClip::AnimateTop(Compositor compositor, float from, float to, double duration) {
m_top = to;
HRESULT hr;
auto device = CompositionDevice::Current();
winrt::com_ptr<IDCompositionAnimation> animation;
hr = device->CreateCubicBezierAnimation(compositor, from, to, duration, animation.put());
if (SUCCEEDED(hr)) {
m_impl->SetTop(animation.get());
}
else {
m_impl->SetTop(to);
}
}
void DirectRectangleClip::AnimateBottom(Compositor compositor, float from, float to, double duration) {
m_bottom = to;
HRESULT hr;
auto device = CompositionDevice::Current();
winrt::com_ptr<IDCompositionAnimation> animation;
hr = device->CreateCubicBezierAnimation(compositor, from, to, duration, animation.put());
if (SUCCEEDED(hr)) {
m_impl->SetBottom(animation.get());
}
else {
m_impl->SetBottom(to);
}
}
}