From 33256b6549324f3a621d8b12c8a6863b63c898ef Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 25 Feb 2021 15:15:12 +0300 Subject: [PATCH] Proper default button size constraints --- libs/ui/source/default_element_factory.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/ui/source/default_element_factory.cpp b/libs/ui/source/default_element_factory.cpp index 394f508e..99f9d7f5 100644 --- a/libs/ui/source/default_element_factory.cpp +++ b/libs/ui/source/default_element_factory.cpp @@ -53,7 +53,19 @@ namespace psemek::ui geom::box size_constraints() const override { - return {{{100.f, 200.f}, {50.f, 100.f}}}; + auto sc = element::size_constraints(); + + if (label()) + sc = label()->size_constraints(); + + if (auto st = style()) + { + float extra = 2.f * (st->border_width + st->inner_margin); + sc[0] += extra; + sc[1] += extra; + } + + return sc; } private: