aboutsummaryrefslogtreecommitdiff
path: root/src/ui/mapper/style/MarginStylerMapper.cpp
blob: cb2fd7ee3eaa37ce78d98636858014f2a3c89414 (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
#include "cru/ui/mapper/style/MarginStylerMapper.h"
#include "cru/ui/mapper/MapperRegistry.h"
#include "cru/ui/render/MeasureRequirement.h"
#include "cru/ui/style/Styler.h"

namespace cru::ui::mapper::style {
MarginStylerMapper::MarginStylerMapper() { SetAllowedTags({u"MarginStyler"}); }

MarginStylerMapper::~MarginStylerMapper() {}

ClonablePtr<ui::style::MarginStyler> MarginStylerMapper::DoMapFromXml(
    xml::XmlElementNode* node) {
  Thickness thickness;

  auto thickness_mapper = MapperRegistry::GetInstance()->GetMapper<Thickness>();

  auto value_attribute = node->GetOptionalAttributeCaseInsensitive(u"value");
  if (value_attribute) {
    thickness = thickness_mapper->MapFromString(*value_attribute);
  }

  return ui::style::MarginStyler::Create(thickness);
}
}  // namespace cru::ui::mapper::style