aboutsummaryrefslogtreecommitdiff
path: root/src/ui/layout_base.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-11-07 18:54:41 +0800
committercrupest <crupest@outlook.com>2018-11-07 18:54:41 +0800
commit2b5b89e9483063f3af05fb5485043868d447994b (patch)
treeafb0bff66420d0a631416149142549adb5c45dc2 /src/ui/layout_base.h
parent9f7de7f0775b86e3c82d4c5e3427a6f2fd98810b (diff)
downloadcru-2b5b89e9483063f3af05fb5485043868d447994b.tar.gz
cru-2b5b89e9483063f3af05fb5485043868d447994b.tar.bz2
cru-2b5b89e9483063f3af05fb5485043868d447994b.zip
Add min max.
Diffstat (limited to 'src/ui/layout_base.h')
-rw-r--r--src/ui/layout_base.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/ui/layout_base.h b/src/ui/layout_base.h
index 662210bd..4a4c09ea 100644
--- a/src/ui/layout_base.h
+++ b/src/ui/layout_base.h
@@ -101,12 +101,27 @@ namespace cru
constexpr bool Validate() const
{
- return length >= 0.0;
+ if (length < 0.0)
+ return false;
+ if (min.has_value() && min.value() < 0.0)
+ return false;
+ if (max.has_value() && max.value() < 0.0)
+ return false;
+ if (min.has_value() && max.has_value() && min.value() > max.value())
+ return false;
+ return true;
}
+ // only used in exactly mode, specify the exactly side length of content.
float length = 0.0;
MeasureMode mode = MeasureMode::Content;
Alignment alignment = Alignment::Center;
+
+ // min and max specify the min/max side length of content.
+ // they are used as hint and respect the actual size that content needs.
+ // when mode is exactly, length is coerced into the min-max range.
+ std::optional<float> min = std::nullopt;
+ std::optional<float> max = std::nullopt;
};
struct BasicLayoutParams final