Don't send unnecessary events

This commit is contained in:
Gregor Parzefall 2024-04-25 20:53:45 +02:00
parent 23b0bf155a
commit 753008a547
2 changed files with 2 additions and 14 deletions

View File

@ -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;

View File

@ -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);