- [Palette Editor] Add preset search bar. - [Gradient Editor] Add preset, palette search bar.

This commit is contained in:
Tanasart 2025-03-02 14:53:29 +07:00
parent e26ec42524
commit 3aed925ed7
8 changed files with 205 additions and 57 deletions

View file

@ -231,13 +231,12 @@
"Node_Group_Input",
"Node_Group_Output",
"Node_PB_Output",
{ "label": "Main" },
"Node_PB_Dimension",
{ "label": "/PBBOX" },
{ "label": "PBBOX" },
"Node_PB_Box",
"Node_PB_Box_BBOX",
"Node_PB_Box_Mirror",
"Node_PB_Box_BBOX",
{ "label": "Draw" },
"Node_PB_Draw_Rectangle",

View file

@ -94,7 +94,7 @@ event_inherited();
registerFunction("Add Node", "Trigger Favourite", "", MOD_KEY.none, trigger_favourite);
function rightClick(node) {
if(!is_instanceof(node, NodeObject)) return;
if(!is(node, NodeObject)) return;
node_menu_selecting = node;
var fav = struct_exists(global.FAV_NODES, node.nodeName);
@ -221,7 +221,7 @@ event_inherited();
var _inputs = [];
var _outputs = [];
if(is_instanceof(_node, NodeObject)) {
if(is(_node, NodeObject)) {
_new_node = _node.build(node_target_x, node_target_y,, _param);
if(!_new_node) return;
@ -232,7 +232,7 @@ event_inherited();
array_pop(global.RECENT_NODES);
}
if(is_instanceof(context, Node_Collection_Inline))
if(is(context, Node_Collection_Inline))
context.addNode(_new_node);
for( var i = 0, n = array_length(_new_node.inputs); i < n; i++ )
@ -252,7 +252,7 @@ event_inherited();
if(struct_has(HOTKEYS, _ins)) FOCUS_STR = _ins;
}
} else if(is_instanceof(_node, NodeAction)) { // NOT IMPLEMENTED
} else if(is(_node, NodeAction)) { // NOT IMPLEMENTED
var _dat = _node.build(node_target_x, node_target_y,, _param);
var _node_in = _dat.inputNode;
var _node_out = _dat.outputNode;
@ -275,7 +275,7 @@ event_inherited();
tx = min(tx, _new_list[i].x);
ty = min(tx, _new_list[i].y);
if(is_instanceof(context, Node_Collection_Inline) && !is_instanceof(_new_list[i], Node_Collection_Inline))
if(is(context, Node_Collection_Inline) && !is(_new_list[i], Node_Collection_Inline))
context.addNode(_new_list[i]);
}
@ -527,7 +527,7 @@ event_inherited();
for(var index = 0; index < node_count; index++) {
var _node = _list[index];
if(is_undefined(_node)) continue;
if(is_instanceof(_node, NodeObject)) {
if(is(_node, NodeObject)) {
if(_node.patreon && !IS_PATREON) continue;
if(is_global && !_node.show_in_global) continue;
}
@ -566,9 +566,9 @@ event_inherited();
var _boxx = _nx + (grid_width - grid_size) / 2;
var cc = c_white;
if(is_instanceof(_node, NodeObject)) cc = c_white;
else if(is_instanceof(_node, NodeAction)) cc = COLORS.add_node_blend_action;
else if(is_instanceof(_node, AddNodeItem)) cc = COLORS.add_node_blend_generic;
if(is(_node, NodeObject)) cc = c_white;
else if(is(_node, NodeAction)) cc = COLORS.add_node_blend_action;
else if(is(_node, AddNodeItem)) cc = COLORS.add_node_blend_generic;
else cc = COLORS.dialog_add_node_collection;
if(!struct_try_get(_node, "hide_bg", false)) {
@ -588,7 +588,7 @@ event_inherited();
}
}
if(is_instanceof(_node, NodeObject)) {
if(is(_node, NodeObject)) {
_node.drawGrid(_boxx, yy, _m[0], _m[1], grid_size);
} else {
var spr_x = _boxx + grid_size / 2;
@ -598,7 +598,7 @@ event_inherited();
if(sprite_exists(_node.spr))
draw_sprite_ui_uniform(_node.spr, 0, spr_x, spr_y, 0.5);
if(is_instanceof(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
if(is(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
draw_sprite_ui_uniform(THEME.play_action, 0, _boxx + grid_size - 16, yy + grid_size - 16, 1, COLORS.add_node_blend_action);
}
@ -711,7 +711,7 @@ event_inherited();
for(var i = 0; i < node_count; i++) {
var _node = _list[i];
if(is_undefined(_node)) continue;
if(is_instanceof(_node, NodeObject)) {
if(is(_node, NodeObject)) {
if(_node.patreon && !IS_PATREON) continue;
if(is_global && !_node.show_in_global) continue;
}
@ -755,14 +755,14 @@ event_inherited();
draw_sprite_stretched_ext(THEME.node_bg, 1, pd, yy, list_width - pd * 2, list_height, COLORS._main_accent, 1);
if(sFOCUS) {
if(mouse_press(mb_left, left_free)) buildNode(_node);
if(mouse_press(mb_right, right_free)) rightClick(_node);
if(mouse_release(mb_left, left_free)) buildNode(_node);
if(mouse_release(mb_right, right_free)) rightClick(_node);
}
}
var tx;
if(is_instanceof(_node, NodeObject)) {
if(is(_node, NodeObject)) {
tx = _node.drawList(pd, yy, _m[0], _m[1], list_height, list_width - pd);
} else {
@ -775,7 +775,7 @@ event_inherited();
draw_sprite_ext(_node.spr, 0, spr_x, spr_y, ss, ss, 0, c_white, 1);
}
if(is_instanceof(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
if(is(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
draw_sprite_ui_uniform(THEME.play_action, 0, spr_x + list_height / 2 - 8, spr_y + list_height / 2 - 8, 0.5, COLORS.add_node_blend_action);
tx = pd + list_height + ui(32 + 4);
@ -944,7 +944,7 @@ event_inherited();
var match = string_partial_match_res(string_lower(_node.getName()), search_lower, search_split);
if(is_instanceof(_node, NodeObject)) {
if(is(_node, NodeObject)) {
if(_node.deprecated) continue;
if(match[0] > -9000 && struct_exists(global.FAV_NODES, _node.nodeName))
match[0] += 10000;
@ -1045,9 +1045,9 @@ event_inherited();
if(_drw) {
if(is_instanceof(_node, NodeObject)) cc = c_white;
else if(is_instanceof(_node, NodeAction)) cc = COLORS.add_node_blend_action;
else if(is_instanceof(_node, AddNodeItem)) cc = COLORS.add_node_blend_generic;
if(is(_node, NodeObject)) cc = c_white;
else if(is(_node, NodeAction)) cc = COLORS.add_node_blend_action;
else if(is(_node, AddNodeItem)) cc = COLORS.add_node_blend_generic;
else cc = COLORS.dialog_add_node_collection;
if(!struct_try_get(_node, "hide_bg", false)) {
@ -1073,7 +1073,7 @@ event_inherited();
buildNode(_node, _param);
}
if(is_instanceof(_node, NodeObject)) {
if(is(_node, NodeObject)) {
_node.drawGrid(_boxx, yy, _m[0], _m[1], grid_size, _param);
} else {
if(variable_struct_exists(_node, "getSpr")) _node.getSpr();
@ -1094,7 +1094,7 @@ event_inherited();
draw_sprite_ext(_node.spr, _si, _sx, _sy, _ss, _ss, 0, c_white, 1);
}
if(is_instanceof(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
if(is(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
draw_sprite_ui_uniform(THEME.play_action, 0, _boxx + grid_size - 16, yy + grid_size - 16, 1, COLORS.add_node_blend_action);
}
@ -1220,7 +1220,7 @@ event_inherited();
var tx;
if(is_instanceof(_node, NodeObject)) {
if(is(_node, NodeObject)) {
var tx = _node.drawList(pd, yy, _m[0], _m[1], list_height, list_width - pd, _param);
} else {
@ -1241,7 +1241,7 @@ event_inherited();
draw_sprite_ext(_node.spr, _si, _sx, _sy, _ss, _ss, 0, c_white, 1);
if(is_instanceof(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
if(is(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
draw_sprite_ui_uniform(THEME.play_action, 0, _sx + list_height / 2 - 8, _sy + list_height / 2 - 8, 0.5, COLORS.add_node_blend_action);
}

View file

@ -82,6 +82,12 @@ event_inherited();
#endregion
#region preset
function initGradient() {
gradientPresets = array_clone(GRADIENTS);
currentGradient = gradientPresets;
return self;
} initGradient();
hovering_name = "";
pal_padding = ui(9);
@ -101,8 +107,8 @@ event_inherited();
var _hover = sHOVER && sp_presets.hover;
for(var i = 0; i < array_length(GRADIENTS); i++) {
var _gradient = GRADIENTS[i];
for(var i = 0; i < array_length(gradientPresets); i++) {
var _gradient = gradientPresets[i];
var isHover = point_in_rectangle(_m[0], _m[1], 0, yy, ww, yy + hg);
draw_sprite_stretched(THEME.ui_panel_bg, 3, 0, yy, ww, hg);
@ -143,10 +149,49 @@ event_inherited();
return hh;
});
//////////////////////// SEARCH ////////////////////////
gradient_search_string = "";
tb_preset_search = new textBox(TEXTBOX_INPUT.text, function(t) /*=>*/ {return searchGradient(t)} )
.setFont(f_p2)
.setHide(1)
.setEmpty(false)
.setPadding(ui(24))
.setAutoUpdate();
function searchGradient(t) {
gradient_search_string = t;
if(gradient_search_string == "") {
gradientPresets = currentGradient;
return;
}
gradientPresets = [];
var _pr = ds_priority_create();
for( var i = 0, n = array_length(currentGradient); i < n; i++ ) {
var _prest = currentGradient[i];
var _match = string_partial_match(_prest.name, gradient_search_string);
if(_match <= -9999) continue;
ds_priority_add(_pr, _prest, _match);
}
repeat(ds_priority_size(_pr))
array_push(gradientPresets, ds_priority_delete_max(_pr));
ds_priority_destroy(_pr);
}
#endregion
#region palette
function initPalette() { paletePresets = array_clone(PALETTES); return self; } initPalette();
function initPalette() {
paletePresets = array_clone(PALETTES);
currentPresets = paletePresets;
return self;
} initPalette();
palette_selecting = -1;
preset_show_name = true;
@ -242,7 +287,42 @@ event_inherited();
return hh;
});
//////////////////////// SORT
//////////////////////// SEARCH ////////////////////////
palette_search_string = "";
tb_palette_search = new textBox(TEXTBOX_INPUT.text, function(t) /*=>*/ {return searchPalette(t)} )
.setFont(f_p2)
.setHide(1)
.setEmpty(false)
.setPadding(ui(24))
.setAutoUpdate();
function searchPalette(t) {
palette_search_string = t;
if(palette_search_string == "") {
paletePresets = currentPresets;
return;
}
paletePresets = [];
var _pr = ds_priority_create();
for( var i = 0, n = array_length(currentPresets); i < n; i++ ) {
var _prest = currentPresets[i];
var _match = string_partial_match(_prest.name, palette_search_string);
if(_match <= -9999) continue;
ds_priority_add(_pr, _prest, _match);
}
repeat(ds_priority_size(_pr))
array_push(paletePresets, ds_priority_delete_max(_pr));
ds_priority_destroy(_pr);
}
//////////////////////// SORT ////////////////////////
sortPreset_name_a = function() /*=>*/ { array_sort(paletePresets, function(p0, p1) /*=>*/ {return string_compare(p0.name, p1.name)}); }
sortPreset_name_d = function() /*=>*/ { array_sort(paletePresets, function(p0, p1) /*=>*/ {return string_compare(p1.name, p0.name)}); }

View file

@ -43,8 +43,18 @@ draggable = true;
#region presets
draw_sprite_stretched(THEME.ui_panel_bg, 1, presets_x + pal_padding, dialog_y + ui(48), ui(240) - pal_padding * 2, dialog_h - ui(48) - pal_padding);
var _px = presets_x + pal_padding + ui(4);
var _py = dialog_y + ui(48 + 4);
var _pw = sp_palette_w;
draw_sprite_stretched_ext(THEME.textbox, 1, _px, _py, _pw, ui(24), COLORS._main_icon);
tb_preset_search.setFocusHover(sFOCUS, sHOVER);
tb_preset_search.draw(_px, _py, _pw, ui(24), gradient_search_string);
draw_sprite_ui(THEME.search, 0, _px + ui(12), _py + ui(12), .75, .75, 0, COLORS._main_icon, .5);
sp_presets.setFocusHover(sFOCUS, sHOVER);
sp_presets.draw(presets_x + pal_padding + ui(4), dialog_y + ui(48) + ui(4));
sp_presets.verify(_pw, dialog_h - ui(72 + 24));
sp_presets.draw(_px, _py + ui(24 + 8));
var bx = presets_x + presets_w - ui(44);
var by = dialog_y + ui(12);
@ -63,6 +73,7 @@ draggable = true;
file_text_write_all(txt + ".txt", gradStr);
__initGradient();
initGradient();
};
dia.path = DIRECTORY + "Gradients/"
}
@ -70,7 +81,7 @@ draggable = true;
bx -= ui(32);
var b = buttonInstant(THEME.button_hide_fill, bx, by, bs, bs, mouse_ui, sHOVER, sFOCUS, __txt("Refresh"), THEME.refresh_20);
if(b == 2) __initGradient();
if(b == 2) { __initGradient(); initGradient(); }
draggable &= !b;
bx -= ui(32);
@ -87,8 +98,18 @@ draggable = true;
#region palette
draw_sprite_stretched(THEME.ui_panel_bg, 1, palette_x + pal_padding, dialog_y + ui(48), ui(240) - pal_padding * 2, dialog_h - ui(48) - pal_padding);
var _px = palette_x + pal_padding + ui(4);
var _py = dialog_y + ui(48 + 4);
var _pw = sp_palette_w;
draw_sprite_stretched_ext(THEME.textbox, 1, _px, _py, _pw, ui(24), COLORS._main_icon);
tb_palette_search.setFocusHover(sFOCUS, sHOVER);
tb_palette_search.draw(_px, _py, _pw, ui(24), palette_search_string);
draw_sprite_ui(THEME.search, 0, _px + ui(12), _py + ui(12), .75, .75, 0, COLORS._main_icon, .5);
sp_palettes.setFocusHover(sFOCUS, sHOVER);
sp_palettes.draw(palette_x + pal_padding + ui(4), dialog_y + ui(48) + ui(4));
sp_palettes.verify(_pw, dialog_h - ui(72 + 24));
sp_palettes.draw(_px, _py + ui(24 + 8));
var bx = palette_x + palette_w - ui(44);
var by = dialog_y + ui(12);

View file

@ -22,7 +22,6 @@ function __PaletteColor(_color = c_black) constructor {
index_dragging = noone;
interactable = true;
drop_target = noone; setDrop = function(d) /*=>*/ { drop_target = d; return self; }
mouse_interact = false;
mixer = noone;
@ -92,14 +91,18 @@ function __PaletteColor(_color = c_black) constructor {
#endregion
#region presets
function initPalette() { paletePresets = array_clone(PALETTES); return self; } initPalette();
function initPalette() {
paletePresets = array_clone(PALETTES);
currentPresets = paletePresets;
return self;
} initPalette();
hovering_name = "";
preset_show_name = true;
pal_padding = ui(9);
sp_preset_w = ui(240) - pal_padding * 2 - ui(8);
sp_presets = new scrollPane(sp_preset_w, dialog_h - ui(48 + 8) - pal_padding, function(_y, _m) {
sp_presets = new scrollPane(sp_preset_w, dialog_h - ui(48 + 8 + 40) - pal_padding, function(_y, _m) {
draw_clear_alpha(COLORS.panel_bg_clear, 0);
var _hov = sp_presets.hover && sHOVER;
@ -154,7 +157,42 @@ function __PaletteColor(_color = c_black) constructor {
return hh;
});
//////////////////////// SORT
//////////////////////// SEARCH ////////////////////////
search_string = "";
tb_search = new textBox(TEXTBOX_INPUT.text, function(t) /*=>*/ {return searchPalette(t)} )
.setFont(f_p2)
.setHide(1)
.setEmpty(false)
.setPadding(ui(24))
.setAutoUpdate();
function searchPalette(t) {
search_string = t;
if(search_string == "") {
paletePresets = currentPresets;
return;
}
paletePresets = [];
var _pr = ds_priority_create();
for( var i = 0, n = array_length(currentPresets); i < n; i++ ) {
var _prest = currentPresets[i];
var _match = string_partial_match(_prest.name, search_string);
if(_match <= -9999) continue;
ds_priority_add(_pr, _prest, _match);
}
repeat(ds_priority_size(_pr))
array_push(paletePresets, ds_priority_delete_max(_pr));
ds_priority_destroy(_pr);
}
//////////////////////// SORT ////////////////////////
sortPreset_name_a = function() /*=>*/ { array_sort(paletePresets, function(p0, p1) /*=>*/ {return string_compare(p0.name, p1.name)}); }
sortPreset_name_d = function() /*=>*/ { array_sort(paletePresets, function(p0, p1) /*=>*/ {return string_compare(p1.name, p0.name)}); }
@ -241,7 +279,6 @@ function __PaletteColor(_color = c_black) constructor {
if(onApply != noone) onApply(palette);
}
function onResize() { sp_presets.resize(sp_preset_w, dialog_h - ui(62)); }
function checkMouse() {}
menu_palette_sort = [

View file

@ -34,8 +34,18 @@ draggable = true;
#region presets
draw_sprite_stretched(THEME.ui_panel_bg, 1, presets_x + pal_padding, dialog_y + ui(48), ui(240) - pal_padding * 2, dialog_h - ui(48) - pal_padding);
var _px = presets_x + pal_padding + ui(4);
var _py = dialog_y + ui(48 + 4);
var _pw = sp_preset_w;
draw_sprite_stretched_ext(THEME.textbox, 1, _px, _py, _pw, ui(24), COLORS._main_icon);
tb_search.setFocusHover(sFOCUS, sHOVER);
tb_search.draw(_px, _py, _pw, ui(24), search_string);
draw_sprite_ui(THEME.search, 0, _px + ui(12), _py + ui(12), .75, .75, 0, COLORS._main_icon, .5);
sp_presets.setFocusHover(sFOCUS, sHOVER);
sp_presets.draw(presets_x + pal_padding + ui(4), dialog_y + ui(48) + ui(4));
sp_presets.verify(_pw, dialog_h - ui(72 + 24));
sp_presets.draw(_px, _py + ui(24 + 8));
var bx = presets_x + presets_w - ui(44);
var by = dialog_y + ui(12);

View file

@ -164,7 +164,7 @@ function Node_PB_Draw(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
shader_set_i("stroke", _stk );
shader_set_f("stroke_thickness", _stk_thk );
shader_set_c("stroke_color", _stk_col );
shader_set_i("stroke_position", _stk_pos );
shader_set_i("stroke_position", _stk_thk <= 1? 1 : _stk_pos );
shader_set_i("stroke_corner", _stk_cor );
shader_set_i("stroke_pattern", _stk_pat );
shader_set_2("stroke_pattern_scale", _stk_pat_sca );

View file

@ -190,19 +190,20 @@ function Panel_Inspector() : PanelContent() constructor {
drawWidgetInit();
#region ---- header labels ----
tb_node_name = new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { if(inspecting) inspecting.setDisplayName(txt); });
tb_node_name.format = TEXT_AREA_FORMAT.node_title;
tb_node_name.font = f_h5;
tb_node_name.align = fa_center;
tb_node_name.hide = true;
tb_node_name = new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { if(inspecting) inspecting.setDisplayName(txt); })
.setFont(f_h5)
.setHide(1)
.setAlign(fa_center);
tb_prop_filter = new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { filter_text = txt; });
tb_prop_filter.no_empty = false;
tb_prop_filter.auto_update = true;
tb_prop_filter.font = f_p0;
tb_prop_filter.color = COLORS._main_text_sub;
tb_prop_filter.align = fa_center;
tb_prop_filter.hide = true;
tb_node_name.format = TEXT_AREA_FORMAT.node_title;
tb_prop_filter = new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { filter_text = txt; })
.setFont(f_p0)
.setHide(1)
.setAlign(fa_center)
.setColor(COLORS._main_text_sub)
.setEmpty(false)
.setAutoUpdate()
filter_text = "";
prop_page = 0;