-
-
Notifications
You must be signed in to change notification settings - Fork 667
Expand file tree
/
Copy pathAnimatedImageBase.cpp
More file actions
71 lines (63 loc) · 2.35 KB
/
Copy pathAnimatedImageBase.cpp
File metadata and controls
71 lines (63 loc) · 2.35 KB
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
#include "pch.h"
#include "AnimatedImageBase.h"
#if __has_include("Controls/AnimatedImageBase.g.cpp")
#include "Controls/AnimatedImageBase.g.cpp"
#endif
namespace winrt::Telegram::Native::Controls::implementation
{
AnimatedImageBase::AnimatedImageBase()
{
m_sizeChangedRevoker = SizeChanged(winrt::auto_revoke, { this, &AnimatedImageBase::HandleSizeChanged });
}
void AnimatedImageBase::OnLoaded()
{
if (auto xamlRoot = XamlRoot())
{
m_rasterizationScale = xamlRoot.RasterizationScale();
m_xamlRootChangedRevoker = xamlRoot.Changed(winrt::auto_revoke, { this, &AnimatedImageBase::HandleXamlRootChanged });
}
}
void AnimatedImageBase::OnUnloaded()
{
if (m_xamlRootChangedRevoker)
{
m_xamlRootChangedRevoker.revoke();
}
}
void AnimatedImageBase::RegisterViewportChanged()
{
if (!m_effectiveViewportChangedRevoker)
{
m_effectiveViewportChangedRevoker = EffectiveViewportChanged(winrt::auto_revoke, { this, &AnimatedImageBase::HandleEffectiveViewportChanged });
}
}
void AnimatedImageBase::UnregisterViewportChanged()
{
if (m_effectiveViewportChangedRevoker)
{
m_effectiveViewportChangedRevoker.revoke();
}
}
void AnimatedImageBase::HandleSizeChanged(winrt::Windows::Foundation::IInspectable const&, winrt::Windows::UI::Xaml::SizeChangedEventArgs const& e)
{
overridable().OnSizeChanged(e);
}
void AnimatedImageBase::HandleXamlRootChanged(winrt::Windows::UI::Xaml::XamlRoot const& sender, winrt::Windows::UI::Xaml::XamlRootChangedEventArgs const& e)
{
auto rasterizationScale = sender.RasterizationScale();
if (rasterizationScale != m_rasterizationScale)
{
m_rasterizationScale = rasterizationScale;
overridable().OnRasterizationScaleChanged(rasterizationScale);
}
}
void AnimatedImageBase::HandleEffectiveViewportChanged(FrameworkElement const& sender, EffectiveViewportChangedEventArgs const& e)
{
auto visible = e.BringIntoViewDistanceX() < sender.ActualWidth() && e.BringIntoViewDistanceY() < sender.ActualHeight();
if (visible != m_visible)
{
m_visible = visible;
overridable().OnViewportChanged(visible);
}
}
}