mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Smooth scrolling (#14562)
This commit is contained in:
parent
05d5dc4cec
commit
73dbd2f0ab
5 changed files with 105 additions and 44 deletions
|
@ -13,6 +13,7 @@ the arrow buttons where there is insufficient space.
|
|||
#pragma once
|
||||
|
||||
#include "irrlichttypes_extrabloated.h"
|
||||
#include <optional>
|
||||
|
||||
class ISimpleTextureSource;
|
||||
|
||||
|
@ -33,21 +34,30 @@ public:
|
|||
DEFAULT
|
||||
};
|
||||
|
||||
virtual void draw();
|
||||
virtual void updateAbsolutePosition();
|
||||
virtual bool OnEvent(const SEvent &event);
|
||||
virtual void draw() override;
|
||||
virtual void updateAbsolutePosition() override;
|
||||
virtual bool OnEvent(const SEvent &event) override;
|
||||
virtual void OnPostRender(u32 time_ms) override;
|
||||
|
||||
s32 getMax() const { return max_pos; }
|
||||
s32 getMin() const { return min_pos; }
|
||||
s32 getLargeStep() const { return large_step; }
|
||||
s32 getSmallStep() const { return small_step; }
|
||||
s32 getPos() const;
|
||||
s32 getTargetPos() const;
|
||||
|
||||
void setMax(const s32 &max);
|
||||
void setMin(const s32 &min);
|
||||
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);
|
||||
|
||||
|
@ -79,4 +89,11 @@ private:
|
|||
video::SColor current_icon_color;
|
||||
|
||||
ISimpleTextureSource *m_tsrc;
|
||||
|
||||
void setPosRaw(const s32 &pos);
|
||||
void updatePos();
|
||||
std::optional<s32> target_pos;
|
||||
u32 last_time_ms = 0;
|
||||
u32 last_delta_ms = 17; // assume 60 FPS
|
||||
void interpolatePos();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue