From 9a3a9f487b24a7b1afff5e6f07e88096dc5755be Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 23 Feb 2022 21:37:11 +0800 Subject: ... --- include/cru/ui/controls/Control.h | 11 +++++++-- .../cru/ui/mapper/style/CheckedConditionMapper.h | 26 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 include/cru/ui/mapper/style/CheckedConditionMapper.h (limited to 'include') diff --git a/include/cru/ui/controls/Control.h b/include/cru/ui/controls/Control.h index 3293969d..c52a53af 100644 --- a/include/cru/ui/controls/Control.h +++ b/include/cru/ui/controls/Control.h @@ -3,6 +3,7 @@ #include "../events/UiEvents.h" #include "../render/RenderObject.h" #include "../style/StyleRuleSet.h" +#include "cru/ui/render/MeasureRequirement.h" namespace cru::ui::controls { @@ -13,8 +14,7 @@ namespace cru::ui::controls { * - GetRenderObject() * - ForEachChild(const std::function& predicate) * - RemoveChild(Control* child) - * The last two methods are totally for convenient control tree management. The - * former one is even not used. + * The last two methods are totally for convenient control tree management. */ class CRU_UI_API Control : public Object { friend class RootControl; @@ -52,6 +52,13 @@ class CRU_UI_API Control : public Object { public: virtual render::RenderObject* GetRenderObject() const = 0; + render::MeasureSize GetPreferredSize() { + return GetRenderObject()->GetPreferredSize(); + } + void SetPreferredSize(const render::MeasureSize& size) { + GetRenderObject()->SetPreferredSize(size); + } + //*************** region: focus *************** public: bool HasFocus(); diff --git a/include/cru/ui/mapper/style/CheckedConditionMapper.h b/include/cru/ui/mapper/style/CheckedConditionMapper.h new file mode 100644 index 00000000..d62aba60 --- /dev/null +++ b/include/cru/ui/mapper/style/CheckedConditionMapper.h @@ -0,0 +1,26 @@ +#pragma once +#include "../Mapper.h" +#include "IConditionMapper.h" +#include "cru/ui/style/Condition.h" + +namespace cru::ui::mapper::style { +class CRU_UI_API CheckedConditionMapper + : public BasicPtrMapper, + public virtual IConditionMapper { + public: + CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(CheckedConditionMapper) + + public: + bool SupportMapFromXml() override { return true; } + bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; + + ClonablePtr MapConditionFromXml( + xml::XmlElementNode* node) override { + return MapFromXml(node); + } + + protected: + ClonablePtr DoMapFromXml( + xml::XmlElementNode* node) override; +}; +} // namespace cru::ui::mapper::style -- cgit v1.2.3