From 5d91d1e5594e37ca5c282e602407eaeb34c6d986 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 22 Sep 2018 22:57:44 +0800 Subject: Done 3 things: 1. Add some helper functions for create controls with layout params. 2. Fix a bug in measure of linear layout. 3. Fix a bug in exception. --- CruUI/ui/control.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'CruUI/ui/control.h') diff --git a/CruUI/ui/control.h b/CruUI/ui/control.h index 2f23fd21..3810f5ac 100644 --- a/CruUI/ui/control.h +++ b/CruUI/ui/control.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "base.h" @@ -348,5 +349,15 @@ namespace cru // Return the ancestor if one control is the ancestor of the other one, otherwise nullptr. Control* IsAncestorOrDescendant(Control* left, Control* right); + + template + TControl* CreateWithLayout(const LayoutLength& width, const LayoutLength& height, Args&&... args) + { + static_assert(std::is_base_of_v, "TControl is not a control class."); + TControl* control = TControl::Create(std::forward(args)...); + control->GetLayoutParams()->width = width; + control->GetLayoutParams()->height = height; + return control; + } } } -- cgit v1.2.3