@ -17,7 +17,7 @@ A [jsui] replacement for the [preset] object in Cycling'74 Max.
- More look customization
- Dynamically adapts to resize both in Edit and Presentation mode
- Select mode: simple click selects the slot, double click recalls it (allows for organizing presets without recalling them)
- Color mode: ability to color sstored presets with 6 customizable colors (currently colors are only assigned automatically depending on slot number)
- Color mode: various ways to colorize preset slots
## How to install
- [Download](https://github.com/Teufeuleu/tc.preset/archive/refs/heads/main.zip) this repository (and please consider donating on the [gumroad page](https://glucose47.gumroad.com/l/tc_preset) if you like this package)
@ -73,7 +73,7 @@ var auto_writeagain = 0; // When enabled, will send a "writeagain" to pattrst
varmenu_number_only=0;// Populates the umenu connected to 2nd outlet with stored preset number only, instead of number and name
varscrollable=1;// Defines weither the object can be scrolled or not
varmin_rows=50;// Minimum number of rows to display if scrollable is enabled
varcolor_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
varcolor_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
varselect_mode=0;// 0: single click to select and recall the slot. 1: single click to select the slot, double click to recall it.
// (WORK)
@ -105,6 +105,14 @@ var shift_hold, option_hold = 0;
varis_interpolating=0;
varis_dragging=0;// Drag flag
vardrag_slot=-1;// Stores the slot that's being dragged
varis_writing=0;
// Keeping track of various variables for dealing with color modes
varrequested_slot=-1;// Which slot we're waiting a value for (used in get_all_preset_colors)
varcolor_mode_candidate=0;// Which color mode we're aiming
varis_listening_to_subscriptionlist=0;//Filters out received subscriptionlist messages when not updating slot color values
varis_listening_to_clientlist=0;//Filters out received clientlist messages when not updating slot color values
varcolor_pattr;
varhas_loaded=false;
@ -113,6 +121,42 @@ if (jsarguments.length>1) { // Depreciated, use "pattrstorage" attribute instead
error(pattrstorage_name+': error while writing '+filename+'\n');
}
}else{
error(pattrstorage_name+': error while writing '+filename+'\n');
error("Send your write messages directly to the pattrstorage instead.\n");
}
}
functionread(){
@ -806,6 +966,37 @@ function read() {
}
}
functionsubscriptionlist(){
varclient=arrayfromargs(arguments)[0];
if(is_listening_to_subscriptionlist){
if(client=="preset_color"){
// [pattr preset_color] subscribed
// post("preset_color pattr object found and subscribed to bound pattrstorage. Switching to color mode", color_mode_candidate, '\n');
is_listening_to_subscriptionlist=0;
color_mode=color_mode_candidate;
paint_base();
}elseif(client=="done"){
error("A [pattr preset_color] object has been found but it isn't subscribed to your pattrstorage. Please add it to your subscribelist and try changing color mode again.\n")
is_listening_to_subscriptionlist=0;
}
}
}
functionclientlist(){
varclient=arrayfromargs(arguments)[0];
if(is_listening_to_clientlist){
if(client=="preset_color"){
// post("preset_color pattr object found and client to bound pattrstorage. Switching to color mode", color_mode_candidate, '\n');
is_listening_to_clientlist=0;
color_mode=color_mode_candidate;
paint_base();
}elseif(client=="done"){
error("A [pattr preset_color] object has been found but seems to be invisible to the pattrstorage.\n")
<description>Function depends on inlet</description>
</method> -->
<methodname="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>
<methodname="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>
<methodname="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.
<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.