aboutsummaryrefslogtreecommitdiff
path: root/CruUI/ui/layout_base.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-09-02 00:15:50 +0800
committercrupest <crupest@outlook.com>2018-09-02 00:15:50 +0800
commitd0fe3828bdda050316a331cefecec88987963b3e (patch)
tree02e25b43d9fba291f976cfbfdd30fc52f49a52b6 /CruUI/ui/layout_base.h
parent956a401f9c955f26b7e661dc80f76bfc43fc4124 (diff)
downloadcru-d0fe3828bdda050316a331cefecec88987963b3e.tar.gz
cru-d0fe3828bdda050316a331cefecec88987963b3e.tar.bz2
cru-d0fe3828bdda050316a331cefecec88987963b3e.zip
...
Diffstat (limited to 'CruUI/ui/layout_base.h')
-rw-r--r--CruUI/ui/layout_base.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/CruUI/ui/layout_base.h b/CruUI/ui/layout_base.h
index 9bbbc9fd..409c2875 100644
--- a/CruUI/ui/layout_base.h
+++ b/CruUI/ui/layout_base.h
@@ -85,7 +85,21 @@ namespace cru
bool Validate() const
{
- return size.Validate() && max_size.Validate() && min_size.Validate();
+ if (!(size.Validate() && max_size.Validate() && min_size.Validate()))
+ return false;
+
+ auto&& f = [](const std::optional<float> max_length, const std::optional<float> min_length) -> bool
+ {
+ return max_length.has_value() && min_length.has_value() && max_length.value() < min_length.value();
+ };
+
+ if (!f(max_size.width, min_size.width))
+ return false;
+
+ if (!f(max_size.height, min_size.height))
+ return false;
+
+ return true;
}
MeasureSize size;