You can’t tell a row to be 100% as width as its parent, cause its width is set up by its children. Same for the height of a column.
Those relative sizes are nice to have, but often you are loosing the overview which is resizing what now.
I usually solve this by using consts for the texts, controls. This way the whole thing also looks a lot cleaner - it aligns itself.
Heres a GUI proposal:
function show_dialog()
if (dialog and dialog.visible) then
-- already showing a dialog. bring it to front:
dialog:show()
return;
end
local MARGIN_DEFAULT = renoise.ViewBuilder.DEFAULT_CONTROL_MARGIN;
local SPACING_DEFAULT = renoise.ViewBuilder.DEFAULT_CONTROL_SPACING;
local TEXT_LABEL_WIDTH = 80;
local CONTROL_WIDTH = 100;
local CONTENT_WIDTH = TEXT_LABEL_WIDTH + CONTROL_WIDTH;
local DIALOG_BUTTON_HEIGHT = renoise.ViewBuilder.DEFAULT_DIALOG_BUTTON_HEIGHT;
vb = renoise.ViewBuilder();
-- create_global_properties
local function create_global_properties()
local row_note = vb:row {
vb:text {
text = "Note",
width = TEXT_LABEL_WIDTH
},
vb:popup {
width = CONTROL_WIDTH,
value = int_note,
items = generate_note_matrix(1,120),
notifier = function(new_index)
int_note = new_index
int_frames = SAMPLE_FREQUENCY / note_to_frequency(new_index);
end,
width = CONTROL_WIDTH
}
}
local row_cycles = vb:row {
vb:text {
text = "Cycles" ,
width = TEXT_LABEL_WIDTH
},
vb:textfield {
width = CONTROL_WIDTH,
value = "1",
notifier = function(new_text)
real_cycles = tonumber(new_text);
end
}
}
local row_label = vb:row {
vb:text {
text = "Amplification",
width = TEXT_LABEL_WIDTH
},
vb:text {
id = "txtDbValue",
text = "0 dB",
width = TEXT_LABEL_WIDTH
}
}
local slider_volume = vb:slider {
width = CONTROL_WIDTH + TEXT_LABEL_WIDTH,
min = 0, -- -INF using log scale
max = 1, -- 0 Decibels using log scale
value = 1,
notifier = function(value)
real_amplification = math.pow(value,2);
if(real_amplification==0) then
vb.views.txtDbValue.text = "-INF dB";
else
vb.views.txtDbValue.text = string.format("%.2f dB",
convert_linear_to_db(real_amplification));
end
end
}
local array_string_buttons = {};
for i = 1, OPERATORS do
array_string_buttons[i] = tostring(i);
end
local switch_tabs = vb:switch {
id = "switchTabs",
width = CONTENT_WIDTH,
items = array_string_buttons,
notifier = function(int_index_new)
change_tab(int_index_new)
end
}
local column_global_properties = vb:column {
style = "group",
margin = MARGIN_DEFAULT,
row_note,
row_cycles,
row_label,
slider_volume,
switch_tabs
};
return column_global_properties
end
-- operator_gui
local function create_operator_gui()
local text_operator = vb:text {
id = "txtOperator",
text = "Operator",
font = "bold",
align = "center",
width = CONTENT_WIDTH,
}
local row_wave = vb:row {
vb:text {
text = "Wave",
width = TEXT_LABEL_WIDTH
},
vb:popup {
id = "cmbWave",
width = CONTROL_WIDTH,
value = int_wave_type_selected,
items = array_string_operators,
notifier = function(int_wave_type)
change_wave(int_operator_selected,int_wave_type);
end
}
}
local row_amplitude = vb:row {
vb:text {
text = "Amplitude",
width= TEXT_LABEL_WIDTH
},
vb:slider {
id = "sldAmplitude",
width = CONTROL_WIDTH,
min = 0,
max = 1,
value = 1,
notifier = function(real_value)
array_real_amplitudes[int_operator_selected] = real_value;
end
}
}
local row_width = vb:row {
id = "rowWidth",
vb:text {
text = "Width",
width = TEXT_LABEL_WIDTH
},
vb:slider {
id = "sldWidth",
width = CONTROL_WIDTH,
min = 0,
max = 0.5,
value = 0.5,
notifier = function(real_value)
array_variant_parameters[int_operator_selected] = real_value;
end
}
}
local row_invert = vb:row {
id = "rowInvert",
vb:text {
text = "Invert wave",
width= TEXT_LABEL_WIDTH
},
vb:checkbox {
id = "chkInvert",
value = false,
notifier = function(boolean_value)
array_boolean_inverts[int_operator_selected] = boolean_value;
end
}
}
local row_modulate = vb:row {
vb:text {
text = "Mod.Ampl. of",
width = TEXT_LABEL_WIDTH
},
vb:popup {
id = "cmbModulate",
width = CONTROL_WIDTH,
items = generate_modulator_matrix(),
value = 1,
notifier = function(new_index)
array_int_modulators[int_operator_selected] = new_index - 1;
end
}
}
local dropdown_instruments = vb:popup {
id = "cmbInstruments",
width = CONTENT_WIDTH,
items = generate_instrument_matrix(),
value = 1,
notifier = function(new_index)
vb.views.cmbSamples.items = generate_sample_matrix(new_index);
array_variant_parameters[int_operator_selected] = renoise.song().instruments[new_index].samples[1].sample_buffer;
end
}
local dropdown_samples = vb:popup {
id = "cmbSamples",
width = CONTENT_WIDTH,
items = generate_sample_matrix(1),
value = 1,
notifier = function(new_index)
array_variant_parameters[int_operator_selected] = renoise.song().instruments[vb.views.cmbInstruments.value].samples[new_index].sample_buffer;
end
}
local column_wavetable = vb:column {
id = "colWaveTable",
dropdown_instruments,
dropdown_samples
}
local row_frequency_multiplier = vb:row {
id = "rowMultiplier",
vb:text {
text = "Freq. Multiplier",
width = TEXT_LABEL_WIDTH
},
vb:textfield {
id = "txtMultiplier",
width = CONTROL_WIDTH,
value = "1",
notifier = function(new_text)
array_real_frequency_multipliers[int_operator_selected] = tonumber(new_text);
end
}
}
local column_gui = vb:column {
id = "columnGui",
style = "group",
margin = MARGIN_DEFAULT,
text_operator,
row_wave,
column_wavetable,
row_amplitude,
row_width,
row_invert,
row_frequency_multiplier,
row_modulate
}
return column_gui;
end
-- main layout
local button_generate = vb:button {
text = "Generate",
tooltip = "Hit this button to generate a custom wave with the specified features.",
width = "100%",
height = DIALOG_BUTTON_HEIGHT,
notifier = function()
generate()
end
}
local button_reset = vb:button {
text = "Reset",
width = "100%",
height = DIALOG_BUTTON_HEIGHT,
tooltip = "Reset all data",
notifier = function()
if renoise.app():show_prompt("Parameters Reset",
"Are you sure you want to reset all parameters data?",{"Yes","No"}) == "Yes" then
reset_gui();
end
end
}
local dialog_content = vb:column {
id = "colContainer",
margin = MARGIN_DEFAULT,
spacing = SPACING_DEFAULT,
create_global_properties(),
create_operator_gui(),
button_generate,
button_reset
}
change_wave(1,WAVE_SINE);
change_tab(1);
dialog = renoise.app():show_custom_dialog (
"Custom Wave Generator",
dialog_content
);
end
I’ve also reduced the amount of local views a bit. Although I said its great to mix the nested notation with the localy initialized ones, both in extreme are too much IMHO. For example:
THis :
local row_cycles = vb:row {
vb:text { text = "Cycles" },
vb:textfield {
value = "1",
notifier = function(new_text)
real_cycles = tonumber(new_text);
end
}
}
looks/reads easier to me than:
local text_cycles = vb:text {
text = "Cycles"
}
local textfield_cycles = vb:textfield {
value = "1",
notifier = function(new_text)
real_cycles = tonumber(new_text);
end
}
local row_cycles = vb:row {
text_cycles,
textfield_cycles
}
aka, uising one level of nesting to shorten things a bit. But well, I guess, everyone will see this different…