8 Commits

View File

@@ -80,12 +80,15 @@ var min_rows = 10; // Minimum number of rows to display if scrollable i
var color_mode = 0; // Change the way the filled slots (stored presets) color is handeld. 0: stored_slot_color. 1: looping through color_1 to color_6. 2: Freely assign colors 1 to 6. 3: Set any color to any preset
var select_mode = 0; // 0: single click to select and recall the slot. 1: single click to select the slot, double click to recall it.
var click_mode = 0; // Sets the behavior of single clicks. 0: normal (recall), 1: select, 2: store, 3: delete
var drag_mode = 1; // Sets the behavior of drag operations. 0: disabled, 1: move preset (default), 2: in-line interpolation, 3: zone interpolation
var drag_interp_radius = 1; // In use with drag_mode 3
var send_name = "none"; // The global name to send presets dict name to (received by the [receive] object)
var unique_names = false; // When enabled, force names to be unique when renaming slots by appending "bis" to them. Gets applied only to subsequently renamed presets.
var autoname = false; // Automatically name new presets when created as "Preset" followed by the slot id
var use_uid = 0; // Generating UID for each presets when enabled. Requires a [pattr preset_metadata]
var timestamp = false; // Generates a `created` and `modified` timestamp for each preset. Requires use_uid enabled
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 store_passthrough = true; // Same as recall_passthrough but for store messages triggered with shift+click. The store message message has to be routed back into [tc.preset] to be effective.
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 = 0; // 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.
@@ -198,6 +201,10 @@ function slot(left, top, right, bottom) {
this.top = top;
this.right = right;
this.bottom = bottom;
this.center = {
x: (left + right) / 2,
y: (top + bottom) / 2,
}
}
this.export_metadata = function () {
@@ -313,13 +320,14 @@ function calc_rows_columns(src) {
slots[cur].set_geom(left, top, right, bottom);
} else {
// Empty slot, possibly not initialized (if above slots_highest)
slots[cur] = new slot(left, top, right, bottom);
slots[cur] = new slot();
slots[cur].set_geom(left, top, right, bottom);
}
}
}
if (slots_count_display < slots_highest) {
if (slots.length < slots_highest ) {
for (var i = slots_count_display + 1; i <= slots_highest; i++) {
slots[i] = new slot();
}
@@ -459,7 +467,7 @@ function paint_base() {
for (var i = 1; i <= true_slots_count_display; i++) {
if (i != drag_slot) { //We mask the slot that is currently dragged as it is drawn at the mouse position already
var slot = slots[i];
if (slot.filled == true) {
if (slot.filled === true) {
if (color_mode == 1) {
mg.set_source_rgba(color_wheel_custom[i % color_wheel_size]);
} else if (color_mode == 2) {
@@ -503,7 +511,7 @@ function paint()
mgraphics.set_line_width(1);
// Active slot
if (is_dragging == 0 && active_slot > 0 && active_slot <= slots_count_display) {
if (is_dragging !== 1 && active_slot > 0 && active_slot <= slots_count_display) {
var opacity = active_slot_color[3];
var opacity = control_hold && last_hovered == active_slot ? active_slot_color[3] * 0.7 : active_slot_color[3];
mgraphics.set_source_rgba(active_slot_color[0], active_slot_color[1], active_slot_color[2], opacity);
@@ -521,7 +529,7 @@ function paint()
}
// Previous active slot
if (is_dragging == 0 && previous_active_slot > 0 && previous_active_slot <= slots_count_display) {
if (is_dragging === 0 && previous_active_slot > 0 && previous_active_slot <= slots_count_display) {
mgraphics.set_source_rgba(active_slot_color[0], active_slot_color[1], active_slot_color[2], active_slot_color[3] * 0.5);
if (color_mode) {
if (!control_hold) {
@@ -545,7 +553,7 @@ function paint()
}
// Interpolated slots
if (is_dragging == 0 && display_interp && is_interpolating) {
if (is_dragging !== 1 && display_interp && is_interpolating) {
for (var i = 1; i <= slots_count_display; i++) {
var slot = slots[i];
@@ -575,10 +583,10 @@ function paint()
// }
// Hovered slot
if (last_hovered > -1) {
if ((last_hovered > -1) && ((drag_mode < 2) || (drag_mode >= 2 && !is_dragging))) {
// Slot border
if (slots[last_hovered].filled == false || (slots[last_hovered].filled == true && !control_hold)) {
if (slots[last_hovered].filled === false || (slots[last_hovered].filled === true && !control_hold)) {
mgraphics.set_source_rgba(text_color[0], text_color[1], text_color[2], 0.8 * text_color[3]);
mgraphics.set_line_width(1);
draw_slot_bubble(slots[last_hovered].left, slots[last_hovered].top, slot_size, slot_size);
@@ -589,7 +597,7 @@ function paint()
var stroke_width = Math.round(1 + slot_size / 10);
stroke_width = Math.max(2, stroke_width);
if (shift_hold) {
if (control_hold && slots[last_hovered].filled == true) {
if (control_hold && slots[last_hovered].filled === true) {
// About to lock/unlock
var bracket_size = slot_size * 0.2;
mgraphics.set_source_rgba(text_color);
@@ -603,7 +611,7 @@ function paint()
mgraphics.rel_line_to(0, slot_size);
mgraphics.rel_line_to(-bracket_size, 0);
mgraphics.stroke();
} else if (option_hold && !control_hold && slots[last_hovered].filled == true) {
} else if (option_hold && !control_hold && slots[last_hovered].filled === true) {
// About to delete
mgraphics.set_source_rgba(0, 0, 0, 0.5);
draw_slot_bubble(slots[last_hovered].left + 1, slots[last_hovered].top + 1, slot_size-2, slot_size-2);
@@ -614,7 +622,7 @@ function paint()
draw_slot_bubble(slots[last_hovered].left + 1, slots[last_hovered].top + 1, slot_size-2, slot_size-2);
mgraphics.fill();
}
} else if (control_hold && slots[last_hovered].filled == true) {
} else if (control_hold && slots[last_hovered].filled === true) {
// About to rename
mgraphics.set_source_rgba(text_color);
mgraphics.set_line_width(stroke_width);
@@ -682,7 +690,7 @@ function paint()
}
// Drag slot
if (is_dragging) {
if (is_dragging === 1) {
if (layout == 0) {
mgraphics.translate(last_x, last_y );
mgraphics.rotate(0.15);
@@ -925,7 +933,7 @@ function anything() {
} else {
slots[v].name = null;
slots[v].interp = -1;
slots[v].filled = 0;
slots[v].filled = false;
if (active_slot == v) {
active_slot = 0;
selected_slot = 0;
@@ -934,7 +942,7 @@ function anything() {
previous_active_slot = 0;
}
if (is_dragging == 0 && is_moving == 0) {
if (is_dragging === 0 && is_moving === 0) {
to_pattrstorage("delete", v);
to_pattrstorage("getslotlist");
set_active_slot(active_slot);
@@ -980,9 +988,7 @@ function msg_int(v) {
}
function msg_float(v) {
var s = Math.floor(v);
var i = v % 1;
to_pattrstorage("recall", s, s+1, i);
to_pattrstorage(v);
}
function pattrstorage(v) {
@@ -1021,7 +1027,7 @@ function slotname() {
return;
}
if (slot > 0 && name != "(undefined)") {
if (is_updating_names == 1 && slots[slot].filled == false && name !== "<(unnamed)>") {
if (is_updating_names == 1 && slots[slot].filled === false && name !== "<(unnamed)>") {
// Removing parenthesis automatically added by pattrstorage if the preset has a name but isn't filled
name = name.slice(1, -1);
}
@@ -1088,10 +1094,13 @@ function recall() {
} else if (args.length == 3) {
src_slot = Math.abs(args[0]);
trg_slot = Math.abs(args[1]);
interp = Math.min( 1, Math.max(0, args[2]));
interp = Math.min(1, Math.max(0, args[2]));
}
if ((src_slot == 0 || filled_slots.indexOf(src_slot) > -1) && (trg_slot == 0 || filled_slots.indexOf(trg_slot) > -1 )) {
var src_slot_exists = filled_slots.indexOf(src_slot) > -1;
var trg_slot_exists = filled_slots.indexOf(trg_slot) > -1;
if ((src_slot == 0 || src_slot_exists) || (trg_slot == 0 || trg_slot_exists )) {
for (var i = 0; i < filled_slots.length; i++) {
slots[filled_slots[i]].interp = -1;
}
@@ -1105,7 +1114,7 @@ function recall() {
src_slot = active_slot;
}
}
if (interp == 0.0) {
if (interp == 0.0 && src_slot_exists) {
slots[src_slot].interp = -1;
slots[trg_slot].interp = -1;
is_interpolating = 0;
@@ -1119,7 +1128,7 @@ function recall() {
set_active_slot(src_slot);
active_slot_edited = 0;
run_edited_poll_task();
} else if (interp == 1.0) {
} else if (interp == 1.0 && trg_slot_exists) {
slots[src_slot].interp = -1;
slots[trg_slot].interp = -1;
is_interpolating = 0;
@@ -1128,8 +1137,8 @@ function recall() {
active_slot_edited = 0;
run_edited_poll_task();
} else {
slots[src_slot].interp = 1 - interp;
slots[trg_slot].interp = interp;
if (src_slot_exists) slots[src_slot].interp = 1 - interp;
if (trg_slot_exists) slots[trg_slot].interp = interp;
is_interpolating = 1;
active_slot = 0;
// if (src_slot != trg_slot) {
@@ -1158,22 +1167,27 @@ function recallmulti() {
var args = arrayfromargs(arguments);
var interp_slots = [];
var summed_weight = 0;
for (var i = 0; i < filled_slots.length; i++) {
slots[filled_slots[i]].interp = -1;
}
for (var i = 0; i < args.length; i++) {
var slot = Math.floor(args[i]);
var weight = args[i] % 1.;
if (weight == 0) weight = 1;
summed_weight += weight;
interp_slots.push([Math.floor(args[i]), weight]);
interp_slots.push([slot, weight]);
}
for (var i = 0; i < interp_slots.length; i++) {
var nb = interp_slots[i][0];
if (slots[nb].filled == true) {
if (slots[nb].filled === true) {
interp_slots[i][1] /= summed_weight;
} else {
interp_slots[i][1] = -1;
}
slots[nb].interp = interp_slots[i][1]
slots[nb].interp = interp_slots[i][1];
}
is_interpolating = 1;
@@ -1243,8 +1257,10 @@ function store(v) {
if (!(ignore_slot_zero && v === 0)) {
set_active_slot(v);
}
outlet(0, "store", v);
if (store_passthrough) {
outlet(0, "store", v);
}
if (v) {
// We writagain only if stored preset is > 0
trigger_writeagain();
@@ -1294,7 +1310,7 @@ function move() {
if (args.length < 2) return;
var src_slot = args[0]; // Preset to move
var dst_slot = args[1]; // Destination slot
if (src_slot == dst_slot || !(src_slot <= slots_highest && dst_slot <= slots_count_display) || slots[src_slot].filled == false) {
if (src_slot == dst_slot || !(src_slot <= slots_highest && dst_slot <= slots_count_display) || slots[src_slot].filled === false) {
if (is_dragging) {
}
@@ -1306,7 +1322,7 @@ function move() {
var cur_prev_active_slot = previous_active_slot;
var cur_selected_slot = selected_slot;
var offset = ((dst_slot <= src_slot) && slots[dst_slot].filled) ? 1 : 0;
var offset_others = slots[dst_slot].filled == true ? 1 : 0;
var offset_others = slots[dst_slot].filled === true ? 1 : 0;
var src_slot_lock = slots[src_slot].lock;
var recalc_rows_flag = 0;
@@ -1315,7 +1331,7 @@ function move() {
lock(src_slot, 0);
}
// If new slot is empty we just move the drag preset here. If it's not, we move al next slots to the right
if (slots[dst_slot].filled == true) {
if (slots[dst_slot].filled === true) {
if (slots_highest == slots_count_display) {
// If there's a stored preset in the last displayed slot, it will be pushed to a new row at insert, so we need to add a new row at redraw
recalc_rows_flag = 1;
@@ -1485,7 +1501,6 @@ find_pattrstorage.local = 1;
function to_pattrstorage() {
if (pattrstorage_obj != null) {
// post('sending to pattrstorage: ', arrayfromargs(arguments), '\n');
pattrstorage_obj.message(arrayfromargs(arguments));
}
}
@@ -1588,7 +1603,6 @@ function update_filled_slots_dict() {
tmp_dict['color_custom'] = slot.color_custom; // Preset color (when color_mode = 3)
}
if (use_uid) tmp_dict['uid'] = slot.uid; // Preset uid (unique and persistent across preset renaming, overwriting and moving) Useful for keeping track of preset across changes
// post('updating by_uid', slot.uid, '\n');
if (timestamp) {
tmp_dict['created'] = slot.created;
tmp_dict['modified'] = slot.modified;
@@ -1798,14 +1812,18 @@ function onclick(x,y,but,cmd,shift,capslock,option,ctrl)
output = "lock";
} else if (!shift && ctrl && slots[last_hovered].filled) {
output = "rename";
} else if (slots[last_hovered].filled == false) {
} else if (slots[last_hovered].filled === false) {
return;
}
if (output == "recall" && recall_passthrough == false) {
// if recall_passthrough == true, send the recall message to pattrstorage directly
outlet(0, 'recall', last_hovered);
} else if (output == "store") {
store(last_hovered);
if (store_passthrough) {
store(last_hovered);
} else {
outlet(0, 'store', last_hovered);
}
} else if (output == "select") {
select(last_hovered);
// mgraphics.redraw();
@@ -1853,51 +1871,137 @@ function ondrag(x,y,but,cmd,shift,capslock,option,ctrl)
{
if (pattrstorage_name != null) {
y -= y_offset;
if (is_dragging == 0 && last_hovered > 0 && slots[last_hovered].filled == true) {
// To prevent mistakes, is_dragging is set to 1 only when dragging for more than 10 pixels
var dist_from_start = Math.sqrt((x-last_x)*(x-last_x)+(y-last_y)*(y-last_y));
if (dist_from_start > 10) {
is_dragging = 1;
drag_slot = last_hovered;
paint_base(); // We repaint the base with the dragged slot removed from the grid
}
} else if (is_dragging == 1) {
last_hovered = get_slot_index(x, y);
last_hovered_is_preset_slot = scrollable && nbslot_edit && last_hovered > (true_slots_count_display - 2) ? false : true;
if (!last_hovered_is_preset_slot) {
last_hovered = 0;
}
if (!but) {
// When the button is released, the dragging ceases
if (last_hovered > 0 && last_hovered != drag_slot && last_hovered_is_preset_slot) {
move(drag_slot, last_hovered);
} else {
// Drag released but not somewhere we can throw a slot in
is_dragging = 0;
drag_slot = -1;
paint_base();
if (drag_mode === 1) {
if (is_dragging === 0 && last_hovered > 0 && slots[last_hovered].filled === true) {
// To prevent mistakes, is_dragging is set to 1 only when dragging for more than 10 pixels
var dist_from_start = Math.sqrt((x-last_x)*(x-last_x)+(y-last_y)*(y-last_y));
if (dist_from_start > 10) {
is_dragging = 1;
drag_slot = last_hovered;
paint_base(); // We repaint the base with the dragged slot removed from the grid
}
} else {
// Click still hold, we keep dragging
if (scrollable) {
// Auto-scroll if mouse out of bounds
if (y+y_offset < 0 && y-(last_y-drag_scroll) < 0) {
drag_scroll = 2;
} else if (y+y_offset > ui_height && y-(last_y-drag_scroll) > 0) {
drag_scroll = -2;
} else if (is_dragging == 1) {
last_hovered = get_slot_index(x, y);
last_hovered_is_preset_slot = scrollable && nbslot_edit && last_hovered > (true_slots_count_display - 2) ? false : true;
if (!last_hovered_is_preset_slot) {
last_hovered = 0;
}
if (!but) {
// When the button is released, the dragging ceases
if (last_hovered > 0 && last_hovered != drag_slot && last_hovered_is_preset_slot) {
move(drag_slot, last_hovered);
} else {
drag_scroll = 0;
// Drag released but not somewhere we can throw a slot in
is_dragging = 0;
drag_slot = -1;
paint_base();
}
y_offset += drag_scroll;
y_offset = Math.min(y_offset, 0);
y_offset = Math.max(y_offset, -1 * (bg_height - ui_height));
} else {
// Click still hold, we keep dragging
if (scrollable) {
// Auto-scroll if mouse out of bounds
if (y+y_offset < 0 && y-(last_y-drag_scroll) < 0) {
drag_scroll = 2;
} else if (y+y_offset > ui_height && y-(last_y-drag_scroll) > 0) {
drag_scroll = -2;
} else {
drag_scroll = 0;
}
y_offset += drag_scroll;
y_offset = Math.min(y_offset, 0);
y_offset = Math.max(y_offset, -1 * (bg_height - ui_height));
}
mgraphics.redraw();
}
last_x = x;
last_y = y;
}
} else if (drag_mode === 2) {
// Drag to interpolate across adjacent (previous and next) presets
if (is_dragging == 0) {
var dist_from_start = Math.sqrt((x-last_x)*(x-last_x)+(y-last_y)*(y-last_y));
if (dist_from_start > 3) {
is_dragging = 2;
}
}
// last_hovered retains the slot where the drag began
if (is_dragging === 2 && last_hovered > -1) {
var relative_dist_from_start =
layout === 0 ? (x - slots[last_hovered].center.x) / (slot_size + spacing) :
(y - slots[last_hovered].center.y) / (slot_size + spacing);
var current_slot = Math.max(Math.round(last_hovered - 0.5 + relative_dist_from_start), 1);
var prev_filled_slot = -1;
var next_filled_slot = -1;
for (var i = 0; i < filled_slots.length; i++) {
var p = filled_slots[i];
if (p <= current_slot) {
if (prev_filled_slot === -1 || p > prev_filled_slot) {
prev_filled_slot = p;
}
} else if (p > current_slot) {
if (next_filled_slot === -1 || p < next_filled_slot) {
next_filled_slot = p;
}
}
}
var interp_amount = 0;
if (prev_filled_slot === -1) {
prev_filled_slot = next_filled_slot;
interp_amount = 1;
} else if (next_filled_slot === -1) {
next_filled_slot = prev_filled_slot;
interp_amount = 1;
} else if (prev_filled_slot > 0 && next_filled_slot > 0) {
interp_amount = (last_hovered + relative_dist_from_start - prev_filled_slot) / (next_filled_slot - prev_filled_slot);
interp_amount = Math.min(interp_amount, Math.max(interp_amount, 0), 1);
}
if (prev_filled_slot !== -1 || next_filled_slot !== -1) {
to_pattrstorage("recall", prev_filled_slot, next_filled_slot, interp_amount);
}
last_x = x;
last_y = y;
if (!but) {
is_dragging = 0;
}
}
} else if (drag_mode === 3) {
// Drag to interpolate across adjacent (previous and next) presets
if (is_dragging == 0) {
var dist_from_start = Math.sqrt((x-last_x)*(x-last_x)+(y-last_y)*(y-last_y));
if (dist_from_start > 3) {
is_dragging = 3;
}
}
// last_hovered retains the slot where the drag began
if (is_dragging === 3 && last_hovered > -1) {
var nearby_slots = [];
var max_dist = 0;
for (var i = 0; i < filled_slots.length; i++) {
// Interpolating only through displayed slots;
if (filled_slots[i] <= slots_count_display) {
var s_pos = slots[filled_slots[i]].center;
var dist_from_mouse = Math.sqrt((x - s_pos.x) * (x - s_pos.x) + (y - s_pos.y) * (y - s_pos.y)) / (slot_size + spacing);
if (dist_from_mouse < drag_interp_radius) {
var interp_factor = Math.pow((dist_from_mouse / drag_interp_radius) - 1, 4)
// var interp_factor = 1 - (dist_from_mouse / drag_interp_radius);
nearby_slots.push(filled_slots[i] + interp_factor);
if (max_dist < dist_from_mouse) max_dist = dist_from_mouse;
}
}
}
if (nearby_slots.length) {
var args = ["recallmulti"].concat(nearby_slots);
to_pattrstorage.apply(null, args);
recallmulti.apply(null, nearby_slots);
}
last_x = x;
last_y = y;
if (!but) {
is_dragging = 0;
}
mgraphics.redraw();
}
last_x = x;
last_y = y;
}
}
}
@@ -1988,12 +2092,7 @@ function setslotsize(v){
}
setslotsize.local = 1;
declareattribute("slot_round", "getslotround", "setslotround", 1, {type: "long", default: 0, label: "Slot Round", category: "Appearance"});
function getslotround() {
return slot_round;
}
getslotround.local = 1;
declareattribute("slot_round", null, "setslotround", 1, {type: "long", default: 0, label: "Slot Round", category: "Appearance"});
function setslotround(v){
if (arguments.length) {
slot_round = Math.max(0, Math.min(slot_size, v));
@@ -2005,12 +2104,7 @@ function setslotround(v){
}
setslotround.local = 1;
declareattribute("margin", "getmargin", "setmargin", 1, {type: "long", default: 4, label: "Margin", category: "Appearance"});
function getmargin() {
return margin;
}
getmargin.local = 1;
declareattribute("margin", null, "setmargin", 1, {type: "long", default: 4, label: "Margin", category: "Appearance"});
function setmargin(v){
if (arguments.length) {
margin = Math.max(0, v);
@@ -2021,12 +2115,7 @@ function setmargin(v){
}
setmargin.local = 1;
declareattribute("spacing", "getspacing", "setspacing", 1, {type: "long", default: 4, label: "Spacing", category: "Appearance"});
function getspacing() {
return spacing;
}
getspacing.local = 1;
declareattribute("spacing", null, "setspacing", 1, {type: "long", default: 4, label: "Spacing", category: "Appearance"});
function setspacing(v){
if (arguments.length) {
spacing = Math.max(1, v);
@@ -2056,12 +2145,7 @@ function setbgcolor(){
}
setbgcolor.local = 1;
declareattribute("empty_slot_color", "getemptycolor", "setemptycolor", 1, {style: "rgba", label: "Empty Slot Color", category: "Appearance"});
function getemptycolor() {
return empty_slot_color;
}
getemptycolor.local = 1;
declareattribute("empty_slot_color", null, "setemptycolor", 1, {style: "rgba", label: "Empty Slot Color", category: "Appearance"});
function setemptycolor(){
if (arguments.length == 4) {
empty_slot_color = [arguments[0], arguments[1], arguments[2], arguments[3]];
@@ -2074,12 +2158,7 @@ function setemptycolor(){
}
setemptycolor.local = 1;
declareattribute("active_slot_color", "getactiveslotcolor", "setactiveslotcolor", 1, {style: "rgba", label: "Active Slot Color", category: "Appearance"});
function getactiveslotcolor() {
return active_slot_color;
}
getactiveslotcolor.local = 1;
declareattribute("active_slot_color", null, "setactiveslotcolor", 1, {style: "rgba", label: "Active Slot Color", category: "Appearance"});
function setactiveslotcolor(){
if (arguments.length == 4) {
active_slot_color = [arguments[0], arguments[1], arguments[2], arguments[3]];
@@ -2092,12 +2171,7 @@ function setactiveslotcolor(){
}
setactiveslotcolor.local = 1;
declareattribute("stored_slot_color", "getstoredslotcolor", "setstoredslotcolor", 1, {style: "rgba", label: "Stored Slot Color", category: "Appearance"});
function getstoredslotcolor() {
return stored_slot_color;
}
getstoredslotcolor.local = 1;
declareattribute("stored_slot_color", null, "setstoredslotcolor", 1, {style: "rgba", label: "Stored Slot Color", category: "Appearance"});
function setstoredslotcolor(){
if (arguments.length == 4) {
stored_slot_color = [arguments[0], arguments[1], arguments[2], arguments[3]];
@@ -2110,12 +2184,7 @@ function setstoredslotcolor(){
}
setstoredslotcolor.local = 1;
declareattribute("interp_slot_color", "getinterpslotcolor", "setinterpslotcolor", 1, {style: "rgba", label: "Interpolating slot color", category: "Appearance"});
function getinterpslotcolor() {
return interp_slot_color;
}
getinterpslotcolor.local = 1;
declareattribute("interp_slot_color", null, "setinterpslotcolor", 1, {style: "rgba", label: "Interpolating slot color", category: "Appearance"});
function setinterpslotcolor(){
if (arguments.length == 4) {
interp_slot_color = [arguments[0], arguments[1], arguments[2], arguments[3]];
@@ -2128,11 +2197,7 @@ function setinterpslotcolor(){
}
setinterpslotcolor.local = 1;
declareattribute("text_color", "gettextcolor", "settextcolor", 1, {style: "rgba", label: "Text Color", category: "Appearance"});
function gettextcolor() {
return text_color;
}
gettextcolor.local = 1;
declareattribute("text_color", null, "settextcolor", 1, {style: "rgba", label: "Text Color", category: "Appearance"});
function settextcolor(){
if (arguments.length == 4) {
text_color = [arguments[0], arguments[1], arguments[2], arguments[3]];
@@ -2201,12 +2266,7 @@ function setfontname(v){
}
setfontname.local = 1;
declareattribute("menu_mode", "getmenu_mode", "setmenu_mode", 1, {style: "enumindex", enumvals: ["Preset number + name", "Preset number", "Preset name"], label: "Menu Mode"});
function getmenu_mode() {
return menu_mode;
}
getmenu_mode.local = 1;
declareattribute("menu_mode", null, "setmenu_mode", 1, {style: "enumindex", enumvals: ["Preset number + name", "Preset number", "Preset name"], label: "Menu Mode"});
function setmenu_mode(v){
if (arguments.length == 1) {
menu_mode = Math.min(Math.max(0, parseInt(v)), 2);
@@ -2245,12 +2305,7 @@ function setignoreslotzero(v){
}
setignoreslotzero.local = 1;
declareattribute("display_interp", "getdisplayinterp", "setdisplayinterp", 1, {style: "onoff", label: "Display Interpolations", category: "Appearance"});
function getdisplayinterp() {
return display_interp;
}
getdisplayinterp.local = 1;
declareattribute("display_interp", null, "setdisplayinterp", 1, { style: "onoff", label: "Display Interpolations", category: "Appearance" });
function setdisplayinterp(v){
if (v == 0) {
display_interp = 0;
@@ -2260,12 +2315,7 @@ function setdisplayinterp(v){
}
setdisplayinterp.local = 1;
declareattribute("layout", "getlayout", "setlayout", 1, {style: "enumindex", enumvals: ["Grid", "List"], label: "Layout", category: "Appearance"});
function getlayout() {
return layout;
}
getlayout.local = 1;
declareattribute("layout", null, "setlayout", 1, {style: "enumindex", enumvals: ["Grid", "List"], label: "Layout", category: "Appearance"});
function setlayout(v){
if (v == 0) {
layout = 0;
@@ -2277,12 +2327,7 @@ function setlayout(v){
}
setlayout.local = 1;
declareattribute("scrollable", "getscrollable", "setscrollable", 1, {style: "onoff", label: "Scrollable"});
function getscrollable() {
return scrollable;
}
getscrollable.local = 1;
declareattribute("scrollable", null, "setscrollable", 1, {style: "onoff", label: "Scrollable"});
function setscrollable(v){
if (v == 0) {
scrollable = 0;
@@ -2294,11 +2339,7 @@ function setscrollable(v){
}
setscrollable.local = 1;
declareattribute("min_rows", "getmin_rows", "setmin_rows", 1, {type: "long", min: 1, label: "Minimum Rows"});
function getmin_rows() {
return min_rows;
}
getmin_rows.local = 1;
declareattribute("min_rows", null, "setmin_rows", 1, {type: "long", min: 1, label: "Minimum Rows"});
function setmin_rows(v){
if (v > 0) {
min_rows = v;
@@ -2311,24 +2352,18 @@ setmin_rows.local = 1;
declareattribute("click_mode", null, null, 1, { style: "enumindex", enumvals: ["Recall", "Select", "Store", "Delete"], default: 0, label: "Click Mode", paint: 1});
declareattribute("select_mode", "getselect_mode", "setselect_mode", 1, {style: "onoff", label: "Select Mode", invisible: 1});
function getselect_mode() {
return select_mode;
}
getselect_mode.local = 1;
declareattribute("select_mode", null, "setselect_mode", 1, {style: "onoff", label: "Select Mode", invisible: 1});
function setselect_mode(v) {
select_mode = v ? 1 : 0;
if (select_mode) this.box.message("click_mode", v);
}
setselect_mode.local = 1;
declareattribute("color_mode", "getcolor_mode", "setcolor_mode", 1, {type: "long", min: 0, max: 3, style: "enumindex", enumvals: ["Classic", "Cycle", "Select", "Custom"], label: "Color Mode", category: "Appearance"});
function getcolor_mode() {
return color_mode;
}
getcolor_mode.local = 1;
declareattribute("drag_mode", null, null, 1, { style: "enumindex", enumvals: ["Disabled", "Move", "In-Line Interp", "Interp"], default: 1, label: "Drag Mode", paint: 1 });
declareattribute("drag_interp_radius", null, null, 1, { type: "float", min: 1, default: 1, label: "Drag Interpolation Radius" });
declareattribute("color_mode", null, "setcolor_mode", 1, {type: "long", min: 0, max: 3, style: "enumindex", enumvals: ["Classic", "Cycle", "Select", "Custom"], label: "Color Mode", category: "Appearance"});
function setcolor_mode(v){
v = Math.floor(v);
v = Math.max(0, Math.min(3, v));
@@ -2353,12 +2388,7 @@ function setcolor_mode(v){
}
setcolor_mode.local = 1;
declareattribute("color_1", "getcolor1", "setcolor1", 1, {style: "rgba", label: "Color 1", category: "Appearance"});
function getcolor1() {
return color_1;
}
getcolor1.local = 1;
declareattribute("color_1", null, "setcolor1", 1, {style: "rgba", label: "Color 1", category: "Appearance"});
function setcolor1(){
if (arguments.length == 4) {
color_wheel(1, arguments[0], arguments[1], arguments[2], arguments[3]);
@@ -2370,12 +2400,7 @@ function setcolor1(){
}
setcolor1.local = 1;
declareattribute("color_2", "getcolor2", "setcolor2", 1, {style: "rgba", label: "Color 2", category: "Appearance"});
function getcolor2() {
return color_2;
}
getcolor2.local = 1;
declareattribute("color_2", null, "setcolor2", 1, {style: "rgba", label: "Color 2", category: "Appearance"});
function setcolor2(){
if (arguments.length == 4) {
color_wheel(2, arguments[0], arguments[1], arguments[2], arguments[3]);
@@ -2387,12 +2412,7 @@ function setcolor2(){
}
setcolor2.local = 1;
declareattribute("color_3", "getcolor3", "setcolor3", 1, {style: "rgba", label: "Color 3", category: "Appearance"});
function getcolor3() {
return color_3;
}
getcolor3.local = 1;
declareattribute("color_3", null, "setcolor3", 1, {style: "rgba", label: "Color 3", category: "Appearance"});
function setcolor3(){
if (arguments.length == 4) {
color_wheel(3, arguments[0], arguments[1], arguments[2], arguments[3]);
@@ -2404,12 +2424,7 @@ function setcolor3(){
}
setcolor3.local = 1;
declareattribute("color_4", "getcolor4", "setcolor4", 1, {style: "rgba", label: "Color 4", category: "Appearance"});
function getcolor4() {
return color_4;
}
getcolor4.local = 1;
declareattribute("color_4", null, "setcolor4", 1, {style: "rgba", label: "Color 4", category: "Appearance"});
function setcolor4(){
if (arguments.length == 4) {
color_wheel(4, arguments[0], arguments[1], arguments[2], arguments[3]);
@@ -2421,12 +2436,7 @@ function setcolor4(){
}
setcolor4.local = 1;
declareattribute("color_5", "getcolor5", "setcolor5", 1, {style: "rgba", label: "Color 5", category: "Appearance"});
function getcolor5() {
return color_5;
}
getcolor5.local = 1;
declareattribute("color_5", null, "setcolor5", 1, {style: "rgba", label: "Color 5", category: "Appearance"});
function setcolor5(){
if (arguments.length == 4) {
color_wheel(5, arguments[0], arguments[1], arguments[2], arguments[3]);
@@ -2438,12 +2448,7 @@ function setcolor5(){
}
setcolor5.local = 1;
declareattribute("color_6", "getcolor6", "setcolor6", 1, {style: "rgba", label: "Color 6", category: "Appearance"});
function getcolor6() {
return color_6;
}
getcolor6.local = 1;
declareattribute("color_6", null, "setcolor6", 1, {style: "rgba", label: "Color 6", category: "Appearance"});
function setcolor6(){
if (arguments.length == 4) {
color_wheel(6, arguments[0], arguments[1], arguments[2], arguments[3]);
@@ -2455,12 +2460,7 @@ function setcolor6(){
}
setcolor6.local = 1;
declareattribute("send_name", "getsendname", "setsendname", 1, {type: "symbol", label: "Send Dictionary To"});
function getsendname() {
return send_name;
}
getsendname.local = 1;
declareattribute("send_name", null, "setsendname", 1, {type: "symbol", label: "Send Dictionary To"});
function setsendname(){
if (arguments.length > 0) {
send_name = arguments[0];
@@ -2470,12 +2470,7 @@ function setsendname(){
}
setsendname.local = 1;
declareattribute("unique_names", "getunique_names", "setunique_names", 1, {style: "onoff", label: "Force Unique Names"});
function getunique_names() {
return unique_names;
}
getunique_names.local = 1;
declareattribute("unique_names", null, "setunique_names", 1, {style: "onoff", label: "Force Unique Names"});
function setunique_names(v){
unique_names = v > 0;
}
@@ -2483,12 +2478,7 @@ setunique_names.local = 1;
declareattribute("autoname", null, null, 1, { style: "onoff", label: "Autoname new presets" });
declareattribute("use_uid", "getuse_uid", "setuse_uid", 1, {style: "onoff", label: "Use UID"});
function getuse_uid() {
return use_uid;
}
getuse_uid.local = 1;
declareattribute("use_uid", null, "setuse_uid", 1, {style: "onoff", label: "Use UID"});
function setuse_uid(v){
var new_val = v == 1 ? 1 : 0;
if (new_val != use_uid && new_val == 1) {
@@ -2517,23 +2507,19 @@ function settimestamp(v){
}
settimestamp.local = 1;
declareattribute("recall_passthrough", "getrecall_passthrough", "setrecall_passthrough", 1, {style: "onoff", label: "Recall Passthrough"});
function getrecall_passthrough() {
return recall_passthrough;
}
getrecall_passthrough.local = 1;
declareattribute("recall_passthrough", null, "setrecall_passthrough", 1, {style: "onoff", label: "Recall Passthrough"});
function setrecall_passthrough(v){
recall_passthrough = v > 0;
}
setrecall_passthrough.local = 1;
declareattribute("ui_rename", "getui_rename", "setui_rename", 1, {style: "onoff", label: "Rename In UI"});
function getui_rename() {
return ui_rename;
declareattribute("store_passthrough", null, "setstore_passthrough", 1, {style: "onoff", label: "Store Passthrough"});
function setstore_passthrough(v){
store_passthrough = v > 0;
}
getui_rename.local = 1;
setstore_passthrough.local = 1;
declareattribute("ui_rename", null, "setui_rename", 1, {style: "onoff", label: "Rename In UI"});
function setui_rename(v){
ui_rename = v > 0;
if (ui_rename) {
@@ -2542,12 +2528,7 @@ function setui_rename(v){
}
setui_rename.local = 1;
declareattribute("poll_edited", "getpoll_edited", "setpoll_edited", 1, {type: "float", min: 0, label: "Poll Edited State"});
function getpoll_edited() {
return poll_edited;
}
getpoll_edited.local = 1;
declareattribute("poll_edited", null, "setpoll_edited", 1, {type: "float", min: 0, label: "Poll Edited State"});
function setpoll_edited(v){
poll_edited = v == 0 ? 0 : Math.max(0.1, Math.abs(v));
if (poll_edited > 0) {
@@ -2578,12 +2559,7 @@ function do_poll_edited() {
}
do_poll_edited.local = 1;
declareattribute("edited_color", "getedited_color", "setedited_color", 1, {style: "rgba", label: "Edited Dot Color", category: "Appearance"});
function getedited_color() {
return edited_color;
}
getedited_color.local = 1;
declareattribute("edited_color", null, "setedited_color", 1, {style: "rgba", label: "Edited Dot Color", category: "Appearance"});
function setedited_color(){
if (arguments.length == 4) {
edited_color = [arguments[0], arguments[1], arguments[2], arguments[3]];
@@ -2603,12 +2579,7 @@ function edited(v) {
}
}
declareattribute("nbslot_edit", "getnbslot_edit", "setnbslot_edit", 1, {style: "onoff", label: "Add/remove rows of presets"});
function getnbslot_edit() {
return nbslot_edit;
}
getnbslot_edit.local = 1;
declareattribute("nbslot_edit", null, "setnbslot_edit", 1, {style: "onoff", label: "Add/remove rows of presets"});
function setnbslot_edit(v){
nbslot_edit = v > 0;
y_offset = 0;