aboutsummaryrefslogtreecommitdiff
path: root/src/ui/mapper/CursorMapper.cpp
blob: 00b94b915afec2acf2e07b3e06afff04839fd86d (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
#include "cru/ui/mapper/CursorMapper.h"
#include "cru/platform/gui/Cursor.h"
#include "cru/platform/gui/UiApplication.h"

namespace cru::ui::mapper {
using cru::platform::gui::ICursor;
using cru::platform::gui::SystemCursorType;

std::shared_ptr<ICursor> CursorMapper::DoMapFromString(std::string str) {
  if (str.empty()) return nullptr;

  auto cursor_manager =
      platform::gui::IUiApplication::GetInstance()->GetCursorManager();

  if (cru::string::CaseInsensitiveCompare(str, "arrow") == 0) {
    return cursor_manager->GetSystemCursor(SystemCursorType::Arrow);
  } else if (cru::string::CaseInsensitiveCompare(str, "hand") == 0) {
    return cursor_manager->GetSystemCursor(SystemCursorType::Hand);
  } else if (cru::string::CaseInsensitiveCompare(str, "ibeam") == 0) {
    return cursor_manager->GetSystemCursor(SystemCursorType::IBeam);
  } else {
    throw MapException("Unknown cursor name.");
  }
}

std::shared_ptr<ICursor> CursorMapper::DoMapFromXml(xml::XmlElementNode* node) {
  return MapFromXmlAsStringValue(node, nullptr);
}
}  // namespace cru::ui::mapper