diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-12-15 21:27:33 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-12-15 21:27:33 +0800 |
| commit | c77072d586bf7aca58e6465ceab3d11a0be0021f (patch) | |
| tree | 83605be90fd32104ef74bbd1d84d900aaf0271ce /include/cru/ui/mapper/style/StylerMapper.h | |
| parent | bc3fa9650699046f3a87a620282ee43f26b2fa75 (diff) | |
| download | cru-c77072d586bf7aca58e6465ceab3d11a0be0021f.tar.gz cru-c77072d586bf7aca58e6465ceab3d11a0be0021f.tar.bz2 cru-c77072d586bf7aca58e6465ceab3d11a0be0021f.zip | |
Clean up mapper codes.
Diffstat (limited to 'include/cru/ui/mapper/style/StylerMapper.h')
| -rw-r--r-- | include/cru/ui/mapper/style/StylerMapper.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/include/cru/ui/mapper/style/StylerMapper.h b/include/cru/ui/mapper/style/StylerMapper.h new file mode 100644 index 00000000..569684ab --- /dev/null +++ b/include/cru/ui/mapper/style/StylerMapper.h @@ -0,0 +1,39 @@ +#pragma once +#include "../../Base.h" +#include "cru/base/ClonePtr.h" +#include "cru/base/xml/XmlNode.h" +#include "cru/ui/mapper/Mapper.h" +#include "cru/ui/style/Styler.h" + +namespace cru::ui::mapper::style { +using ui::style::Styler; +using cru::ui::style::ApplyBorderStyleInfo; + +struct CRU_UI_API IStylerMapper : virtual Interface { + virtual bool XmlElementIsOfThisType(xml::XmlElementNode* node) = 0; + virtual ClonePtr<Styler> MapStylerFromXml(xml::XmlElementNode* node) = 0; +}; + +#define CRU_DECLARE_STYLER_MAPPER(styler_name) \ + using ui::style::styler_name##Styler; \ + class CRU_UI_API styler_name##StylerMapper \ + : public BasicClonePtrMapper<styler_name##Styler>, \ + public virtual IStylerMapper { \ + CRU_UI_DECLARE_CAN_MAP_FROM_XML_ELEMENT_TAG(styler_name##Styler, \ + ClonePtr<styler_name##Styler>) \ + \ + ClonePtr<Styler> MapStylerFromXml(xml::XmlElementNode* node) override { \ + return MapFromXml(node); \ + } \ + }; + +CRU_DECLARE_STYLER_MAPPER(Border) +CRU_DECLARE_STYLER_MAPPER(ContentBrush) +CRU_DECLARE_STYLER_MAPPER(Cursor) +CRU_DECLARE_STYLER_MAPPER(Font) +CRU_DECLARE_STYLER_MAPPER(Margin) +CRU_DECLARE_STYLER_MAPPER(Padding) +CRU_DECLARE_STYLER_MAPPER(PreferredSize) + +#undef CRU_DECLARE_STYLER_MAPPER +} // namespace cru::ui::mapper::style |
