blob: 12dde02566fa2059e932d45c391a4e0f4a2d595e (
plain)
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
|
#include "margin_container.h"
namespace cru::ui::controls
{
inline float AtLeast0(const float value)
{
return value < 0 ? 0 : value;
}
inline Size AtLeast0(const Size& size)
{
return Size(AtLeast0(size.width), AtLeast0(size.height));
}
MarginContainer::MarginContainer(const Thickness& margin)
: Control(true), margin_(margin)
{
}
void MarginContainer::SetMargin(const Thickness& margin)
{
margin_ = margin;
InvalidateLayout();
}
Size MarginContainer::OnMeasure(const Size& available_size)
{
return DefaultMeasureWithPadding(available_size, margin_);
}
void MarginContainer::OnLayout(const Rect& rect)
{
DefaultLayoutWithPadding(rect, margin_);
}
}
|