Add dynamic_combobox: a combobox with a runtime-populated item list#171
Add dynamic_combobox: a combobox with a runtime-populated item list#171bltzr wants to merge 3 commits into
Conversation
A combobox port whose choices are discovered by the processor at run time (e.g. the files in a folder, OSC addresses, dataset ids) rather than being fixed at compile time. The port carries an update_items callback that supporting bindings inject and that the object invokes — from any thread — whenever its list changes. Bindings without support leave the callback empty and render a plain combobox from the static fallback range(), so the feature is fully backwards-compatible: no API, ABI or behaviour change for existing objects. avnd::dynamic_items_parameter lets a binding detect such ports. Co-authored-by: Pia Baltazar <pia@baltazar.studio>
|
Host-side consumer: ossia/score#2110 (adds the |
|
Closing for now — no real object consumes this port yet (Granola, the intended user, went with a custom picker), so I don't want to add to your review queue. The work stays on my fork branch |
|
Leaving this as a reference rather than an active review request. A working example of the port in use: For our actual case — Granola's sound picker — we ended up doing it manually with a custom widget instead, so nothing here is blocking us. But if you think a runtime-populated combobox would be useful to others in the codebase, happy to revive and polish both PRs (this port + the score binding). |
A combobox whose items are the files of a sibling folder/path port, listed by the host at edit time and refreshed when the folder changes — populated at document load, without execution. Complements dynamic_combobox (which is pushed by the running object); this pulls from a folder in the UI, matching how file pickers actually need to behave in an editor. Co-authored-by: Pia Baltazar <pia@baltazar.studio>
|
related to ossia/score#2110 so reopening along with the latter |
Chains of processes that write then read conventionally-named files rely on default values; keep the initially selected file name as a parameter so it stays selected even while the file does not exist yet. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDQaHG5FbEyH9D8VsjEyXe
|
Added an init file-name template parameter (folder_combobox<name, folder_port, extensions, init>): chains of processes that write then read conventionally-named files keep working with defaults — the init stays selected even while the file does not exist yet, and is picked up once written. |
PR (avendish): dynamic_combobox — runtime-populated combobox port
Branch:
feature/dynamic-combobox(offmain)Files: 2 new headers, 79 lines, no changes to existing code.
What
A combobox port whose item list is discovered by the processor at run time,
rather than fixed at compile time by
range():halp/dynamic_combobox.hpp— the port:int value, a static fallbackrange()(single "-" item), andstd::function<void(std::vector<std::string>)> update_items.avnd/concepts/dynamic_items.hpp—avnd::dynamic_items_parameter<T>, so abinding can detect these ports.
Backwards compatibility
The design is additive and opt-in. Bindings that don't know the concept never
fill
update_items; the port then renders as a plain combobox from the staticfallback
range(). Existing objects and existing bindings are untouched — noAPI, ABI or behaviour change.
Host side
The score binding that consumes this is a companion PR on ossia/score
(
feature/dynamic-combobox):Process::ComboBoxgainssetAlternatives()+alternativesChanged, the widgets rebuild live, and theexecutor injects
update_items(thread-marshalled). Other bindings can adoptit incrementally or ignore it.
Motivation
Folder-backed pickers: the score-avnd-flucoma / Granola work needs a sound
whose choices are the files currently in a working folder. Also useful for OSC
address lists, dataset point ids, device names, preset names — any choice set
known only at run time. Full design notes in
dynamic-combobox-proposal.md.Open questions for review
match by string.
Host binding
ossia/score#2110 consumes this port:
Process::ComboBoxgains a runtimesetAlternatives()+alternativesChanged, the inspector/canvas widgets rebuild live, and the avnd executor injectsupdate_items. This avendish PR should land first. No real object depends on it yet — it was verified with a throwaway test object.