Skip to content

Editor → User Interface → gizmo_controller.h

ui::gizmo_controller

Syntax

class CONJURE_API gizmo_controller

Constructors

AccessSignatureDescription
publicgizmo_controller();

Important

Additional constructor overloads have been deleted.

Destructors

AccessSignatureDescription
public~gizmo_controller();

Variables

AccessNameTypeDefaultDescription
privatemAwaitReleaseboolfalse
privatemDraggedstd::vector<dragged_entity>{}
privatemDraggingboolfalse
privatemDragOperationgizmo_operationgizmo_operation::TRANSLATE
privatemDragSessionu640
privatemLitAxisstd::optional<gizmo_axis>std::nullopt
privatemManipulationsu320
privatemOperationgizmo_operationgizmo_operation::TRANSLATE
privatemOverHandleboolfalse
privatemPivotmath::mat4math::mat4(1.0f)
privatemSnapRotateDegreesf3215.0f
privatemSnapScalef320.1f
privatemSnapTranslatef320.5f
privatemSpacegizmo_spacegizmo_space::WORLD
privatemUseSnapboolfalse

Functions

Public

active_operation

[[nodiscard]] gizmo_operation active_operation() const noexcept;

The tool the gizmo draws and edits with: the open drag's, else the one chosen.

apply_delta

void apply_delta(
    editor_context &context,
    const math::mat4 &deltaWorld);

Applies a delta matrix to the selection as if the gizmo produced it (tests, keyboard nudges): begins the drag when none is open.

draw

bool draw(
    editor_context &context,
    const math::vec2 &rectMin,
    const math::vec2 &rectSize);

Draws the gizmo for the current selection inside the viewport rectangle and applies the user's manipulation. Call once per frame between ImGui::Begin and End of the viewport window. Returns true in a frame that moved the selection (ImGuizmo reported a manipulation, or a drag's delta was applied).

end_drag

void end_drag(
    editor_context &context);

Ends an open drag and its undo transaction (the release does it in draw()). When the left mouse button is still down, the drag was cut short (the viewport was hidden, the selection went away): draw() then shows no gizmo until the button is released, so the press that belonged to the ended drag cannot start another one.

highlight

[[nodiscard]] gizmo_highlight highlight(
    const editor_context &context) const;

The role the gizmo highlights its handles with (theme_applier.h): ACCENT while editing; while playing or paused PERSIST when every entity the gizmo moves has an entity pin of its own (stopping keeps the drag), PLAY otherwise, a field, component or ancestor pin included (stopping keeps only what those pins cover). draw() colours ImGuizmo with it before every draw.

is_dragging

[[nodiscard]] bool is_dragging() const noexcept;

is_over

[[nodiscard]] bool is_over() const noexcept;

True when the last draw() showed the gizmo and the mouse was over one of its handles (the previous frame's hotspot, as ImGuizmo reports it) or a drag is in progress. False after a draw() that showed no gizmo (no frame, no scene, an empty selection, or a cut-short drag whose button is still down), so the viewport can pick again.

lit_axis

[[nodiscard]] const std::optional<gizmo_axis> &lit_axis() const noexcept;

The axis whose handle the last draw() lit in its hover colour (gizmo_hover_colour): in an edit, the axis handle (or the plane across that axis) ImGuizmo found under the pointer or dragged in its frame before. Nullopt when that was no axis handle, while playing or paused, and after a draw() that showed no gizmo.

manipulation_count

[[nodiscard]] u32 manipulation_count() const noexcept;

operation

[[nodiscard]] gizmo_operation operation() const noexcept;

The tool chosen; the one an open drag uses is active_operation().

set_operation

void set_operation(
    gizmo_operation operation) noexcept;

Chooses the tool. An open drag keeps the tool it began with until it ends: ImGuizmo finishes a drag only in the handler of its own operation, so switching mid-drag would leave it open (and its undo transaction with it) and make the entity jump when the tool came back.

set_snap

void set_snap(
    bool enabled,
    f32 translate,
    f32 rotateDegrees,
    f32 scale) noexcept;

Snapping and its steps: world units for translate (and universal), degrees for rotate, a factor for scale. The defaults are 0.5, 15 and 0.1 with snapping off; the workspace toolbar's Snap toggle and step field drive it.

set_space

void set_space(
    gizmo_space space) noexcept;

snap_enabled

[[nodiscard]] bool snap_enabled() const noexcept;

snap_rotate_degrees

[[nodiscard]] f32 snap_rotate_degrees() const noexcept;

snap_scale

[[nodiscard]] f32 snap_scale() const noexcept;

snap_translate

[[nodiscard]] f32 snap_translate() const noexcept;

space

[[nodiscard]] gizmo_space space() const noexcept;

Private

apply_axis_style

void apply_axis_style(
    gizmo_highlight highlight,
    bool wasOver);

begin_drag

void begin_drag(
    editor_context &context);

gather_selection

[[nodiscard]] bool gather_selection(
    editor_context &context);