From 1b84b07e221cf6c791836150cfb0e889c00c6f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Clet?= Date: Wed, 11 Feb 2026 09:07:51 +0100 Subject: [PATCH] remove text_bg_color attr, set this color automatically based on text_color, remove ability to rename empty slots, bring textedit to front when renaming, minor ui changes --- extras/tc.preset Launch.maxpat | 6 ++-- help/max8.tc.preset.maxhelp | 24 +++++--------- help/max9.tc.preset.maxhelp | 36 +++++++-------------- javascript/tc.preset.js | 59 ++++++++++++++++------------------ 4 files changed, 50 insertions(+), 75 deletions(-) diff --git a/extras/tc.preset Launch.maxpat b/extras/tc.preset Launch.maxpat index fbfd8c1..ff5a7f7 100644 --- a/extras/tc.preset Launch.maxpat +++ b/extras/tc.preset Launch.maxpat @@ -61,9 +61,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 1, 1, 1, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], @@ -150,9 +149,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 1, 1, 1, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], diff --git a/help/max8.tc.preset.maxhelp b/help/max8.tc.preset.maxhelp index a70b6a6..a035afd 100644 --- a/help/max8.tc.preset.maxhelp +++ b/help/max8.tc.preset.maxhelp @@ -531,9 +531,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], @@ -1205,9 +1204,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], @@ -1663,9 +1661,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], @@ -1806,9 +1803,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], @@ -2364,9 +2360,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], @@ -2642,9 +2637,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], @@ -4294,9 +4288,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], @@ -4799,9 +4792,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], diff --git a/help/max9.tc.preset.maxhelp b/help/max9.tc.preset.maxhelp index 4d3e232..a91cbc3 100644 --- a/help/max9.tc.preset.maxhelp +++ b/help/max9.tc.preset.maxhelp @@ -156,7 +156,7 @@ [ "edited_color", 1, 0.49, 0.263, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1 ], [ "fontname", "Arial" ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 0 ], @@ -173,7 +173,6 @@ [ "slot_round", 0 ], [ "spacing", 4 ], [ "stored_slot_color", 0.458595350062755, 0.458595237564901, 0.458595266962388, 1 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "text_color", 0.85, 0.85, 0.85, 1 ], [ "ui_rename", 1 ], [ "unique_names", 0 ], @@ -287,7 +286,7 @@ [ "edited_color", 1, 0.49, 0.263, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1 ], [ "fontname", "Arial" ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 0 ], @@ -304,7 +303,6 @@ [ "slot_round", 0 ], [ "spacing", 4 ], [ "stored_slot_color", 0.458595350062755, 0.458595237564901, 0.458595266962388, 1 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "text_color", 0.85, 0.85, 0.85, 1 ], [ "ui_rename", 1 ], [ "unique_names", 0 ], @@ -392,9 +390,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], @@ -1080,7 +1077,7 @@ [ "edited_color", 1, 0.49, 0.263, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1 ], [ "fontname", "Arial" ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 0 ], @@ -1097,7 +1094,6 @@ [ "slot_round", 0 ], [ "spacing", 4 ], [ "stored_slot_color", 0.458595350062755, 0.458595237564901, 0.458595266962388, 1 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "text_color", 0.85, 0.85, 0.85, 1 ], [ "ui_rename", 0 ], [ "unique_names", 0 ], @@ -1749,7 +1745,7 @@ [ "edited_color", 1, 0.49, 0.263, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1 ], [ "fontname", "Arial" ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 0 ], @@ -1766,7 +1762,6 @@ [ "slot_round", 0 ], [ "spacing", 4 ], [ "stored_slot_color", 0.458595350062755, 0.458595237564901, 0.458595266962388, 1 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "text_color", 0.85, 0.85, 0.85, 1 ], [ "ui_rename", 1 ], [ "unique_names", 0 ], @@ -2172,9 +2167,8 @@ "border": 0, "embedstate": [ [ "bgcolor", 0.125, 0.125, 0.125, 1.0 ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "menu_mode", 0 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "autowriteagain", 0 ], [ "color_4", 0.367, 0.542, 0.712, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1.0 ], @@ -2393,7 +2387,7 @@ [ "edited_color", 1, 0.49, 0.263, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1 ], [ "fontname", "Arial" ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 1 ], @@ -2410,7 +2404,6 @@ [ "slot_round", 0 ], [ "spacing", 4 ], [ "stored_slot_color", 0.458595350062755, 0.458595237564901, 0.458595266962388, 1 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "text_color", 0.85, 0.85, 0.85, 1 ], [ "ui_rename", 1 ], [ "unique_names", 0 ], @@ -2530,7 +2523,7 @@ [ "edited_color", 1, 0.49, 0.263, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1 ], [ "fontname", "Arial" ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 0 ], @@ -2547,7 +2540,6 @@ [ "slot_round", 0 ], [ "spacing", 4 ], [ "stored_slot_color", 0.458595350062755, 0.458595237564901, 0.458595266962388, 1 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "text_color", 0.85, 0.85, 0.85, 1 ], [ "ui_rename", 0 ], [ "unique_names", 0 ], @@ -3088,7 +3080,7 @@ [ "edited_color", 1, 0.49, 0.263, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1 ], [ "fontname", "Arial" ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 0 ], @@ -3105,7 +3097,6 @@ [ "slot_round", 0 ], [ "spacing", 4 ], [ "stored_slot_color", 0.458595350062755, 0.458595237564901, 0.458595266962388, 1 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "text_color", 0.85, 0.85, 0.85, 1 ], [ "ui_rename", 1 ], [ "unique_names", 0 ], @@ -3348,7 +3339,7 @@ [ "edited_color", 1, 0.49, 0.263, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1 ], [ "fontname", "Arial" ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 1 ], @@ -3365,7 +3356,6 @@ [ "slot_round", 0 ], [ "spacing", 4 ], [ "stored_slot_color", 0.458595350062755, 0.458595237564901, 0.458595266962388, 1 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "text_color", 0.85, 0.85, 0.85, 1 ], [ "ui_rename", 1 ], [ "unique_names", 0 ], @@ -4976,7 +4966,7 @@ [ "edited_color", 1, 0.49, 0.263, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1 ], [ "fontname", "Arial" ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 0 ], @@ -4993,7 +4983,6 @@ [ "slot_round", 0 ], [ "spacing", 4 ], [ "stored_slot_color", 0.458595350062755, 0.458595237564901, 0.458595266962388, 1 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "text_color", 0.85, 0.85, 0.85, 1 ], [ "ui_rename", 0 ], [ "unique_names", 0 ], @@ -5458,7 +5447,7 @@ [ "edited_color", 1, 0.49, 0.263, 1 ], [ "empty_slot_color", 0.221327066888467, 0.221327006361825, 0.221327022178404, 1 ], [ "fontname", "Arial" ], - [ "fontsize", 14 ], + [ "fontsize", 13 ], [ "ignoreslotzero", 1 ], [ "interp_slot_color", 1, 1, 1, 0.8 ], [ "layout", 0 ], @@ -5475,7 +5464,6 @@ [ "slot_round", 0 ], [ "spacing", 4 ], [ "stored_slot_color", 0.458595350062755, 0.458595237564901, 0.458595266962388, 1 ], - [ "text_bg_color", 0.5, 0.5, 0.5, 0.5 ], [ "text_color", 0.85, 0.85, 0.85, 1 ], [ "ui_rename", 1 ], [ "unique_names", 0 ], diff --git a/javascript/tc.preset.js b/javascript/tc.preset.js index 494c7c0..4ee2eb3 100644 --- a/javascript/tc.preset.js +++ b/javascript/tc.preset.js @@ -46,7 +46,7 @@ var slot_round_ratio = 0; var margin = 4; var spacing = 4; -var font_size = 14; +var font_size = 13; var font_name = "Arial"; var background_color = max.getcolor("theme_bgcolor"); //[0.2, 0.2, 0.2, 1]; @@ -55,8 +55,8 @@ var active_slot_color = max.getcolor("theme_color"); //[0.808, 0.898, 0.910, 1]; var stored_slot_color = max.getcolor("theme_accentcolor"); //[0.502, 0.502, 0.502, 1]; var interp_slot_color = [1.0, 1.0, 1.0, 0.8]; var border_color = [1.0, 1.0, 1.0, 0.85]; -var text_bg_color = [0.5,0.5,0.5, 0.5]; var text_color = max.getcolor("theme_textcolor"); //[0.129, 0.129, 0.129, 1]; +var text_bg_color = set_text_bg_color(); var edited_color = [1, 0.49, 0.263, 1]; var color_1 = [0.743, 0.41, 0.501, 1]; // Color set for the filled slots. I don't like how this is declared. More info in color_wheel() declaration @@ -553,19 +553,21 @@ function paint() // Slot border if (slots[last_hovered].filled == false || (slots[last_hovered].filled == true && !control_hold)) { - mgraphics.set_source_rgba(border_color[0], border_color[1], border_color[2], 0.8 * border_color[3]); + 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); mgraphics.stroke(); } if (last_hovered_is_preset_slot) { + 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) { // About to lock/unlock var bracket_size = slot_size * 0.2; - mgraphics.set_source_rgba(border_color); - mgraphics.set_line_width(2); + mgraphics.set_source_rgba(text_color); + mgraphics.set_line_width(stroke_width); mgraphics.move_to(slots[last_hovered].left + bracket_size, slots[last_hovered].top); mgraphics.rel_line_to(-bracket_size, 0); mgraphics.rel_line_to(0, slot_size); @@ -577,7 +579,7 @@ function paint() mgraphics.stroke(); } else if (option_hold && !control_hold && slots[last_hovered].filled == true) { // About to delete - mgraphics.set_source_rgba(empty_slot_color[0], empty_slot_color[1], empty_slot_color[2], 0.6); + 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); mgraphics.fill(); } else if (!control_hold && !option_hold){ @@ -586,10 +588,10 @@ 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) { + } else if (control_hold && slots[last_hovered].filled == true) { // About to rename - mgraphics.set_source_rgba(border_color); - mgraphics.set_line_width(2); + mgraphics.set_source_rgba(text_color); + mgraphics.set_line_width(stroke_width); mgraphics.move_to(slots[last_hovered].left - 1, slots[last_hovered].top); mgraphics.rel_line_to(slot_size + 2, 0); mgraphics.move_to(slots[last_hovered].left - 1, slots[last_hovered].bottom); @@ -890,6 +892,7 @@ function anything() { slots[v].filled = 0; if (active_slot == v) { active_slot = 0; + selected_slot = 0; } if (previous_active_slot == v) { previous_active_slot = 0; @@ -898,8 +901,8 @@ function anything() { if (is_dragging == 0 && is_moving == 0) { to_pattrstorage("delete", v); to_pattrstorage("getslotlist"); - paint_base(); set_active_slot(active_slot); + paint_base(); if (!is_dragging) { outlet(0, "delete", v); if (selected_slot == v) { @@ -1608,6 +1611,7 @@ function set_textedit(s) { } textedit_obj.setattr('presentation', this.patcher.getattr("presentation")); textedit_obj.setattr('hidden', 0); + this.patcher.bringtofront(textedit_obj); } textedit_obj.message("select"); is_typing_name = s; @@ -1718,13 +1722,13 @@ function onclick(x,y,but,cmd,shift,capslock,option,ctrl) } if (shift) { output = "store"; - if (option) { + if (option && slots[last_hovered].filled) { output = "delete"; } - if (ctrl) { + if (ctrl && slots[last_hovered].filled) { output = "lock"; } - } else if (ctrl) { + } else if (ctrl && slots[last_hovered].filled) { output = "rename"; } else if (slots[last_hovered].filled == false) { return; @@ -2054,24 +2058,6 @@ function setinterpslotcolor(){ } setinterpslotcolor.local = 1; -declareattribute("text_bg_color", "gettextbgcolor", "settextbgcolor", 1, {style: "rgba", label: "Text Background Color", category: "Appearance"}); -function gettextbgcolor() { - return text_bg_color; -} -gettextbgcolor.local = 1; - -function settextbgcolor(){ - if (arguments.length == 4) { - text_bg_color = [arguments[0], arguments[1], arguments[2], arguments[3]]; - } else if (arguments.length == 0) { - text_bg_color = [1,1,1, 0.5]; - } else { - error('text_bg_color: wrong number of arguments\n'); - } - mgraphics.redraw(); -} -settextbgcolor.local = 1; - declareattribute("text_color", "gettextcolor", "settextcolor", 1, {style: "rgba", label: "Text Color", category: "Appearance"}); function gettextcolor() { return text_color; @@ -2085,10 +2071,21 @@ function settextcolor(){ } else { error('text_color: wrong number of arguments\n'); } + set_text_bg_color(); mgraphics.redraw(); } settextcolor.local = 1; +function set_text_bg_color() { + text_bg_color = is_dark_color(text_color) ? [1, 1, 1, 0.5] : [0, 0, 0, 0.5]; +} +set_text_bg_color.local = 1; + +function is_dark_color(color) { + return (0.299 * color[0] + 0.587 * color[1] + 0.114 * color[2]) < 0.5; +} +is_dark_color.local = 1; + declareattribute("fontsize", "getfontsize", "setfontsize", 1, {type: "float", label: "Font Size", category: "Appearance"}); function getfontsize() { return font_size;