blob: 9984d81a99736b79eb374807c73afec3913cd66a (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 | #include "CursorStylerEditor.h"
#include "cru/platform/gui/Cursor.h"
#include "cru/platform/gui/UiApplication.h"
namespace cru::theme_builder::components::stylers {
CursorStylerEditor::CursorStylerEditor() {
  SetLabel(u"Cursor Styler");
  GetContainer()->AddChild(cursor_select_.GetRootControl());
  cursor_select_.SetLabel(u"Cursor");
  cursor_select_.SetItems({u"arrow", u"hand", u"ibeam"});
  cursor_select_.SetSelectedIndex(0);
  ConnectChangeEvent(cursor_select_);
}
CursorStylerEditor::~CursorStylerEditor() {}
ClonablePtr<ui::style::CursorStyler> CursorStylerEditor::GetValue() {
  auto cursor_manager =
      platform::gui::IUiApplication::GetInstance()->GetCursorManager();
  std::shared_ptr<platform::gui::ICursor> cursor;
  switch (cursor_select_.GetSelectedIndex()) {
    case 0:
      cursor = cursor_manager->GetSystemCursor(
          platform::gui::SystemCursorType::Arrow);
      break;
    case 1:
      cursor = cursor_manager->GetSystemCursor(
          platform::gui::SystemCursorType::Hand);
      break;
    case 2:
      cursor = cursor_manager->GetSystemCursor(
          platform::gui::SystemCursorType::IBeam);
      break;
  }
  return ui::style::CursorStyler::Create(cursor);
}
void CursorStylerEditor::SetValue(ui::style::CursorStyler* styler,
                                  bool trigger_change) {
  auto cursor_manager =
      platform::gui::IUiApplication::GetInstance()->GetCursorManager();
  auto cursor = styler->GetCursor();
  if (cursor ==
      cursor_manager->GetSystemCursor(platform::gui::SystemCursorType::Arrow)) {
    cursor_select_.SetSelectedIndex(0);
  } else if (cursor == cursor_manager->GetSystemCursor(
                           platform::gui::SystemCursorType::Hand)) {
    cursor_select_.SetSelectedIndex(1);
  } else if (cursor == cursor_manager->GetSystemCursor(
                           platform::gui::SystemCursorType::IBeam)) {
    cursor_select_.SetSelectedIndex(2);
  }
  if (trigger_change) {
    RaiseChangeEvent();
  }
}
}  // namespace cru::theme_builder::components::stylers
 |