1 ardour { ["type"] = "Snippet", name = "Dialog Test" }
3 function factory () return function ()
4 local md = LuaDialog.Message ("title", "hello", LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close)
10 -----------------------------------------------------------------
11 function basic_serialize (o)
12 if type(o) == "number" then
15 return string.format("%q", o)
19 function serialize (name, value)
20 local rv = name .. ' = '
22 if type(value) == "number" or type(value) == "string" or type(value) == "nil" or type (value) == "boolean" then
23 return rv .. basic_serialize(value) .. ' '
24 elseif type(value) == "table" then
26 for k,v in pairs(value) do
27 local fieldname = string.format("%s[%s]", name, basic_serialize(k))
28 rv = rv .. serialize(fieldname, v) .. ' '
31 elseif type(value) == "function" then
32 --return rv .. string.format("%q", string.dump(value, true))
33 return rv .. "(function)"
35 error('cannot serialize a ' .. type(value))
38 -----------------------------------------------------------------
40 function func () print "Hello" end
42 local dialog_options = {
43 { type = "checkbox", key = "onoff", default = true, title = "OnOff" },
45 { type = "entry", key = "text", default = "changeme", title = "Text Entry" },
48 type = "radio", key = "select", title = "RadioBtn", values =
50 ["Option 1"] = 1, ["Option 2"] = "2", ["Option A"] = 'A'
56 type = "dropdown", key = "dropdown", title = "Menu", values =
58 ["Option 1"] = 1, ["Option 2"] = "2", ["Callback"] = func,
61 ["Option 4a"] = "test", ["Option 4b"] = 4.2
67 { type = "fader", key = "gain", title = "Level", default = -10 }, -- unit = 'dB"
70 type = "slider", key = "freq", title = "Frequency", min = 20, max = 20000, scalepoints =
72 [20] = "20", [200] = "nice", [2000] = "2k", [10000] = "too much"
77 { type = "heading", title = "Heading" },
79 { type = "number", key = "number", title = "Whatever", min = 0, max = 10, step = 1, digits = 2 },
81 { type = "file", key = "file", title = "Select a File", path = ARDOUR.LuaAPI.build_filename (Session:path (), Session:name () .. ".ardour") },
83 { type = "folder", key = "folder", title = "Select a Folder", path = Session:path() }
86 local od = LuaDialog.Dialog ("title", dialog_options)
89 print (serialize ("dialog", rv))