From 753008a54761234a9d60dbcb53998c44346e2b92 Mon Sep 17 00:00:00 2001 From: Gregor Parzefall Date: Thu, 25 Apr 2024 20:53:45 +0200 Subject: [PATCH] Don't send unnecessary events --- src/gui/guiScrollBar.cpp | 14 -------------- src/gui/guiScrollBar.h | 2 ++ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/gui/guiScrollBar.cpp b/src/gui/guiScrollBar.cpp index 593de3ef9..a812911d5 100644 --- a/src/gui/guiScrollBar.cpp +++ b/src/gui/guiScrollBar.cpp @@ -75,13 +75,6 @@ bool GUIScrollBar::OnEvent(const SEvent &event) setPosInterpolated(getTargetPos() - small_step); else if (event.GUIEvent.Caller == down_button) setPosInterpolated(getTargetPos() + small_step); - - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = nullptr; - e.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; - Parent->OnEvent(e); return true; } else if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) if (event.GUIEvent.Caller == this) @@ -96,13 +89,6 @@ bool GUIScrollBar::OnEvent(const SEvent &event) s8 d = event.MouseInput.Wheel < 0 ? -1 : 1; s8 h = is_horizontal ? 1 : -1; setPosInterpolated(getTargetPos() + (d * small_step * h)); - - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = nullptr; - e.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; - Parent->OnEvent(e); return true; } break; diff --git a/src/gui/guiScrollBar.h b/src/gui/guiScrollBar.h index fcddf7c0b..a976d1a59 100644 --- a/src/gui/guiScrollBar.h +++ b/src/gui/guiScrollBar.h @@ -51,10 +51,12 @@ public: void setSmallStep(const s32 &step); void setLargeStep(const s32 &step); //! Sets a position immediately, aborting any ongoing interpolation. + // setPos does not send EGET_SCROLL_BAR_CHANGED events for you. void setPos(const s32 &pos); //! Sets a target position for interpolation. // If you want to do an interpolated addition, use // setPosInterpolated(getTargetPos() + x). + // setPosInterpolated takes care of sending EGET_SCROLL_BAR_CHANGED events. void setPosInterpolated(const s32 &pos); void setPageSize(const s32 &size); void setArrowsVisible(ArrowVisibility visible);