DEKI/ENGINE docs
manual api reference
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
Loading...
Searching...
No Matches
DekiEditor::Motion Namespace Reference

Shared timing and easing for animated editor UI. More...

Classes

struct  RowHover
 List rows that ImGui draws (tree nodes, selectables) with a fading highlight. More...

Functions

bool AnyMoving ()
 Whether anything animated this frame is still moving.
float EaseOut (float t)
 Curves: map linear progress t in [0, 1] to eased progress.
float Follow (ImGuiID id, float target, float seconds, float epsilon=0.01f)
 Chase an unbounded value (a scroll position, a zoom level): covers most of the remaining distance within seconds, fast at first and settling (exponential ease-out), and snaps when within epsilon.
float Hover (ImGuiID id, bool hovered)
 Hover highlight in one call: eased 0 -> 1 while hovered, back to 0 after.
float ItemHover (bool hovered)
 For a hand-drawn hover background, right after its item (usually an InvisibleButton): the fade for the item just submitted.
float ItemPress ()
 Press feedback for the same kind of item, also right after it: eased 0 -> 1 while it is held under the pointer, back to 0 after release.
ImVec4 Mix (const ImVec4 &a, const ImVec4 &b, float t)
 Blend two colours by t in [0, 1].
ImU32 PressShade (float t)
float Progress (ImGuiID id, float fraction)
 A progress bar's fill: glides toward fraction as work reports it in steps, and drops back at once when it goes down (a new run starting at 0).
bool ReduceMotion ()
 Reduce motion: every animation lands on its target the frame it is asked for.
float RowHighlight (ImGuiID id, bool selected, bool hovered, float selectedAlpha, float hoveredAlpha, float *outSelected=nullptr)
 A row's highlight strength: the stronger of its selection fade (scaled by selectedAlpha) and its hover fade (by hoveredAlpha).
void Set (ImGuiID id, float value)
 Jump id to value now, with no animation (e.g.
void SetReduceMotion (bool reduce)
float Smooth (float t)
float To (ImGuiID id, float target, float seconds)
 Move id's value linearly toward target so a full 0 -> 1 sweep takes seconds, and return it.
float ToFrom (ImGuiID id, float from, float target, float seconds)
 Like To, but the first sighting starts at from instead of the target, for things that should animate IN when they first appear (a popup opening, a toast arriving).
ImU32 WithAlpha (ImU32 col, float t)
 col with its alpha scaled by t in [0, 1].

Variables

constexpr float kFast = 0.10f
constexpr float kNormal = 0.14f
constexpr float kSlow = 0.20f

Detailed Description

Shared timing and easing for animated editor UI.

Function Documentation

◆ AnyMoving()

bool DekiEditor::Motion::AnyMoving ( )

Whether anything animated this frame is still moving.

Lets a caller keep redrawing while motion is in flight and rest once it settles.

◆ EaseOut()

float DekiEditor::Motion::EaseOut ( float t)
inline

Curves: map linear progress t in [0, 1] to eased progress.

◆ Follow()

float DekiEditor::Motion::Follow ( ImGuiID id,
float target,
float seconds,
float epsilon = 0.01f )

Chase an unbounded value (a scroll position, a zoom level): covers most of the remaining distance within seconds, fast at first and settling (exponential ease-out), and snaps when within epsilon.

First sighting snaps to the target.

◆ Hover()

float DekiEditor::Motion::Hover ( ImGuiID id,
bool hovered )
inline

Hover highlight in one call: eased 0 -> 1 while hovered, back to 0 after.

◆ ItemHover()

float DekiEditor::Motion::ItemHover ( bool hovered)
inline

For a hand-drawn hover background, right after its item (usually an InvisibleButton): the fade for the item just submitted.

Draw the background while this is above 0, with its colour through WithAlpha, and it fades in and out instead of switching.

◆ ItemPress()

float DekiEditor::Motion::ItemPress ( )
inline

Press feedback for the same kind of item, also right after it: eased 0 -> 1 while it is held under the pointer, back to 0 after release.

Draw PressShade over the item's background at this value and it dips while pressed. (Native ImGui buttons get the same through PressMotion, with no call.)

◆ Mix()

ImVec4 DekiEditor::Motion::Mix ( const ImVec4 & a,
const ImVec4 & b,
float t )
inline

Blend two colours by t in [0, 1].

◆ PressShade()

ImU32 DekiEditor::Motion::PressShade ( float t)
inline

◆ Progress()

float DekiEditor::Motion::Progress ( ImGuiID id,
float fraction )
inline

A progress bar's fill: glides toward fraction as work reports it in steps, and drops back at once when it goes down (a new run starting at 0).

◆ ReduceMotion()

bool DekiEditor::Motion::ReduceMotion ( )

Reduce motion: every animation lands on its target the frame it is asked for.

Stored in the editor settings ("editor.reduceMotion"), read once and cached, so the check costs nothing per widget.

◆ RowHighlight()

float DekiEditor::Motion::RowHighlight ( ImGuiID id,
bool selected,
bool hovered,
float selectedAlpha,
float hoveredAlpha,
float * outSelected = nullptr )
inline

A row's highlight strength: the stronger of its selection fade (scaled by selectedAlpha) and its hover fade (by hoveredAlpha).

Draw the row as selected while this is above 0, with the highlight colour at this alpha as both its normal and hovered background. outSelected receives the eased selection fade alone, for anything else that marks selection.

◆ Set()

void DekiEditor::Motion::Set ( ImGuiID id,
float value )

Jump id to value now, with no animation (e.g.

a scroll the user dragged directly, which the follower must not fight).

◆ SetReduceMotion()

void DekiEditor::Motion::SetReduceMotion ( bool reduce)

◆ Smooth()

float DekiEditor::Motion::Smooth ( float t)
inline

◆ To()

float DekiEditor::Motion::To ( ImGuiID id,
float target,
float seconds )

Move id's value linearly toward target so a full 0 -> 1 sweep takes seconds, and return it.

Time-based (the same length at 60 and 144 Hz). A value seen for the first time starts AT its target: a panel that just opened shows its state instead of animating everything in it from zero. Pair with an easing curve below for the shape.

◆ ToFrom()

float DekiEditor::Motion::ToFrom ( ImGuiID id,
float from,
float target,
float seconds )

Like To, but the first sighting starts at from instead of the target, for things that should animate IN when they first appear (a popup opening, a toast arriving).

◆ WithAlpha()

ImU32 DekiEditor::Motion::WithAlpha ( ImU32 col,
float t )
inline

col with its alpha scaled by t in [0, 1].

Variable Documentation

◆ kFast

float DekiEditor::Motion::kFast = 0.10f
constexpr

◆ kNormal

float DekiEditor::Motion::kNormal = 0.14f
constexpr

◆ kSlow

float DekiEditor::Motion::kSlow = 0.20f
constexpr