-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverlayPanel.cpp
More file actions
57 lines (49 loc) · 1.27 KB
/
Copy pathOverlayPanel.cpp
File metadata and controls
57 lines (49 loc) · 1.27 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
#include "OverlayPanel.h"
namespace FD2D
{
OverlayPanel::OverlayPanel()
: Panel()
{
}
OverlayPanel::OverlayPanel(const std::wstring& name)
: Panel(name)
{
}
Size OverlayPanel::Measure(Size available)
{
// OverlayPanel uses the maximum size of its children, but does not exceed the available size
Size maxSize {};
for (auto& child : ChildrenInOrder())
{
if (child)
{
Size s = child->Measure(available);
maxSize.w = (std::max)(maxSize.w, s.w);
maxSize.h = (std::max)(maxSize.h, s.h);
}
}
// Clamp to not exceed the available size
if (available.w > 0.0f && maxSize.w > available.w)
{
maxSize.w = available.w;
}
if (available.h > 0.0f && maxSize.h > available.h)
{
maxSize.h = available.h;
}
m_desired = maxSize;
return m_desired;
}
void OverlayPanel::Arrange(Rect finalRect)
{
for (auto& child : ChildrenInOrder())
{
if (child)
{
child->Arrange(finalRect);
}
}
m_bounds = finalRect;
m_layoutRect = ToD2D(finalRect);
}
}