Browse Source

Updated documentation and test patcher.

main
TFLCL 1 month ago
parent
commit
2b27dee78f
  1. 7
      code/tc.preset.js
  2. 23
      docs/tc.preset.maxref.xml
  3. 1137
      help/tc.preset.maxhelp
  4. 219
      patchers/tc.preset_demo.maxpat

7
code/tc.preset.js

@ -73,7 +73,7 @@ var auto_writeagain = 0; // When enabled, will send a "writeagain" to pattrst
var menu_number_only = 0; // Populates the umenu connected to 2nd outlet with stored preset number only, instead of number and name
var scrollable = 1; // Defines weither the object can be scrolled or not
var min_rows = 50; // 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
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.
// (WORK)
@ -150,7 +150,6 @@ function slot(left, top, right, bottom, name, lock, interp, color_index, color_c
}
}
function loadbang() {
// post("loadbang\n");
has_loaded = true;
@ -522,6 +521,7 @@ function color_wheel() {
// But that makes the code sooo ugly...
var args = arrayfromargs(arguments);
if (args.length == 0) {
// Reset to default
color_wheel_custom = [];
color_wheel_custom = color_wheel_default.slice();
color_1 = color_wheel_default[0];
@ -531,6 +531,7 @@ function color_wheel() {
color_5 = color_wheel_default[4];
color_6 = color_wheel_default[5];
} else if (args.length == 5) {
// Set color
var n = args[0];
var col = [args[1], args[2], args[3], args[4]]
if (n > 0 && n < 7) {
@ -1606,7 +1607,7 @@ function getcolor_mode() {
function setcolor_mode(v){
v = Math.floor(v);
v = Math.max(0, Math.min(3, v));
// For color modes 2 and 3 (free and custom),
// For color modes 2 and 3 (select and custom),
// we need to ensure there's a [pattr preset_color] somewhere to store the preset color
if (v >= 2 ) {
if (!preset_color_pattr_exist()) {

23
docs/tc.preset.maxref.xml

@ -53,12 +53,23 @@
<description>Function depends on inlet</description>
</method> -->
<method name="color_wheel">
<digest>Set the slot colors</digest>
<digest>Define color wheel colors</digest>
<description>The message "color_wheel", followed by an integer and four float, defines one of the 6 available slot colors when color_mode is enabled.
The integer argument, between 1 and 6, defines which color in being modifier, and next the four floats define the color in the RGBA format.
The integer argument, between 1 and 6, defines which color in being modified, and next the four floats define the color in the RGBA format.
The message "color_wheel" without argument resets the six colors to their default values.
</description>
</method>
<method name="setcolor">
<digest>Set the preset colors</digest>
<description>The message "setcolor" allows to set the color of a preset as shown when in color_mode 2 (select) or 3 (custom).
With 1 or 2 integer arguments, it allows to set a preset color as seen in color mode 2. With 4 float arguments or 1 integer followed by 4 floats, it allows to set a preset color for the color mode 3.
With 1 integer argument, the currently selected preset color wheel's color is set to the argument's value.
With two integer arguments, the preset number defined by first argument is set to color wheel's color defined by the second argument.
With 4 float arguments, the currently selected preset is set to a custom color defined by the four arguments (in RGBA format).
With 1 integer followed by 4 float arguments, the preset number defined by first argument is set to a custom color defined by the four arguments (in RGBA format).
The integer argument, between 1 and 6, defines which color in being modifier, and next the four floats define the color in the RGBA format.
</description>
</method>
<method name="pattrstorage">
<digest>Link to named pattrstorage object</digest>
<description>The word 'pattrstorage' followed by the name of an existing pattrstorage links the jsui to that pattrstorage.
@ -113,7 +124,13 @@
</attribute>
<attribute name='color_mode' get='1' set='1' type='int' size='1' >
<digest>Color mode</digest>
<description>When set to 0, all preset slots have the same color (same as the preset object). When set to 1, stored preset slots are colored. See color_1 to color_6 as well as the color_wheel message.</description>
<description>When set to 0, all preset slots have the same color (same as the preset object) defined by the stored_slot_color attribute.
When set to 1, stored preset slots are colored according to one of the six colors of the color wheel, in a repeating pattern.
In mode 2, stored preset colors can be freely set to one of the six colors of the color wheel.
In mode 3, stored preset color can be set to any color in RGBA format.
To define colors of the color wheel for modes 1 and 2, see color_1 to color_6 as well as the color_wheel message.
To define preset color as in mode 2 or 3, see the setcolor message. Modes 2 and 3 require a pattr object named 'preset_color' to be at the same patcher level as the tc.preset object.
</description>
</attribute>
<attribute name='color_1' get='1' set='1' type='list' size='4' >
<digest>Slot color 1</digest>

1137
help/tc.preset.maxhelp

File diff suppressed because it is too large Load Diff

219
patchers/tc.preset_demo.maxpat

@ -4,13 +4,13 @@
"appversion" : {
"major" : 8,
"minor" : 6,
"revision" : 3,
"revision" : 4,
"architecture" : "x64",
"modernui" : 1
}
,
"classnamespace" : "box",
"rect" : [ 310.0, 100.0, 854.0, 848.0 ],
"rect" : [ 451.0, 100.0, 630.0, 848.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
@ -40,37 +40,135 @@
"assistshowspatchername" : 0,
"boxes" : [ {
"box" : {
"id" : "obj-31",
"id" : "obj-61",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 245.5, 565.0, 89.0, 22.0 ],
"text" : "storagewindow"
"patching_rect" : [ 326.0, 524.0, 33.0, 22.0 ],
"text" : "read"
}
}
, {
"box" : {
"format" : 6,
"id" : "obj-68",
"maxclass" : "flonum",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 647.0, 515.0, 50.0, 22.0 ]
}
}
, {
"box" : {
"format" : 6,
"id" : "obj-54",
"maxclass" : "flonum",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 595.0, 515.0, 50.0, 22.0 ]
}
}
, {
"box" : {
"format" : 6,
"id" : "obj-49",
"maxclass" : "flonum",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 549.0, 515.0, 50.0, 22.0 ]
}
}
, {
"box" : {
"id" : "obj-9",
"maxclass" : "newobj",
"numinlets" : 5,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 522.0, 555.0, 127.0, 22.0 ],
"text" : "pak setcolor 0. 0. 0. 1."
}
}
, {
"box" : {
"id" : "obj-42",
"maxclass" : "number",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 522.0, 587.0, 50.0, 22.0 ]
}
}
, {
"box" : {
"id" : "obj-15",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 522.0, 616.0, 67.0, 22.0 ],
"text" : "setcolor $1"
}
}
, {
"box" : {
"id" : "obj-57",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 364.0, 524.0, 34.0, 22.0 ],
"text" : "write"
}
}
, {
"box" : {
"id" : "obj-25",
"id" : "obj-53",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 15.0, 664.0, 32.0, 22.0 ],
"text" : "print"
}
}
, {
"box" : {
"id" : "obj-51",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 422.0, 598.0, 45.0, 22.0 ],
"text" : "store 3"
"patching_rect" : [ 393.0, 564.0, 77.0, 22.0 ],
"text" : "clientwindow"
}
}
, {
"box" : {
"id" : "obj-14",
"id" : "obj-31",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 360.5, 586.0, 29.5, 22.0 ],
"text" : "init"
"patching_rect" : [ 245.5, 559.0, 89.0, 22.0 ],
"text" : "storagewindow"
}
}
@ -172,7 +270,7 @@
, {
"box" : {
"id" : "obj-111",
"items" : [ "Off", ",", "Cycle" ],
"items" : [ "Off", ",", "Cycle", ",", "Select", ",", "Custom" ],
"maxclass" : "umenu",
"numinlets" : 1,
"numoutlets" : 3,
@ -338,7 +436,7 @@
"appversion" : {
"major" : 8,
"minor" : 6,
"revision" : 3,
"revision" : 4,
"architecture" : "x64",
"modernui" : 1
}
@ -994,14 +1092,15 @@
"parameter_enable" : 0,
"patching_rect" : [ 302.0, 772.0, 100.0, 50.0 ],
"presentation" : 1,
"presentation_rect" : [ 146.0, 63.5, 119.0, 22.0 ]
"presentation_rect" : [ 146.0, 63.5, 119.0, 22.0 ],
"text" : "random"
}
}
, {
"box" : {
"id" : "obj-8",
"items" : "<empty>",
"items" : [ 1, "up", ",", 2, "down", ",", 3, "sine", ",", 4, "random" ],
"maxclass" : "umenu",
"numinlets" : 1,
"numoutlets" : 3,
@ -1090,7 +1189,7 @@
, {
"box" : {
"border" : 0,
"embedstate" : [ [ "layout", 0 ], [ "color_6", 0.316, 0.616, 0.377, 1 ], [ "text_color", 0.129, 0.129, 0.129, 1 ], [ "ignoreslotzero", 1 ], [ "min_rows", 50 ], [ "bgcolor", 0.2, 0.2, 0.2, 1 ], [ "spacing", 4 ], [ "empty_slot_color", 0.349, 0.349, 0.349, 1 ], [ "displayinterp", 1 ], [ "color_1", 0.743, 0.41, 0.501, 1 ], [ "text_bg_color", 1, 1, 1, 0.5 ], [ "slot_round", 0 ], [ "color_2", 0.679, 0.405, 0.669, 1 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "autowriteagain", 0 ], [ "color_3", 0.527, 0.459, 0.756, 1 ], [ "active_slot_color", 0.808, 0.898, 0.91, 1 ], [ "color_mode", 0 ], [ "margin", 4 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "fontsize", 14 ], [ "select_mode", 0 ], [ "color_5", 0.283, 0.606, 0.559, 1 ], [ "bubblesize", 20 ], [ "stored_slot_color", 0.502, 0.502, 0.502, 1 ], [ "scrollable", 1 ], [ "fontname", "Arial" ], [ "pattrstorage", "test" ] ],
"embedstate" : [ [ "text_color", 0.129, 0.129, 0.129, 1 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 0 ], [ "min_rows", 50 ], [ "bubblesize", 20 ], [ "color_mode", 0 ], [ "color_5", 0.283, 0.606, 0.559, 1 ], [ "display_interp", 1 ], [ "select_mode", 0 ], [ "color_1", 0.743, 0.41, 0.501, 1 ], [ "margin", 4 ], [ "empty_slot_color", 0.349, 0.349, 0.349, 1 ], [ "text_bg_color", 1, 1, 1, 0.5 ], [ "fontsize", 14 ], [ "color_6", 0.316, 0.616, 0.377, 1 ], [ "slot_round", 0 ], [ "bgcolor", 0.2, 0.2, 0.2, 1 ], [ "color_2", 0.679, 0.405, 0.669, 1 ], [ "fontname", "Arial" ], [ "autowriteagain", 0 ], [ "pattrstorage", "test" ], [ "active_slot_color", 0.808, 0.898, 0.91, 1 ], [ "color_3", 0.527, 0.459, 0.756, 1 ], [ "stored_slot_color", 0.502, 0.502, 0.502, 1 ], [ "scrollable", 1 ], [ "spacing", 4 ] ],
"filename" : "tc.preset.js",
"id" : "obj-10",
"maxclass" : "jsui",
@ -1100,7 +1199,8 @@
"parameter_enable" : 0,
"patching_rect" : [ 72.0, 636.0, 364.0, 125.0 ],
"presentation" : 1,
"presentation_rect" : [ 1.0, 103.0, 293.0, 149.0 ]
"presentation_rect" : [ 1.0, 103.0, 293.0, 149.0 ],
"varname" : "jsui_test"
}
}
@ -1124,7 +1224,7 @@
"numoutlets" : 3,
"outlettype" : [ "", "", "" ],
"patching_rect" : [ 465.0, 664.0, 40.0, 22.0 ],
"restore" : [ -0.714285714285714, -0.714285714285714, -0.6, -0.542857142857143, -0.457142857142857, -0.342857142857143, -0.171428571428571, -0.028571428571429, 0.028571428571428, 0.142857142857143, 0.228571428571429, 0.371428571428571, 0.485714285714286, 0.571428571428571, 0.714285714285714, 0.8 ],
"restore" : [ -0.079365079365079, 0.206349206349206, 0.428571428571429, 0.682539682539683, 0.904761904761905, 0.904761904761905, 0.841269841269841, 0.555555555555556, 0.047619047619048, -0.301587301587302, -0.587301587301587, -0.682539682539683, -0.650793650793651, -0.428571428571429, -0.111111111111111, 0.079365079365079 ],
"saved_object_attributes" : {
"parameter_enable" : 0,
"parameter_mappable" : 0
@ -1156,15 +1256,16 @@
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 72.0, 599.0, 176.0, 22.0 ],
"patching_rect" : [ 72.0, 599.0, 283.0, 22.0 ],
"saved_object_attributes" : {
"client_rect" : [ 1450, 76, 2131, 1323 ],
"client_rect" : [ 4, 44, 358, 172 ],
"parameter_enable" : 0,
"parameter_mappable" : 0,
"storage_rect" : [ 583, 69, 1034, 197 ]
}
,
"text" : "pattrstorage test @savemode 0",
"subscribe" : [ "u099005226", "preset_color" ],
"text" : "pattrstorage test @savemode 0 @subscribemode 1",
"varname" : "test"
}
@ -1371,7 +1472,7 @@
, {
"patchline" : {
"destination" : [ "obj-10", 0 ],
"source" : [ "obj-14", 0 ]
"source" : [ "obj-15", 0 ]
}
}
@ -1427,13 +1528,6 @@
"source" : [ "obj-24", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-10", 0 ],
"source" : [ "obj-25", 0 ]
}
}
, {
"patchline" : {
@ -1506,6 +1600,13 @@
"source" : [ "obj-41", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-15", 0 ],
"source" : [ "obj-42", 0 ]
}
}
, {
"patchline" : {
@ -1552,6 +1653,13 @@
"source" : [ "obj-48", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-9", 1 ],
"source" : [ "obj-49", 0 ]
}
}
, {
"patchline" : {
@ -1560,6 +1668,20 @@
"source" : [ "obj-5", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-51", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-9", 2 ],
"source" : [ "obj-54", 0 ]
}
}
, {
"patchline" : {
@ -1574,6 +1696,13 @@
"source" : [ "obj-56", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-57", 0 ]
}
}
, {
"patchline" : {
@ -1588,6 +1717,13 @@
"source" : [ "obj-60", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-61", 0 ]
}
}
, {
"patchline" : {
@ -1597,6 +1733,13 @@
"source" : [ "obj-63", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-9", 3 ],
"source" : [ "obj-68", 0 ]
}
}
, {
"patchline" : {
@ -1641,6 +1784,13 @@
"source" : [ "obj-87", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-10", 0 ],
"source" : [ "obj-9", 0 ]
}
}
, {
"patchline" : {
@ -1661,11 +1811,18 @@
],
"dependency_cache" : [ {
"name" : "tc.preset.js",
"bootpath" : "~/Documents/_MAX/tc.preset",
"patcherrelativepath" : ".",
"bootpath" : "~/Documents/Max 8/Packages/tc.preset/code",
"patcherrelativepath" : "../code",
"type" : "TEXT",
"implicit" : 1
}
, {
"name" : "test.json",
"bootpath" : "~/Documents/Max 8/Packages/tc.preset/help",
"patcherrelativepath" : "../help",
"type" : "JSON",
"implicit" : 1
}
],
"autosave" : 0
}

Loading…
Cancel
Save