diff options
author | crupest <crupest@outlook.com> | 2021-03-13 16:05:21 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-03-13 16:05:21 +0800 |
commit | 49dfb2bc9f965b398aa12e711148696d28443eaf (patch) | |
tree | 7fffb9ad42988709809929802c8d08425eec8a42 /include | |
parent | e19d42f2f89ad6670e6b9a226bcf7abc12003bb5 (diff) | |
download | cru-49dfb2bc9f965b398aa12e711148696d28443eaf.tar.gz cru-49dfb2bc9f965b398aa12e711148696d28443eaf.tar.bz2 cru-49dfb2bc9f965b398aa12e711148696d28443eaf.zip |
feat: Scrollbar auto collapse.
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/platform/gui/UiApplication.hpp | 5 | ||||
-rw-r--r-- | include/cru/ui/render/ScrollBar.hpp | 7 |
2 files changed, 12 insertions, 0 deletions
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<ScrollRenderObject*> render_object_; @@ -118,6 +123,8 @@ class ScrollBar : public Object { Event<Scroll> scroll_attempt_event_; std::optional<std::shared_ptr<platform::gui::ICursor>> old_cursor_; + + platform::gui::TimerAutoCanceler auto_collapse_timer_canceler_; }; class HorizontalScrollBar : public ScrollBar { |