diff options
| author | crupest <crupest@outlook.com> | 2022-05-15 14:15:31 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2022-05-15 14:15:31 +0800 |
| commit | 34a64e6ffefaab007578932ddbab931a25f1d56e (patch) | |
| tree | 541fdb8279e829a129df62288d09916bf23c9200 /src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp | |
| parent | 8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6 (diff) | |
| download | cru-34a64e6ffefaab007578932ddbab931a25f1d56e.tar.gz cru-34a64e6ffefaab007578932ddbab931a25f1d56e.tar.bz2 cru-34a64e6ffefaab007578932ddbab931a25f1d56e.zip | |
...
Diffstat (limited to 'src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp')
| -rw-r--r-- | src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp b/src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp new file mode 100644 index 00000000..9984d81a --- /dev/null +++ b/src/ThemeBuilder/components/stylers/CursorStylerEditor.cpp @@ -0,0 +1,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 |
