blob: 9bbbc9fd22b3f1956979dee9cba227f7b68e0c34 (
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
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
|
#pragma once
#include <optional>
namespace cru
{
namespace ui
{
enum class MeasureMode
{
Exactly,
Content,
Stretch
};
struct MeasureLength final
{
explicit MeasureLength(const float length = 0.0, const MeasureMode mode = MeasureMode::Exactly)
: length(length), mode(mode)
{
}
bool Validate() const
{
return !(mode == MeasureMode::Exactly && length < 0.0);
}
float length;
MeasureMode mode;
};
struct MeasureSize final
{
MeasureLength width;
MeasureLength height;
bool Validate() const
{
return width.Validate() && height.Validate();
}
};
struct OptionalSize final
{
OptionalSize()
: width(std::nullopt), height(std::nullopt)
{
}
OptionalSize(const std::optional<float> width, const std::optional<float> height)
: width(width), height(height)
{
}
OptionalSize(const OptionalSize& other) = default;
OptionalSize(OptionalSize&& other) = default;
OptionalSize& operator = (const OptionalSize& other) = default;
OptionalSize& operator = (OptionalSize&& other) = default;
~OptionalSize() = default;
bool Validate() const
{
if (width.has_value() && width.value() < 0.0)
return false;
if (height.has_value() && height.value() < 0.0)
return false;
return true;
}
std::optional<float> width;
std::optional<float> height;
};
struct BasicLayoutParams
{
BasicLayoutParams() = default;
BasicLayoutParams(const BasicLayoutParams&) = default;
BasicLayoutParams(BasicLayoutParams&&) = default;
BasicLayoutParams& operator = (const BasicLayoutParams&) = default;
BasicLayoutParams& operator = (BasicLayoutParams&&) = default;
virtual ~BasicLayoutParams() = default;
bool Validate() const
{
return size.Validate() && max_size.Validate() && min_size.Validate();
}
MeasureSize size;
OptionalSize min_size;
OptionalSize max_size;
};
}
}
|