class HandleSlider2D

Inherits: HandleSlider

Handle slider that is positioned in screen-space, and reports 2D movement in screen space (in pixels).

When setting the position the Z coordinate will be ignored, and XY coordinates will be interpreted as pixels relative to the camera its viewed through.

Public

Constructors

HandleSlider2D

HandleSlider2D(const SPtr<SceneHandles> &owner, u32 width, u32 height, Slider2DConstraint constraint = Slider2DConstraint::None, u64 layer = 1)

Constructs a new 2D slider.

owner
Object that that owns the slider.
width
Width of the area of the slider that can be interacted with, in pixels.
height
Height of the area of the slider that can be interacted with, in pixels.
constraint
Optional constraint that determines in which direction is the slider allowed to be
layer
Layer that allows filtering of which sliders are interacted with from a specific camera.

Methods

~HandleSlider2D

~HandleSlider2D() noexcept

Intersects

bool Intersects(const Vector2I &screenPos, const Ray &ray, float &t) const override

Attempts to find an intersection between the provided ray and the slider geometry.

screenPos
Position in screen space at which to look for intersection. Some sliders might ignore this and use the instead.
ray
Ray in world space to try to interect with geometry.
t
Position of the intersection along the ray. Only if intersection happened.

Returns: Whether an intersection was detected.

HandleInput

void HandleInput(const HCamera &camera, const Vector2I &inputDelta) override

Updates a slider that is currently active (being dragged).

camera
Camera through which we're interacting with the slider.
inputDelta
Pointer movement since the last time this method was called.

GetDelta

Vector2I GetDelta() const

Returns a delta value that is the result of dragging/sliding the pointer.

This changes every frame and will be zero unless the slider is active. The value is in screen space (pixels).

Protected

Methods

Activate

void Activate(const HCamera &camera, const Vector2I &pointerPos) override

Triggered when the slider state is changed to active.

Reset

void Reset() override

Triggered when the slider state is changed from active to some other state.

Fields

mWidth

u32 mWidth

mHeight

u32 mHeight

mConstraint

Slider2DConstraint mConstraint

mDelta

Vector2I mDelta

mStartPosition

Vector2I mStartPosition