hi @piever, I have no experience of Interact.jl-based GUI before, so please correct me if I’m wrong. After reading the docs, I feel like the underlying design between ImGui and Interact are quite different.
ImGui is immediate mode UI that doesn’t hold any hidden states, which means it manipulates the value and does “drawing” stuff (emits vertices, textures, drawing cmds, etc to drawing data buffer/window stack) simultaneously. For example, what this line of code
CImGui.ColorEdit3("color", col1) does is “drawing” the slider widget and immediately set
col1 to current color/value selected by users. Unlike retained mode UI, all of the widgets get updated every frame regardless of whether the states changed or not(the idea is to update widgets and the states every frame instead of storing hidden states and calculating which widget should be re-rendering). As a result, widgets in ImGui do not return outputs, so current unify widget syntax may not fit.
Considering the following example:
import Colors using Plots function mycolorpicker() r = slider(0:255, label = "red") g = slider(0:255, label = "green") b = slider(0:255, label = "blue") output = Interact.@map Colors.RGB(&r/255, &g/255, &b/255) plt = Interact.@map plot(sin, color = &output) wdg = Widget(["r" => r, "g" => g, "b" => b], output = output) @layout! wdg hbox(plt, vbox(:r, :g, :b)) ## custom layout: by default things are stacked vertically end
In ImGui, one might write:
# this is a fake Julia code snippet, but you may already get the idea. let r, g, b = 0, 0, 0 # ImGui won't handle states for us, we need to find a way to store them ourselves. function mycolorpicker() # Interact.@map magic should happen here, but is it still necessary? slider(&r, 0, 255, label = "red") slider(&g, 0, 255, label = "green") slider(&b, 0, 255, label = "blue") # emit textures immediately to drawing buffer plot(sin, color = Colors.RGB(r/255, g/255, b/255)) SameLine()/NoSameLine() # layouts are not a part of widgets in ImGui end end