#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); } CursorStylerEditor::~CursorStylerEditor() {} ClonablePtr CursorStylerEditor::GetValue() { auto cursor_manager = platform::gui::IUiApplication::GetInstance()->GetCursorManager(); std::shared_ptr 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) { change_event_.Raise(nullptr); } } } // namespace cru::theme_builder::components::stylers