This is a tool to generate JSFX UIs (using my UI library) based on slider definitions.
It's not intended to be full-featured UI editor, and it only produces limited layouts: rows, and groups within those rows. The groups/rows have to be specified using simple comment annotations. It might not work on older browsers.
However, it's hopefully an easy way to get some shinier controls on a JSFX, and the individual controls could be copied and used in a more customised layout if needed.
ui-lib.jsfx-inc
in the same directory as your effect
import "ui-lib.jsfx-inc"
to your header (e.g. underneath the sliders)
@init
, e.g.
@init
freemem = 0; // some empty section of the memory buffer
freemem = ui_setup(freemem); // returns the first index it's not using
// ui:row
// ui:group
// ui:group name=Some Group Name
// format=%i, bias=3, title=New Title
// inverted=0, columns=3
@gfx
section
If you enter JSFX which already has a UI generated by this tool, it will replace the generated section and return the result.
This means once you've done all of the above, you can keep developing your effect (including custom graphics), and occasionally come back to update the UI.
function custom_gfx_func(gfx_w, gfx_h, mouse_x, mouse_y) (
// previous @gfx code
);
// ui:gfx function=custom_gfx_func, height=300
The custom graphics will draw below the generated controls. This is done using an off-screen buffer (gfx_dest
) so if the code also uses its own off-screen buffers, you'll need to make sure it draws back to the original buffer (instead of gfx_dest = -1
).
The height
parameter can be a percentage, or negative (in which case the controls are fixed-height, and this custom section scales).
You can also specify a specific off-screen buffer to use (e.g. buffer=19
), or whether to use a finish over the top (e.g. finish=technical
).
Because the sliders are no longer being handled by the built-in sliders, we might miss out on @slider
updates when the user changes them. If this is a problem, you can avoid this by:
needs_slider_update
.
@slider
code to a function (in @init
) with no arguments, which resets this flag:
function slider_update_function() (
needs_slider_update = 0;
// previous @slider code
);
@gfx
(right at the end), set this flag if the user has interacted at all:
ui_interacted() ? needs_slider_update = 1;
@block
, and call your function if needed:
@block
needs_slider_update ? slider_update_function();
If you have a lot of controls and want a more compact layout, you can add:
// ui:layout compact=1
This produces a layout that lets you fit more rows in.
You can do some (fairly basic) customisation using a PNG template:
filename:0,theme-cyan.png
bitmap-simple
parameter should match the the filename index:
// ui:layout bitmap-simple=0
filename:0,theme-cyan.png
The basic layout is fixed, but you can change the colours and gloss effects.