aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/host/WindowHost.cpp21
-rw-r--r--src/ui/render/ScrollBar.cpp17
2 files changed, 28 insertions, 10 deletions
diff --git a/src/ui/host/WindowHost.cpp b/src/ui/host/WindowHost.cpp
index 5e107733..eac2ef41 100644
--- a/src/ui/host/WindowHost.cpp
+++ b/src/ui/host/WindowHost.cpp
@@ -422,9 +422,13 @@ void WindowHost::DispatchMouseHoverControlChangeEvent(
void WindowHost::UpdateCursor() {
if (native_window_) {
- const auto capture = GetMouseCaptureControl();
- native_window_->SetCursor(
- (capture ? capture : GetMouseHoverControl())->GetInheritedCursor());
+ if (override_cursor_) {
+ native_window_->SetCursor(override_cursor_);
+ } else {
+ const auto capture = GetMouseCaptureControl();
+ native_window_->SetCursor(
+ (capture ? capture : GetMouseHoverControl())->GetInheritedCursor());
+ }
}
}
@@ -437,4 +441,15 @@ controls::Control* WindowHost::HitTest(const Point& point) {
}
return root_control_;
}
+
+std::shared_ptr<platform::gui::ICursor> WindowHost::GetOverrideCursor() {
+ return override_cursor_;
+}
+
+void WindowHost::SetOverrideCursor(
+ std::shared_ptr<platform::gui::ICursor> cursor) {
+ if (cursor == override_cursor_) return;
+ override_cursor_ = cursor;
+ UpdateCursor();
+}
} // namespace cru::ui::host
diff --git a/src/ui/render/ScrollBar.cpp b/src/ui/render/ScrollBar.cpp
index 4bde6d19..ec583b2a 100644
--- a/src/ui/render/ScrollBar.cpp
+++ b/src/ui/render/ScrollBar.cpp
@@ -14,6 +14,7 @@
#include "cru/ui/UiManager.hpp"
#include "cru/ui/events/UiEvent.hpp"
#include "cru/ui/helper/ClickDetector.hpp"
+#include "cru/ui/host/WindowHost.hpp"
#include "cru/ui/render/ScrollRenderObject.hpp"
#include <algorithm>
@@ -348,22 +349,24 @@ void ScrollBar::OnDraw(platform::graphics::IPainter* painter,
}
void ScrollBar::SetCursor() {
- if (!old_cursor_) {
- if (const auto control = render_object_->GetAttachedControl()) {
- old_cursor_ = control->GetCursor();
- control->SetCursor(
+ if (const auto control = render_object_->GetAttachedControl()) {
+ if (const auto window_host = control->GetWindowHost()) {
+ window_host->SetOverrideCursor(
GetUiApplication()->GetCursorManager()->GetSystemCursor(
platform::gui::SystemCursorType::Arrow));
+ cursor_overrided_ = true;
}
}
}
void ScrollBar::RestoreCursor() {
- if (old_cursor_) {
+ if (cursor_overrided_) {
if (const auto control = render_object_->GetAttachedControl()) {
- control->SetCursor(*old_cursor_);
+ if (const auto window_host = control->GetWindowHost()) {
+ window_host->SetOverrideCursor(nullptr);
+ }
}
- old_cursor_ = std::nullopt;
+ cursor_overrided_ = false;
}
}