diff options
author | crupest <crupest@outlook.com> | 2021-05-11 16:51:52 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-05-11 16:51:52 +0800 |
commit | f54032b94817bc5a03be68d39758e9b3d67a1b59 (patch) | |
tree | 4c40cf74302678a07873adab4d5d5ad6348b403b /src/ui/render/ScrollBar.cpp | |
parent | 5c050b44558856ad0fe41dab95f97ea0a59d77eb (diff) | |
download | cru-f54032b94817bc5a03be68d39758e9b3d67a1b59.tar.gz cru-f54032b94817bc5a03be68d39758e9b3d67a1b59.tar.bz2 cru-f54032b94817bc5a03be68d39758e9b3d67a1b59.zip |
...
Diffstat (limited to 'src/ui/render/ScrollBar.cpp')
-rw-r--r-- | src/ui/render/ScrollBar.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/ui/render/ScrollBar.cpp b/src/ui/render/ScrollBar.cpp index 84a6fbe9..4bde6d19 100644 --- a/src/ui/render/ScrollBar.cpp +++ b/src/ui/render/ScrollBar.cpp @@ -122,7 +122,7 @@ void ScrollBar::InstallHandlers(controls::Control* control) { event_guard_.Clear(); if (control != nullptr) { event_guard_ += - control->MouseDownEvent()->Bubble()->PrependShortCircuitHandler( + control->MouseDownEvent()->Tunnel()->PrependShortCircuitHandler( [control, this](event::MouseButtonEventArgs& event) { if (event.GetButton() == mouse_buttons::left && IsEnabled() && IsExpanded()) { @@ -176,7 +176,7 @@ void ScrollBar::InstallHandlers(controls::Control* control) { }); event_guard_ += - control->MouseUpEvent()->Bubble()->PrependShortCircuitHandler( + control->MouseUpEvent()->Tunnel()->PrependShortCircuitHandler( [control, this](event::MouseButtonEventArgs& event) { if (mouse_press_ != std::nullopt) { mouse_press_ = std::nullopt; @@ -201,7 +201,7 @@ void ScrollBar::InstallHandlers(controls::Control* control) { }); event_guard_ += - control->MouseMoveEvent()->Bubble()->PrependShortCircuitHandler( + control->MouseMoveEvent()->Tunnel()->PrependShortCircuitHandler( [this](event::MouseEventArgs& event) { if (move_thumb_start_) { auto new_scroll_position = CalculateNewScrollPosition( @@ -247,7 +247,7 @@ void ScrollBar::InstallHandlers(controls::Control* control) { }); event_guard_ += - control->MouseLeaveEvent()->Bubble()->PrependShortCircuitHandler( + control->MouseLeaveEvent()->Tunnel()->PrependShortCircuitHandler( [this](event::MouseEventArgs&) { if (IsExpanded() && !move_thumb_start_) { if (mouse_hover_ != std::nullopt) { @@ -556,13 +556,11 @@ float HorizontalScrollBar::CalculateNewScrollPosition( } bool HorizontalScrollBar::CanScrollUp() { - return render_object_->GetScrollOffset().x > 0.0; + return render_object_->HorizontalCanScrollUp(); } bool HorizontalScrollBar::CanScrollDown() { - return render_object_->GetScrollOffset().x < - render_object_->GetFirstChild()->GetSize().width - - render_object_->GetViewRect().width; + return render_object_->HorizontalCanScrollDown(); } VerticalScrollBar::VerticalScrollBar( @@ -705,13 +703,11 @@ float VerticalScrollBar::CalculateNewScrollPosition( } bool VerticalScrollBar::CanScrollUp() { - return render_object_->GetScrollOffset().y > 0.0; + return render_object_->VerticalCanScrollUp(); } bool VerticalScrollBar::CanScrollDown() { - return render_object_->GetScrollOffset().y < - render_object_->GetFirstChild()->GetSize().height - - render_object_->GetViewRect().height; + return render_object_->VerticalCanScrollDown(); } ScrollBarDelegate::ScrollBarDelegate( |