aboutsummaryrefslogtreecommitdiff
path: root/src/ui/mapper/style/CursorStylerMapper.cpp
blob: 3b060c254aca23754e601e21def787eb643dae1b (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
#include "cru/ui/mapper/style/CursorStylerMapper.h"
#include "cru/base/ClonablePtr.h"
#include "cru/platform/gui/Cursor.h"
#include "cru/ui/mapper/MapperRegistry.h"
#include "cru/ui/style/Styler.h"

namespace cru::ui::mapper::style {
bool CursorStylerMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
  return node->GetTag().CaseInsensitiveEqual(u"CursorStyler");
}

ClonablePtr<ui::style::CursorStyler> CursorStylerMapper::DoMapFromXml(
    xml::XmlElementNode* node) {
  auto cursor_mapper =
      MapperRegistry::GetInstance()->GetSharedPtrMapper<platform::gui::ICursor>();
  std::shared_ptr<platform::gui::ICursor> cursor;

  for (auto child : node->GetChildren()) {
    if (child->GetType() == xml::XmlNode::Type::Element &&
        cursor_mapper->XmlElementIsOfThisType(child->AsElement())) {
      cursor = cursor_mapper->MapFromXml(child->AsElement());
    }
  }

  return ui::style::CursorStyler::Create(cursor);
}
}  // namespace cru::ui::mapper::style