aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/mapper/style/StylerMapper.h
blob: 569684ab3f0ec6cbab1bf4d486d1ecccd4bcd83b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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