|
|
|
@@ -70,11 +70,12 @@ var layout = 0; // 0: grid mode (same as [preset]). 1: list mode
|
|
|
|
|
var display_interp = 1; // Enable/disable the UI feedback when interpolating between presets
|
|
|
|
|
var ignore_slot_zero = 1; // Makes previous_active_slot and interpolation display to ignore slot 0. Can be usefull when using slot 0 as a temporary step for interpolation.
|
|
|
|
|
var auto_writeagain = 0; // When enabled, will send a "writeagain" to pattrstorage any time a preset is stored/deleted/moved/renamed/(un)locked
|
|
|
|
|
var menu_number_only = 0; // Populates the umenu connected to 2nd outlet with stored preset number only, instead of number and name
|
|
|
|
|
var menu_mode = 0; // Populates the umenu connected to 2nd outlet with preset number and name (0), preset number only (1), or name only (2)
|
|
|
|
|
var scrollable = 0; // Defines weither the object can be scrolled or not
|
|
|
|
|
var min_rows = 10; // Minimum number of rows to display if scrollable is enabled
|
|
|
|
|
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 send_name = "none"; // The global name to send presets dict name to (received by the [receive] object)
|
|
|
|
|
|
|
|
|
|
// (WORK)
|
|
|
|
|
var pattrstorage_name, pattrstorage_obj = null;
|
|
|
|
@@ -84,6 +85,7 @@ var slots = []; // Stores on screen box, name, lock and interpol
|
|
|
|
|
var slots_highest = 0; // Highest filled preset slot number
|
|
|
|
|
var slots_count_display = 0; // Number of slots to be displayed
|
|
|
|
|
var filled_slots = []; // List of stored slots
|
|
|
|
|
var filled_slots_dict = new Dict();
|
|
|
|
|
|
|
|
|
|
var active_slot = 0; //Last recalled slot
|
|
|
|
|
var previous_active_slot = 0; //Previously recalled slot
|
|
|
|
@@ -203,13 +205,6 @@ function calc_rows_columns() {
|
|
|
|
|
slots[cur] = new slot(left, top, right, bottom, prev_state.name, prev_state.lock, prev_state.interp, prev_state.color_index, prev_state.color_custom);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (slots_count_display < slots_highest) {
|
|
|
|
|
for (var i = slots_count_display + 1; i <= slots_highest; i++) {
|
|
|
|
|
slots[i] = new slot();
|
|
|
|
|
slots[i].init();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
paint_base();
|
|
|
|
|
}
|
|
|
|
|
calc_rows_columns.local = 1;
|
|
|
|
@@ -381,10 +376,6 @@ function paint()
|
|
|
|
|
|
|
|
|
|
// Previous active slot
|
|
|
|
|
if (is_dragging == 0 && previous_active_slot > 0 && previous_active_slot <= slots_count_display) {
|
|
|
|
|
// set_source_rgba(active_slot_color);
|
|
|
|
|
// draw_slot_bubble(slots[previous_active_slot][0]+0.75, slots[previous_active_slot][1]+0.75, slot_size-1.5, slot_size-1.5);
|
|
|
|
|
// set_line_width(1.5);
|
|
|
|
|
// stroke();
|
|
|
|
|
set_source_rgba(active_slot_color[0], active_slot_color[1], active_slot_color[2], active_slot_color[3] * 0.5);
|
|
|
|
|
if (color_mode) {
|
|
|
|
|
draw_slot_bubble(slots[previous_active_slot].left+1.5, slots[previous_active_slot].top+1.5, slot_size-3, slot_size-3);
|
|
|
|
@@ -396,6 +387,13 @@ function paint()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Hide dragged slot
|
|
|
|
|
if (is_dragging) {
|
|
|
|
|
set_source_rgba(empty_slot_color);
|
|
|
|
|
draw_slot_bubble(slots[drag_slot].left, slots[drag_slot].top, slot_size, slot_size);
|
|
|
|
|
fill();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Selected slot
|
|
|
|
|
if (selected_slot > 0 && selected_slot <= slots_count_display) {
|
|
|
|
|
set_source_rgba(active_slot_color);
|
|
|
|
@@ -434,6 +432,7 @@ function paint()
|
|
|
|
|
fill();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Slot border
|
|
|
|
|
set_source_rgba(1, 1, 1, 0.8);
|
|
|
|
|
draw_slot_bubble(slots[last_hovered].left, slots[last_hovered].top, slot_size, slot_size);
|
|
|
|
@@ -516,7 +515,7 @@ function paint()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
paint.local = 1;
|
|
|
|
|
paint.local = 0;
|
|
|
|
|
|
|
|
|
|
function color_wheel() {
|
|
|
|
|
// Rather than using an array of colors, each color has its own variable, so they can be declared as attributes and saved with the patch
|
|
|
|
@@ -592,6 +591,7 @@ function setcolor() {
|
|
|
|
|
slots[slot_nb].color_custom = [args[1], args[2], args[3], args[4]];
|
|
|
|
|
}
|
|
|
|
|
update_preset_color_pattr(slot_nb);
|
|
|
|
|
update_filled_slots_dict();
|
|
|
|
|
paint_base();
|
|
|
|
|
trigger_writeagain();
|
|
|
|
|
}
|
|
|
|
@@ -676,21 +676,23 @@ function anything() {
|
|
|
|
|
} else if (previous_active_slot == v) {
|
|
|
|
|
previous_active_slot = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// to_pattrstorage("getslotname", v);
|
|
|
|
|
to_pattrstorage("delete", v);
|
|
|
|
|
to_pattrstorage("getslotlist");
|
|
|
|
|
paint_base();
|
|
|
|
|
set_active_slot(active_slot);
|
|
|
|
|
if (!is_dragging) {
|
|
|
|
|
outlet(0, "delete", v);
|
|
|
|
|
if (selected_slot == v) {
|
|
|
|
|
selected_slot == 0
|
|
|
|
|
outlet(2, 'set');
|
|
|
|
|
outlet(3, 'set', 0);
|
|
|
|
|
|
|
|
|
|
if (is_dragging == 0) {
|
|
|
|
|
to_pattrstorage("delete", v);
|
|
|
|
|
to_pattrstorage("getslotlist");
|
|
|
|
|
paint_base();
|
|
|
|
|
set_active_slot(active_slot);
|
|
|
|
|
if (!is_dragging) {
|
|
|
|
|
outlet(0, "delete", v);
|
|
|
|
|
if (selected_slot == v) {
|
|
|
|
|
selected_slot == 0
|
|
|
|
|
outlet(2, 'set');
|
|
|
|
|
outlet(3, 'set', 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
trigger_writeagain();
|
|
|
|
|
}
|
|
|
|
|
trigger_writeagain();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@@ -741,7 +743,9 @@ function slotlist() {
|
|
|
|
|
for (var i = 0; i < filled_slots.length; i++) {
|
|
|
|
|
to_pattrstorage("getslotname", filled_slots[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_all_preset_colors();
|
|
|
|
|
update_filled_slots_dict();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -754,15 +758,20 @@ function slotname() {
|
|
|
|
|
|
|
|
|
|
function setslotname() {
|
|
|
|
|
// Because [pattrstorage] doesn't output anything when renaming presets with "slotname", we use a custom "setslotname" instead, that will rename the active preset
|
|
|
|
|
if (active_slot > 0) {
|
|
|
|
|
var sname = arrayfromargs(arguments).join(' ');
|
|
|
|
|
slotname(selected_slot, sname);
|
|
|
|
|
to_pattrstorage("slotname", selected_slot, sname);
|
|
|
|
|
update_umenu();
|
|
|
|
|
select(selected_slot);
|
|
|
|
|
trigger_writeagain();
|
|
|
|
|
if (layout == 1) {
|
|
|
|
|
paint_base();
|
|
|
|
|
if (selected_slot > 0) {
|
|
|
|
|
if (slots[selected_slot].lock == 0) {
|
|
|
|
|
var sname = arrayfromargs(arguments).join(' ');
|
|
|
|
|
slotname(selected_slot, sname);
|
|
|
|
|
to_pattrstorage("slotname", selected_slot, sname);
|
|
|
|
|
update_umenu();
|
|
|
|
|
update_filled_slots_dict();
|
|
|
|
|
select(selected_slot);
|
|
|
|
|
trigger_writeagain();
|
|
|
|
|
if (layout == 1) {
|
|
|
|
|
paint_base();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
error('Cannot set name of locked slot\n');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -833,6 +842,15 @@ function recall() {
|
|
|
|
|
mgraphics.redraw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function recall_filled() {
|
|
|
|
|
// Recalling preset by its number in the filled_slots list. Useful when used menu_mode 2
|
|
|
|
|
var args = arrayfromargs(arguments);
|
|
|
|
|
var index = args[0];
|
|
|
|
|
if (index < filled_slots.length) {
|
|
|
|
|
to_pattrstorage('recall', filled_slots[args[0]]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function recallmulti() {
|
|
|
|
|
var args = arrayfromargs(arguments);
|
|
|
|
|
var interp_slots = [];
|
|
|
|
@@ -907,6 +925,7 @@ function lock() {
|
|
|
|
|
to_pattrstorage("lock", args[0], args[1]);
|
|
|
|
|
to_pattrstorage("getlockedslots");
|
|
|
|
|
outlet(0, "lock", args[0], args[1]);
|
|
|
|
|
update_filled_slots_dict();
|
|
|
|
|
trigger_writeagain();
|
|
|
|
|
if (layout == 1) {
|
|
|
|
|
paint_base();
|
|
|
|
@@ -930,9 +949,9 @@ function lockedslots() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function write() {
|
|
|
|
|
var args = arrayfromargs(arguments);
|
|
|
|
|
if (is_writing) {
|
|
|
|
|
is_writing = 0;
|
|
|
|
|
var args = arrayfromargs(arguments);
|
|
|
|
|
var filename = args[0];
|
|
|
|
|
var state = args[1];
|
|
|
|
|
if (state) {
|
|
|
|
@@ -941,7 +960,9 @@ function write() {
|
|
|
|
|
error(pattrstorage_name + ': error while writing ' + filename + '\n');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
error("Send your write messages directly to the pattrstorage instead.\n");
|
|
|
|
|
if (args.length < 2) {
|
|
|
|
|
error("Send your write messages directly to the pattrstorage instead.\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@@ -954,6 +975,11 @@ function read() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Given that v8ui has a new read method that cannot be overriden, we need to use [substitute read readfile] between [pattrstorage] and [tc.prest]
|
|
|
|
|
function readfile(f, s) {
|
|
|
|
|
read(f, s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function subscriptionlist() {
|
|
|
|
|
var client = arrayfromargs(arguments)[0];
|
|
|
|
|
if (is_listening_to_subscriptionlist) {
|
|
|
|
@@ -1018,7 +1044,6 @@ find_pattrstorage.local = 1;
|
|
|
|
|
|
|
|
|
|
function to_pattrstorage() {
|
|
|
|
|
if (pattrstorage_obj !== null) {
|
|
|
|
|
// post('To pattrstorage:', arrayfromargs(arguments), '\n');
|
|
|
|
|
pattrstorage_obj.message(arrayfromargs(arguments));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -1075,25 +1100,55 @@ function update_umenu() {
|
|
|
|
|
|
|
|
|
|
for (var i=0; i < filled_slots.length; i++) {
|
|
|
|
|
var nb = filled_slots[i];
|
|
|
|
|
var txt = null;
|
|
|
|
|
if (!menu_number_only) {
|
|
|
|
|
txt = slots[filled_slots[i]].name;
|
|
|
|
|
var txt = slots[filled_slots[i]].name;
|
|
|
|
|
switch(menu_mode){
|
|
|
|
|
case 0:
|
|
|
|
|
outlet(1, "append", nb, txt);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
outlet(1, "append", nb);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
outlet(1, "append", txt);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
outlet(1, "append", nb, txt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (layout == 1) {
|
|
|
|
|
set_umenu(selected_slot);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
update_umenu.local = 1;
|
|
|
|
|
|
|
|
|
|
function update_filled_slots_dict() {
|
|
|
|
|
// Creates a coll-compatible dict containing slot id, name, lock, color index and color_custom for all existing presets
|
|
|
|
|
// And sends the dict name to a receive.
|
|
|
|
|
// Best would be to allow for single slot updates, but for that we need to be able to know which at index of filled_slot is a slot id.
|
|
|
|
|
filled_slots_dict.clear();
|
|
|
|
|
for (var i = 0; i < filled_slots.length; i++) {
|
|
|
|
|
var slot_index = filled_slots[i];
|
|
|
|
|
var tmp_color_custom = slots[slot_index].color_custom;
|
|
|
|
|
filled_slots_dict.set(slot_index, slots[slot_index].name, slots[slot_index].lock, slots[slot_index].color_index, tmp_color_custom[0], tmp_color_custom[1], tmp_color_custom[2], tmp_color_custom[3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Non coll-compatible, but with proper keys:
|
|
|
|
|
// filled_slots_dict.set('filled_slots');
|
|
|
|
|
// for (var i = 0; i < filled_slots.length; i++) {
|
|
|
|
|
// if (i > 0) filled_slots_dict.append('filled_slots', '');
|
|
|
|
|
// var tmp_color_custom = slots[filled_slots[i]].color_custom;
|
|
|
|
|
// filled_slots_dict.setparse('filled_slots[' + i + ']', 'slot:', filled_slots[i], 'name:', '"' + slots[filled_slots[i]].name + '"', 'lock:', slots[filled_slots[i]].lock, 'color_index:', slots[filled_slots[i]].color_index, 'color_custom:', tmp_color_custom[0], tmp_color_custom[1], tmp_color_custom[2], tmp_color_custom[3]);
|
|
|
|
|
// }
|
|
|
|
|
var tmp_send_name = send_name == "none" ? pattrstorage_name + '_presets_dict' : send_name;
|
|
|
|
|
messnamed(tmp_send_name, 'dictionary', filled_slots_dict.name);
|
|
|
|
|
}
|
|
|
|
|
update_filled_slots_dict.local = 1;
|
|
|
|
|
|
|
|
|
|
function set_umenu(v) {
|
|
|
|
|
outlet(1, "clearchecks");
|
|
|
|
|
var item = filled_slots.indexOf(v);
|
|
|
|
|
outlet(1, "checkitem", item);
|
|
|
|
|
if (menu_number_only) {
|
|
|
|
|
outlet(1, "setsymbol", v);
|
|
|
|
|
} else {
|
|
|
|
|
outlet(1, "setsymbol", v + ' ' + slots[v].name);
|
|
|
|
|
}
|
|
|
|
|
outlet(1, "set", item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function trigger_writeagain() {
|
|
|
|
@@ -1189,7 +1244,6 @@ function ondrag(x,y,but,cmd,shift,capslock,option,ctrl)
|
|
|
|
|
if (dist_from_start > 10) {
|
|
|
|
|
is_dragging = 1;
|
|
|
|
|
drag_slot = last_hovered;
|
|
|
|
|
paint_base();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (is_dragging == 1) {
|
|
|
|
@@ -1559,6 +1613,17 @@ function setfontname(v){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
declareattribute("menu_mode", "getmenu_mode", "setmenu_mode", 1);
|
|
|
|
|
function getmenu_mode() {
|
|
|
|
|
return menu_mode;
|
|
|
|
|
}
|
|
|
|
|
function setmenu_mode(v){
|
|
|
|
|
if (arguments.length == 1) {
|
|
|
|
|
menu_mode = Math.min(Math.max(0, parseInt(v)), 2);
|
|
|
|
|
update_umenu();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
declareattribute("autowriteagain", "getautowriteagain", "setautowriteagain", 1);
|
|
|
|
|
function getautowriteagain() {
|
|
|
|
|
return auto_writeagain;
|
|
|
|
@@ -1769,6 +1834,18 @@ function setcolor6(){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
declareattribute("send_name", "getsendname", "setsendname", 1);
|
|
|
|
|
function getsendname() {
|
|
|
|
|
return send_name;
|
|
|
|
|
}
|
|
|
|
|
function setsendname(){
|
|
|
|
|
if (arguments.length > 0) {
|
|
|
|
|
send_name = arguments[0];
|
|
|
|
|
} else {
|
|
|
|
|
send_name = "none";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UTILITY
|
|
|
|
|
function post_keys(obj) {
|
|
|
|
|
post('Keys of obj: ', obj, '\n');
|