class EE::UI::UIScrollController

Overview

Allocation-free, frame-rate-independent scroll motion state. More…

#include <uiscrollcontroller.hpp>

class UIScrollController {
public:
    // structs

    struct SmoothTween;

    // methods

    void setPosition(const Vector2f& position, const Vector2f& maxPosition);
    bool scrollBy(const Vector2f& delta, const Vector2f& currentPosition, const Vector2f& maxPosition, bool smooth, Float durationScale = 1.f);
    void beginDrag(const Vector2f& position, const Vector2f& maxPosition);
    bool dragBy(const Vector2f& delta, const Time& elapsed, const Vector2f& maxPosition);
    void endDrag();
    bool update(const Time& elapsed, const Vector2f& maxPosition);
    void stop();
    bool isActive() const;
    bool isDragging() const;
    const Vector2f& getPosition() const;
    const Vector2f& getTarget() const;
    const Vector2f& getVelocity() const;
    Time getWheelScrollDuration() const;
    void setWheelScrollDuration(const Time& duration);
    Vector2f getDragDeceleration() const;
    void setDragDeceleration(const Vector2f& deceleration);
};

Detailed Documentation

Allocation-free, frame-rate-independent scroll motion state.

The controller operates in pixel coordinates but deliberately does not own a widget. This lets virtualized views, translated child views, and text editors share the same motion without forcing them into a common rendering hierarchy.

Methods

void setPosition(const Vector2f& position, const Vector2f& maxPosition)

Synchronizes the controller with an externally changed scroll position and stops motion.

bool scrollBy(const Vector2f& delta, const Vector2f& currentPosition, const Vector2f& maxPosition, bool smooth, Float durationScale = 1.f)

Adds a wheel displacement. Returns false when the target cannot move in either axis.

void beginDrag(const Vector2f& position, const Vector2f& maxPosition)

Starts direct manipulation at the current scroll position.

bool dragBy(const Vector2f& delta, const Time& elapsed, const Vector2f& maxPosition)

Applies a drag displacement and records a filtered release velocity.

void endDrag()

Transitions a direct manipulation into inertial motion.

bool update(const Time& elapsed, const Vector2f& maxPosition)

Advances smooth or inertial motion. Returns true when the position changed.

void stop()

Stops all pending motion at the current controller position.

void setWheelScrollDuration(const Time& duration)

Sets the duration used to visually interpolate one wheel displacement.