Compare commits

..

4 Commits

3 changed files with 48 additions and 18 deletions

View File

@@ -78,6 +78,11 @@
If the word `pattrstorage`is sent alone, the jsui is unlinked from any pattrstorage.
</description>
</method>
<method name="recall_filled">
<digest>Recalls nth filled preset</digest>
<description>Recalls the nth filled preset. Example: 'recall_filled 3' will recall the third available filled preset from the preset list, regardless of its slot number.
</description>
</method>
<method name="resync">
<digest>Resync the jsui to the pattrstorage</digest>
<description>The word 'resync' will repopulate the jsui with the current preset list from the pattrstorage. It is usefull in case you add/remove/edit presets without using the jsui.
@@ -174,6 +179,10 @@
<digest>Object margin</digest>
<description>Defines the size, in pixels, of the margin between the jsui border and the preset slots.</description>
</attribute>
<attribute name='menu_mode' get='1' set='1' type='int' size='1' >
<digest>Menu mode</digest>
<description>Populates the umenu connected to 2nd outlet with preset number and name (0), preset number only (1), or name only (2). See recall_filled when using mode 2</description>
</attribute>
<attribute name='min_rows' get='1' set='1' type='int' size='1' >
<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.

View File

@@ -1,2 +1,2 @@
max objectfile tc.preset tc.preset;
max definesubstitution tc.preset jsui @filename tc.preset
max definesubstitution tc.preset jsui @filename tc.preset;

View File

@@ -70,7 +70,7 @@ 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
@@ -205,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;
@@ -849,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 = [];
@@ -973,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) {
@@ -1093,11 +1100,18 @@ 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) {
@@ -1134,11 +1148,7 @@ 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() {
@@ -1603,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;