PhoenixKitOG.SceneEdit (PhoenixKitOG v0.3.1)

Copy Markdown View Source

Editor-side scene mutations the property panel drives — the counterpart to OpenFresco.Editor.Ops (which owns pointer gestures: move/resize/hit-test/front/delete). Everything here takes untrusted form input, so every field goes through a whitelist + coercion; an unknown field or junk value returns the scene unchanged.

Also owns element insertion defaults (the Insert menu) and the background fill-type switch (Scene.switch_fill/2 retains inactive variants in the fill map itself, so Color → Image → Gradient → Color round-trips losslessly — persisted with the scene).

Summary

Functions

Builds and adds a default element for an Insert-menu kind. Returns {scene, new_element_id}.

Reads an image element's mask back into a preset name — "none", one of the edges, or "custom" for a mask this module didn't build.

Mask-edge preset names the Fade control offers.

Next free PrefixN slot name (Text, Text2, Text3, …).

Moves the element behind every other element (0.2.0 stacking API).

Switches the background fill type via Scene.switch_fill/2 (0.2.0): the fill map itself retains inactive variants, so Color ↔ Image ↔ Gradient round-trips losslessly — in the persisted scene, no LiveView-side stash needed.

Applies a template-props field change (canvas size, background value fields). Background type switches go through switch_background/2.

Applies one property-panel field change to the element id. String fields pass through; {{name}} image/text values become placeholder maps; numeric/enum fields are coerced + clamped; box fields route through Ops.set_box/3. Unknown fields no-op.

Functions

insert(scene, kind)

Builds and adds a default element for an Insert-menu kind. Returns {scene, new_element_id}.

mask_edge_of(arg1)

@spec mask_edge_of(map()) :: String.t()

Reads an image element's mask back into a preset name — "none", one of the edges, or "custom" for a mask this module didn't build.

mask_edges()

@spec mask_edges() :: [String.t()]

Mask-edge preset names the Fade control offers.

next_slot_name(scene, prefix)

@spec next_slot_name(OpenFresco.Scene.t(), String.t()) :: String.t()

Next free PrefixN slot name (Text, Text2, Text3, …).

send_to_back(scene, id)

@spec send_to_back(OpenFresco.Scene.t(), String.t()) :: OpenFresco.Scene.t()

Moves the element behind every other element (0.2.0 stacking API).

switch_background(scene, type)

@spec switch_background(OpenFresco.Scene.t(), String.t()) :: OpenFresco.Scene.t()

Switches the background fill type via Scene.switch_fill/2 (0.2.0): the fill map itself retains inactive variants, so Color ↔ Image ↔ Gradient round-trips losslessly — in the persisted scene, no LiveView-side stash needed.

update_canvas(scene, field, value)

@spec update_canvas(OpenFresco.Scene.t(), String.t(), term()) :: OpenFresco.Scene.t()

Applies a template-props field change (canvas size, background value fields). Background type switches go through switch_background/2.

update_element(scene, id, field, value)

@spec update_element(OpenFresco.Scene.t(), String.t(), String.t(), term()) ::
  OpenFresco.Scene.t()

Applies one property-panel field change to the element id. String fields pass through; {{name}} image/text values become placeholder maps; numeric/enum fields are coerced + clamped; box fields route through Ops.set_box/3. Unknown fields no-op.