From 49dfb2bc9f965b398aa12e711148696d28443eaf Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 13 Mar 2021 16:05:21 +0800 Subject: feat: Scrollbar auto collapse. --- include/cru/platform/gui/UiApplication.hpp | 5 +++++ include/cru/ui/render/ScrollBar.hpp | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'include/cru') diff --git a/include/cru/platform/gui/UiApplication.hpp b/include/cru/platform/gui/UiApplication.hpp index ba85020a..5a5b0b13 100644 --- a/include/cru/platform/gui/UiApplication.hpp +++ b/include/cru/platform/gui/UiApplication.hpp @@ -79,6 +79,9 @@ class TimerAutoCanceler { } TimerAutoCanceler& operator=(TimerAutoCanceler&& other) { + if (&other == this) { + return *this; + } Reset(other.id_); other.id_ = 0; return *this; @@ -101,6 +104,8 @@ class TimerAutoCanceler { id_ = id; } + explicit operator bool() const { return id_; } + private: long long id_; }; diff --git a/include/cru/ui/render/ScrollBar.hpp b/include/cru/ui/render/ScrollBar.hpp index fc2910c4..7cfd2576 100644 --- a/include/cru/ui/render/ScrollBar.hpp +++ b/include/cru/ui/render/ScrollBar.hpp @@ -94,6 +94,11 @@ class ScrollBar : public Object { void SetCursor(); void RestoreCursor(); + void BeginAutoCollapseTimer(); + void StopAutoCollapseTimer(); + + void OnMouseLeave(); + protected: gsl::not_null render_object_; @@ -118,6 +123,8 @@ class ScrollBar : public Object { Event scroll_attempt_event_; std::optional> old_cursor_; + + platform::gui::TimerAutoCanceler auto_collapse_timer_canceler_; }; class HorizontalScrollBar : public ScrollBar { -- cgit v1.2.3