View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0010288 | ardour | features | public | 2026-04-18 16:38 | 2026-04-18 17:44 |
| Reporter | mschwarzenberg | Assigned To | x42 | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Platform | GNU | OS | Linux | OS Version | (any) |
| Product Version | 9.2 | ||||
| Summary | 0010288: Unintuitive Radio Button Order in LuaDialogRadio (with propsed solution) | ||||
| Description | Problem: When creating a Lua dialog with radio buttons, the order in which they appear in the row is unintuitive - it depends on the internal order of the Lua table which is neither sorted by keys nor by values. This makes using dialogs with radio buttons somewhat confusing. | ||||
| Steps To Reproduce | run the attached radiodialogtest.lua from Window->Scripting. We get a dialog layout as shown in the attached Unordered.png With the proposed fix, LuaDialogRadioOrderingFix.diff we get a more deterministic behavior => Ordered.png | ||||
| Tags | No tags attached. | ||||
|
|
LuaDialogRadioOrderingFix.diff (1,307 bytes)
diff --git a/gtk2_ardour/luadialog.cc b/gtk2_ardour/luadialog.cc
index 8ceba1b833..1d6e7fbc2a 100644
--- a/gtk2_ardour/luadialog.cc
+++ b/gtk2_ardour/luadialog.cc
@@ -386,12 +386,19 @@ public:
: LuaDialogWidget (key, title)
, _rv (0)
{
+ std::map<std::string, std::string> labels_ordered_by_value;
for (luabridge::Iterator i (values); !i.isNil (); ++i) {
+ // i.key is the label of the radio button, i.value is the value.
+ // We sort by values to have a deterministic order of the radio buttons,
+ // which is still independent of the content of the button labels.
if (!i.key ().isString ()) { continue; }
- std::string key = i.key ().cast<std::string> ();
- Gtk::RadioButton* rb = Gtk::manage (new Gtk::RadioButton (_group, key));
+ std::string value_str = i.value ().cast<std::string> ();
+ labels_ordered_by_value.emplace (value_str, i.key ().cast<std::string> ());
+ }
+ for (auto const &i : labels_ordered_by_value) {
+ Gtk::RadioButton* rb = Gtk::manage (new Gtk::RadioButton (_group, i.second));
_hbox.pack_start (*rb);
- luabridge::LuaRef* ref = new luabridge::LuaRef (i.value ());
+ luabridge::LuaRef* ref = new luabridge::LuaRef (values[i.second]);
_refs.push_back (ref);
if (!_rv) { _rv = ref; }
rb->signal_toggled ().connect (sigc::bind (
|
|
|
added radiodialogtest.lua radiodialogtest.lua (1,191 bytes)
-- radiodialogtest.lua
local def = {
{
type = "radio", key = "row1", title = "KeysUp ValuesUp", values =
{
["Key1_Val1"] = "Val1", ["Key2_Val2"] = "Val2", ["Key3_Val3"] = "Val3", ["Key4_Val4"] = "Val4",
},
default = "Key1_Val1"
},{
type = "radio", key = "row2", title = "KeysDown ValuesDown", values =
{
["Key4_Val4"] = "Val4", ["Key3_Val3"] = "Val3", ["Key2_Val2"] = "Val2", ["Key1_Val1"] = "Val1",
},
default = "Key1_Val1"
},{
type = "radio", key = "row3", title = "KeysUp ValuesDown", values =
{
["Key1_Val4"] = "Val4", ["Key2_Val3"] = "Val3", ["Key3_Val2"] = "Val2", ["Key4_Val1"] = "Val1",
},
default = "Key1_Val4"
},{
type = "radio", key = "row4", title = "KeysDown ValuesUp", values =
{
["Key4_Val1"] = "Val1", ["Key3_Val2"] = "Val2", ["Key2_Val3"] = "Val3", ["Key1_Val4"] = "Val4",
},
default = "Key1_Val4"
}
}
res = LuaDialog.Dialog ("Radio Buttons Order", def):run()
print("row1:" .. res["row1"])
print("row2:" .. res["row2"])
print("row3:" .. res["row3"])
print("row4:" .. res["row4"]) |
|
|
Thank you. Applied as 9.2-583-gd7d701abf5 |
|
|
@x42 Nice! I want(ed) this as well. : ) Thanks for bringing it up, @mschwarzenberg ! -J |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-04-18 16:38 | mschwarzenberg | New Issue | |
| 2026-04-18 16:38 | mschwarzenberg | File Added: Unordered.png | |
| 2026-04-18 16:38 | mschwarzenberg | File Added: Ordered.png | |
| 2026-04-18 16:38 | mschwarzenberg | File Added: LuaDialogRadioOrderingFix.diff | |
| 2026-04-18 16:39 | mschwarzenberg | Note Added: 0030272 | |
| 2026-04-18 16:39 | mschwarzenberg | File Added: radiodialogtest.lua | |
| 2026-04-18 17:41 | x42 | Assigned To | => x42 |
| 2026-04-18 17:41 | x42 | Status | new => resolved |
| 2026-04-18 17:41 | x42 | Resolution | open => fixed |
| 2026-04-18 17:41 | x42 | Note Added: 0030273 | |
| 2026-04-18 17:44 | GhostsonAcid | Note Added: 0030274 |