home/ atoms/ sc-gui-window-view

SuperCollider's cross-platform GUI builds windows, sliders, and views by composing View objects in layout managers

SC’s GUI system (Qt-based on all platforms) creates windows with Window.new and populates them with views (Button, Slider, TextField, EnvelopeView, etc.). Views register action callbacks that fire when their value changes. Layout managers (VLayout, HLayout, FlowLayout) size and position views automatically. GUI code must run on the AppClock — use .defer{} to call GUI methods from SystemClock routines. The MVC idiom applies: a model (e.g., Env) broadcasts changes via .changed; dependent views register with .addDependant and update in response.

Examples

w = Window(“envelope GUI”, Rect(100, 100, 300, 400)) .layout_(VLayout( ~envView, HLayout(~envSliders[0], ~envSliders[1], ~envSliders[2]) )).front;

Assessment

Build a GUI with two sliders controlling frequency and amplitude of a running sine synth. Ensure the sliders update the synth without stopping it. Add an .onClose callback that frees the synth.

“w = Window.new("envelope GUI", Rect(100, 100, 300, 400)) .layout_(VLayout( ~envView, HLayout(~envSliders[0], ~envSliders[1], ~envSliders[2]),”
corpus · the-supercollider-book-official-code-examples-scbookcode-gpl · chunk 21