nbslot_edit: add documentation and handle more edge cases
This commit is contained in:
@@ -189,10 +189,16 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<attribute name='min_rows' get='1' set='1' type='int' size='1' >
|
<attribute name='min_rows' get='1' set='1' type='int' size='1' >
|
||||||
<digest>Minimum number of rows to display</digest>
|
<digest>Minimum number of rows to display</digest>
|
||||||
<description>Defines the minimum number of rows to display if scrollable is enabled and layout is set to 1.
|
<description>Defines the minimum number of rows to display if scrollable is enabled.
|
||||||
If a preset is stored in a slot with a higher value than min_row, then min_row is ignored and presets are displayed up to the highest stored one.
|
min_rows gets overridden if the objects size can fit more rows than defined by min_rows, and/or if a stored preset is in a row above min_row.
|
||||||
|
In other words, min_rows is applied as long as scrollable is enabled, the objects size can fit more rows than min_row without scrolling (the size of a row being defined by bubblesize and margin), or a stored preset lives in a row above min_row.
|
||||||
</description>
|
</description>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
</attribute>
|
||||||
|
<attribute name='nbslot_edit' get='1' set='1' type='bool' size='1' >
|
||||||
|
<digest>Add/remove rows of presets</digest>
|
||||||
|
<description>When enabled, adds a "-" and "+" buttons at the end of the presets list which, when clicked, respectively remove or add a row of empty slot(s). The minimum number of rows is capped by min_rows.</description>
|
||||||
|
</attribute>
|
||||||
<attribute name='pattrstorage' get='1' set='1' type='symbol' size='1' >
|
<attribute name='pattrstorage' get='1' set='1' type='symbol' size='1' >
|
||||||
<digest>pattrstorage object to bind to</digest>
|
<digest>pattrstorage object to bind to</digest>
|
||||||
<description>Set the name of the [pattrstorage] to bind to. Its outlet must be connected to the [tc.preset] inlet.
|
<description>Set the name of the [pattrstorage] to bind to. Its outlet must be connected to the [tc.preset] inlet.
|
||||||
|
@@ -84,7 +84,7 @@ var use_uid = 0; // Generating UID for each presets when enabled. Req
|
|||||||
var recall_passthrough = true; // By default (true), clicking a slot sends a recall message directly to [pattrstorage], and the jsui left outlet outputs a recall message once the recall is done. When disabled, clicking a slot will send a recall message straight from the jsui left outlet, so it's up to the user to forward the message to pattrstorage. It can be usefull for triggering interpolations with custom logic.
|
var recall_passthrough = true; // By default (true), clicking a slot sends a recall message directly to [pattrstorage], and the jsui left outlet outputs a recall message once the recall is done. When disabled, clicking a slot will send a recall message straight from the jsui left outlet, so it's up to the user to forward the message to pattrstorage. It can be usefull for triggering interpolations with custom logic.
|
||||||
var ui_rename = false; // Use the attached textedit, if any, to edit slot names directly in the JSUI frame when clicking a slot while holding the control key. When disabled, the textedit remains untouched but gets focused when clicking a slot while holding the control key.
|
var ui_rename = false; // Use the attached textedit, if any, to edit slot names directly in the JSUI frame when clicking a slot while holding the control key. When disabled, the textedit remains untouched but gets focused when clicking a slot while holding the control key.
|
||||||
var poll_edited = 1; // If >0, check if current preset is edited every X seconds defined by the variable value.
|
var poll_edited = 1; // If >0, check if current preset is edited every X seconds defined by the variable value.
|
||||||
var nbslot_edit = true; // If nbslot_edit and scrollable are enabled, the last two visible slots are replaced by buttons to add or remove lines of slot.
|
var nbslot_edit = false; // If nbslot_edit and scrollable are enabled, the last two visible slots are replaced by buttons to add or remove lines of slot.
|
||||||
|
|
||||||
// (WORK)
|
// (WORK)
|
||||||
var pattrstorage_name, pattrstorage_obj = null;
|
var pattrstorage_name, pattrstorage_obj = null;
|
||||||
@@ -494,7 +494,6 @@ function paint()
|
|||||||
|
|
||||||
//Edited dot
|
//Edited dot
|
||||||
if (active_slot_edited && active_slot > 0 && selected_slot <= slots_count_display) {
|
if (active_slot_edited && active_slot > 0 && selected_slot <= slots_count_display) {
|
||||||
post("draw edited dot\n");
|
|
||||||
set_source_rgba(edited_color);
|
set_source_rgba(edited_color);
|
||||||
ellipse(slots[active_slot].left + 1, slots[active_slot].top + 1, slot_size/3, slot_size/3);
|
ellipse(slots[active_slot].left + 1, slots[active_slot].top + 1, slot_size/3, slot_size/3);
|
||||||
fill();
|
fill();
|
||||||
@@ -502,7 +501,7 @@ function paint()
|
|||||||
|
|
||||||
// Hovered slot
|
// Hovered slot
|
||||||
if (last_hovered > -1) {
|
if (last_hovered > -1) {
|
||||||
if (shift_hold) {
|
if (shift_hold && last_hovered_is_preset_slot) {
|
||||||
if (option_hold) {
|
if (option_hold) {
|
||||||
// About to delete
|
// About to delete
|
||||||
set_source_rgba(empty_slot_color[0], empty_slot_color[1], empty_slot_color[2], 0.8);
|
set_source_rgba(empty_slot_color[0], empty_slot_color[1], empty_slot_color[2], 0.8);
|
||||||
@@ -1486,14 +1485,32 @@ onidleout.local = 1;
|
|||||||
function onclick(x,y,but,cmd,shift,capslock,option,ctrl)
|
function onclick(x,y,but,cmd,shift,capslock,option,ctrl)
|
||||||
{
|
{
|
||||||
if (scrollable && nbslot_edit) {
|
if (scrollable && nbslot_edit) {
|
||||||
|
// Click "-"
|
||||||
if (last_hovered == true_slots_count_display - 1) {
|
if (last_hovered == true_slots_count_display - 1) {
|
||||||
|
var tmp_min_rows = min_rows;
|
||||||
setmin_rows(min_rows-1);
|
setmin_rows(min_rows-1);
|
||||||
y_offset = -1 * (bg_height - ui_height);
|
y_offset = -1 * (bg_height - ui_height);
|
||||||
|
if (tmp_min_rows != min_rows) {
|
||||||
|
if (layout == 0) {
|
||||||
|
last_hovered = last_hovered - columns;
|
||||||
|
} else {
|
||||||
|
last_hovered = last_hovered - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
mgraphics.redraw();
|
mgraphics.redraw();
|
||||||
return
|
return
|
||||||
|
// Click "+"
|
||||||
} else if (last_hovered == true_slots_count_display) {
|
} else if (last_hovered == true_slots_count_display) {
|
||||||
|
var tmp_min_rows = min_rows;
|
||||||
setmin_rows(min_rows+1);
|
setmin_rows(min_rows+1);
|
||||||
y_offset = -1 * (bg_height - ui_height);
|
y_offset = -1 * (bg_height - ui_height);
|
||||||
|
if (tmp_min_rows != min_rows) {
|
||||||
|
if (layout == 0) {
|
||||||
|
last_hovered = last_hovered + columns;
|
||||||
|
} else {
|
||||||
|
last_hovered = last_hovered + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
mgraphics.redraw();
|
mgraphics.redraw();
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1501,7 +1518,7 @@ function onclick(x,y,but,cmd,shift,capslock,option,ctrl)
|
|||||||
if (is_typing_name) {
|
if (is_typing_name) {
|
||||||
restore_textedit();
|
restore_textedit();
|
||||||
}
|
}
|
||||||
if (last_hovered > -1 && pattrstorage_name != null) {
|
if (last_hovered > -1 && pattrstorage_name != null && last_hovered_is_preset_slot) {
|
||||||
var output = "recall";
|
var output = "recall";
|
||||||
if (select_mode) {
|
if (select_mode) {
|
||||||
output = "select";
|
output = "select";
|
||||||
@@ -2227,7 +2244,6 @@ function setpoll_edited(v){
|
|||||||
function run_edited_poll_task() {
|
function run_edited_poll_task() {
|
||||||
if (poll_edited_task.valid && !poll_edited_task.running && poll_edited > 0 && active_slot > 0) {
|
if (poll_edited_task.valid && !poll_edited_task.running && poll_edited > 0 && active_slot > 0) {
|
||||||
poll_edited_task.interval = poll_edited * 1000;
|
poll_edited_task.interval = poll_edited * 1000;
|
||||||
post("run task!\n");
|
|
||||||
poll_edited_task.repeat();
|
poll_edited_task.repeat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2267,7 +2283,7 @@ function edited(v) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declareattribute("nbslot_edit", "getnbslot_edit", "setnbslot_edit", 1, {style: "onoff", label: "Rename In UI"});
|
declareattribute("nbslot_edit", "getnbslot_edit", "setnbslot_edit", 1, {style: "onoff", label: "Add/remove rows of presets"});
|
||||||
function getnbslot_edit() {
|
function getnbslot_edit() {
|
||||||
return nbslot_edit;
|
return nbslot_edit;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user