mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
- [Canvas] Hold Shift while applying node tool to replace surface instead of drawing on top.
This commit is contained in:
parent
4ec9ba31e1
commit
ac58c863b6
17 changed files with 471 additions and 76 deletions
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-21 14:51:29
|
||||
// 2024-04-24 16:37:33
|
||||
#event properties (no comments/etc. here are saved)
|
||||
parent_index = _p_dialog;
|
||||
uses_physics = false;
|
||||
|
@ -134,7 +134,9 @@ event_inherited();
|
|||
if(!_node) return;
|
||||
|
||||
if(is_instanceof(context, Node_Canvas)) {
|
||||
UNDO_HOLDING = true;
|
||||
context.nodeTool = new canvas_tool_node(context, _node).init();
|
||||
UNDO_HOLDING = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-21 14:49:20
|
||||
// 2024-04-24 16:34:00
|
||||
#event properties (no comments/etc. here are saved)
|
||||
parent_index = _p_dialog;
|
||||
uses_physics = false;
|
||||
|
@ -134,7 +134,8 @@ event_inherited();
|
|||
if(!_node) return;
|
||||
|
||||
if(is_instanceof(context, Node_Canvas)) {
|
||||
canvas_create_tool_node(context, _node);
|
||||
UNDO_HOLDING = true;
|
||||
context.nodeTool = new canvas_tool_node(context, _node).init();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-21 14:54:22
|
||||
// 2024-04-24 16:47:32
|
||||
function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||
|
||||
self.canvas = canvas;
|
||||
|
@ -13,14 +13,14 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
}
|
||||
|
||||
static cleanUp = function() {
|
||||
|
||||
UNDO_HOLDING = true;
|
||||
surface_free_safe(targetSurface);
|
||||
surface_free_safe(maskedSurface);
|
||||
|
||||
if(is_struct(nodeObject)) {
|
||||
if(is_instanceof(nodeObject, Node))
|
||||
nodeObject.destroy();
|
||||
|
||||
|
||||
else {
|
||||
var keys = struct_get_names(nodeObject);
|
||||
for (var i = 0, n = array_length(keys); i < n; i++)
|
||||
|
@ -29,6 +29,8 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
}
|
||||
}
|
||||
|
||||
node.nodeTool = noone;
|
||||
UNDO_HOLDING = false;
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
@ -87,31 +89,48 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
|
||||
function apply() {
|
||||
var _surf = surface_create(sw, sh);
|
||||
var _repl = key_mod_press(SHIFT);
|
||||
|
||||
if(applySelection) {
|
||||
var _fore = canvas.tool_selection.selection_surface;
|
||||
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
if(_repl) {
|
||||
surface_set_shader(_surf, noone);
|
||||
draw_surface_safe(maskedSurface);
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface(canvas.tool_selection.selection_surface, 0, 0);
|
||||
surface_reset_shader();
|
||||
} else {
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
|
||||
draw_surface_safe(_fore);
|
||||
surface_reset_shader();
|
||||
}
|
||||
|
||||
surface_free(canvas.tool_selection.selection_surface);
|
||||
surface_free(_fore);
|
||||
canvas.tool_selection.selection_surface = _surf;
|
||||
canvas.tool_selection.apply();
|
||||
|
||||
} else {
|
||||
var _fore = canvas.getCanvasSurface();
|
||||
canvas.storeAction();
|
||||
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
if(_repl) {
|
||||
surface_set_shader(_surf, noone);
|
||||
draw_surface_safe(maskedSurface);
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface(canvas.getCanvasSurface(), 0, 0);
|
||||
surface_reset_shader();
|
||||
} else {
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
|
||||
draw_surface_safe(_fore);
|
||||
surface_reset_shader();
|
||||
}
|
||||
|
||||
canvas.setCanvasSurface(_surf);
|
||||
canvas.surface_store_buffer();
|
||||
|
@ -159,16 +178,17 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
if(applySelection) {
|
||||
maskedSurface = surface_verify(maskedSurface, sw, sh);
|
||||
surface_set_shader(maskedSurface);
|
||||
draw_surface(_surf, 0, 0);
|
||||
draw_surface_safe(_surf);
|
||||
BLEND_MULTIPLY
|
||||
draw_surface(canvas.tool_selection.selection_mask, 0, 0);
|
||||
draw_surface_safe(canvas.tool_selection.selection_mask, 0, 0);
|
||||
BLEND_NORMAL
|
||||
surface_reset_shader();
|
||||
|
||||
} else
|
||||
maskedSurface = _surf;
|
||||
|
||||
draw_surface_ext_safe(destiSurface, _dx, _dy, _s, _s);
|
||||
|
||||
if(!key_mod_press(SHIFT))
|
||||
draw_surface_ext_safe(destiSurface, _dx, _dy, _s, _s);
|
||||
draw_surface_ext_safe(maskedSurface, _dx, _dy, _s, _s);
|
||||
|
||||
if(mouse_press(mb_left, active)) { apply(); MOUSE_BLOCK = true; }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-21 14:53:39
|
||||
// 2024-04-24 16:47:25
|
||||
function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||
|
||||
self.canvas = canvas;
|
||||
|
@ -13,14 +13,14 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
}
|
||||
|
||||
static cleanUp = function() {
|
||||
|
||||
UNDO_HOLDING = true;
|
||||
surface_free_safe(targetSurface);
|
||||
surface_free_safe(maskedSurface);
|
||||
|
||||
if(is_struct(nodeObject)) {
|
||||
if(is_instanceof(nodeObject, Node))
|
||||
nodeObject.destroy();
|
||||
|
||||
|
||||
else {
|
||||
var keys = struct_get_names(nodeObject);
|
||||
for (var i = 0, n = array_length(keys); i < n; i++)
|
||||
|
@ -29,6 +29,8 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
}
|
||||
}
|
||||
|
||||
node.nodeTool = noone;
|
||||
UNDO_HOLDING = false;
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
@ -87,31 +89,48 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
|
||||
function apply() {
|
||||
var _surf = surface_create(sw, sh);
|
||||
var _repl = key_mod_press(SHIFT);
|
||||
|
||||
if(applySelection) {
|
||||
var _fore = canvas.tool_selection.selection_surface;
|
||||
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
if(_repl) {
|
||||
surface_set_shader(_surf, noone);
|
||||
draw_surface_safe(maskedSurface);
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface(canvas.tool_selection.selection_surface, 0, 0);
|
||||
surface_reset_shader();
|
||||
} else {
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
|
||||
draw_surface_safe(_fore);
|
||||
surface_reset_shader();
|
||||
}
|
||||
|
||||
surface_free(canvas.tool_selection.selection_surface);
|
||||
surface_free(_fore);
|
||||
canvas.tool_selection.selection_surface = _surf;
|
||||
canvas.tool_selection.apply();
|
||||
|
||||
} else {
|
||||
var _fore = canvas.getCanvasSurface();
|
||||
canvas.storeAction();
|
||||
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
if(_repl) {
|
||||
surface_set_shader(_surf, noone);
|
||||
draw_surface_safe(maskedSurface);
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface(canvas.getCanvasSurface(), 0, 0);
|
||||
surface_reset_shader();
|
||||
} else {
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
|
||||
draw_surface_safe(_fore);
|
||||
surface_reset_shader();
|
||||
}
|
||||
|
||||
canvas.setCanvasSurface(_surf);
|
||||
canvas.surface_store_buffer();
|
||||
|
@ -159,16 +178,17 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
if(applySelection) {
|
||||
maskedSurface = surface_verify(maskedSurface, sw, sh);
|
||||
surface_set_shader(maskedSurface);
|
||||
draw_surface(_surf, 0, 0);
|
||||
draw_surface_safe(_surf);
|
||||
BLEND_MULTIPLY
|
||||
draw_surface(canvas.tool_selection.selection_mask, 0, 0);
|
||||
draw_surface_safe(canvas.tool_selection.selection_mask, 0, 0);
|
||||
BLEND_NORMAL
|
||||
surface_reset_shader();
|
||||
|
||||
} else
|
||||
maskedSurface = _surf;
|
||||
|
||||
draw_surface_ext_safe(destiSurface, _dx, _dy, _s, _s);
|
||||
|
||||
if(!key_mod_press(SHIFT))
|
||||
draw_surface_ext_safe(destiSurface, _dx, _dy, _s, _s);
|
||||
draw_surface_ext_safe(maskedSurface, _dx, _dy, _s, _s);
|
||||
|
||||
if(mouse_press(mb_left, active)) { apply(); MOUSE_BLOCK = true; }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-21 16:39:24
|
||||
// 2024-04-24 16:41:50
|
||||
function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Canvas";
|
||||
color = COLORS.node_blend_canvas;
|
||||
|
@ -825,7 +825,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
shader_set_f("dimension", _sw, _sh);
|
||||
draw_surface_ext_safe(preview_draw_mask, 0, 0, 1, 1, 0, c_white, 1);
|
||||
shader_reset();
|
||||
|
||||
|
||||
draw_set_color(COLORS._main_accent);
|
||||
if(tool_selection.is_selected) {
|
||||
var _spx = tool_selection.selection_position[0];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-21 16:39:12
|
||||
// 2024-04-24 16:40:36
|
||||
function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Canvas";
|
||||
color = COLORS.node_blend_canvas;
|
||||
|
@ -470,7 +470,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
static storeAction = function() { #region
|
||||
|
||||
var action = recordAction(ACTION_TYPE.custom, function(data) {
|
||||
|
||||
if(tool_selection.is_selected) tool_selection.apply();
|
||||
|
||||
var _canvas = surface_clone(getCanvasSurface(data.index));
|
||||
|
||||
|
@ -825,7 +825,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
shader_set_f("dimension", _sw, _sh);
|
||||
draw_surface_ext_safe(preview_draw_mask, 0, 0, 1, 1, 0, c_white, 1);
|
||||
shader_reset();
|
||||
|
||||
|
||||
draw_set_color(COLORS._main_accent);
|
||||
if(tool_selection.is_selected) {
|
||||
var _spx = tool_selection.selection_position[0];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-24 08:14:38
|
||||
// 2024-04-24 11:04:29
|
||||
function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Number";
|
||||
color = COLORS.node_blend_number;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-24 08:13:56
|
||||
// 2024-04-24 10:55:15
|
||||
function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Number";
|
||||
color = COLORS.node_blend_number;
|
||||
|
@ -97,7 +97,6 @@ function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
var _dat = getInputData(0);
|
||||
var _int = getInputData(1);
|
||||
|
||||
print(_dat);
|
||||
var _res = processNumber(_dat, _int);
|
||||
outputs[| 0].setValue(_res);
|
||||
} #endregion
|
||||
|
|
166
#backups/scripts/panel_history/panel_history.gml.backup0
Normal file
166
#backups/scripts/panel_history/panel_history.gml.backup0
Normal file
|
@ -0,0 +1,166 @@
|
|||
// 2024-04-24 16:31:30
|
||||
function Panel_History() : PanelContent() constructor {
|
||||
title = __txt("History");
|
||||
w = ui(400);
|
||||
h = ui(480);
|
||||
|
||||
anchor = ANCHOR.left | ANCHOR.top;
|
||||
hold = false;
|
||||
|
||||
w_min = 320;
|
||||
h_min = 320;
|
||||
hovering = -1;
|
||||
|
||||
redo_list = ds_list_create();
|
||||
undo_list = ds_list_create();
|
||||
click_hold = noone;
|
||||
|
||||
function refreshList() {
|
||||
ds_list_clear(redo_list);
|
||||
ds_list_clear(undo_list);
|
||||
|
||||
while(!ds_stack_empty(REDO_STACK))
|
||||
ds_list_insert(redo_list, 0, ds_stack_pop(REDO_STACK));
|
||||
|
||||
for( var i = 0; i < ds_list_size(redo_list); i++ )
|
||||
ds_stack_push(REDO_STACK, redo_list[| i]);
|
||||
|
||||
while(!ds_stack_empty(UNDO_STACK))
|
||||
ds_list_add(undo_list, ds_stack_pop(UNDO_STACK));
|
||||
|
||||
for( var i = ds_list_size(undo_list) - 1; i >= 0; i-- )
|
||||
ds_stack_push(UNDO_STACK, undo_list[| i]);
|
||||
|
||||
}
|
||||
refreshList();
|
||||
|
||||
onResize = function() {
|
||||
PANEL_PADDING
|
||||
|
||||
sc_history.resize(w - ui(padding + padding), h - ui(title_height + padding));
|
||||
}
|
||||
|
||||
sc_history = new scrollPane(w - ui(padding + padding), h - ui(title_height + padding), function(_y, _m) {
|
||||
draw_clear_alpha(COLORS._main_text, 0);
|
||||
|
||||
if((ds_list_size(redo_list) != ds_stack_size(REDO_STACK)) || (ds_list_size(undo_list) != ds_stack_size(UNDO_STACK)))
|
||||
refreshList();
|
||||
|
||||
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
|
||||
|
||||
var lh = line_get_height() + ui(8);
|
||||
var _h = 0, hh;
|
||||
var yy = _y + ui(8);
|
||||
|
||||
var lw = sc_history.surface_w - ui(32 + 2);
|
||||
var red = ds_list_size(redo_list);
|
||||
var amo = ds_list_size(redo_list) + ds_list_size(undo_list) + 1;
|
||||
var _hover = -1;
|
||||
var connect_line_st = 0;
|
||||
var connect_line_ed = 0;
|
||||
var action = -1;
|
||||
|
||||
for( var i = 0; i < amo; i++ ) {
|
||||
if(i == red) {
|
||||
draw_sprite_stretched_ext(THEME.ui_scrollbar, 0, 0, yy, sc_history.surface_w, ui(4), COLORS._main_accent, 1);
|
||||
connect_line_st = yy + ui(2);
|
||||
|
||||
_h += ui(4 + 8);
|
||||
yy += ui(4 + 8);
|
||||
continue;
|
||||
}
|
||||
|
||||
var item;
|
||||
if(i < red) item = redo_list[| i];
|
||||
else item = undo_list[| i - red - 1];
|
||||
|
||||
var itamo = array_length(item);
|
||||
var amoDisp = itamo;
|
||||
if(itamo > 3) {
|
||||
itamo = 3;
|
||||
amoDisp = 4;
|
||||
}
|
||||
hh = amoDisp * lh;
|
||||
|
||||
BLEND_OVERRIDE;
|
||||
if(pHOVER && sc_history.hover && point_in_rectangle(_m[0], _m[1], ui(32), yy - ui(4), lw, yy + hh + ui(4) - 1)) {
|
||||
draw_sprite_stretched_ext(THEME.node_bg, 0, ui(32), yy - ui(2), lw, hh + ui(4), COLORS._main_icon_light, 1);
|
||||
_hover = i;
|
||||
|
||||
if(array_length(item) > itamo) {
|
||||
TOOLTIP = "";
|
||||
for( var j = 0; j < array_length(item); j++ )
|
||||
TOOLTIP += (j? "\n" : "") + item[j].toString();
|
||||
}
|
||||
|
||||
if(mouse_click(mb_left) && click_hold != item) {
|
||||
click_hold = item;
|
||||
action = i;
|
||||
}
|
||||
} else
|
||||
draw_sprite_stretched_ext(THEME.node_bg, 0, ui(32), yy - ui(2), lw, hh + ui(4), COLORS._main_icon, 1);
|
||||
|
||||
var cc = COLORS._main_icon_dark;
|
||||
var _yc = yy;
|
||||
|
||||
if(i == hovering) cc = COLORS._main_accent;
|
||||
if(i < red) _yc = yy + ui(6);
|
||||
else _yc = yy + hh;
|
||||
|
||||
draw_sprite_ui(THEME.scroll_box_arrow, 0, ui(16), _yc, 1, 1 - (i > red) * 2, 0, cc, 1);
|
||||
BLEND_NORMAL;
|
||||
|
||||
if(i == hovering)
|
||||
connect_line_ed = _yc;
|
||||
|
||||
for( var j = 0; j < amoDisp; j++ ) {
|
||||
var _ty = yy + lh * (j + 0.5);
|
||||
if(j == 3) {
|
||||
draw_set_color(COLORS._main_text_sub);
|
||||
draw_text_add(ui(32 + 12), _ty, string(array_length(item) - 3) + __txtx("more_actions", " more actions..."));
|
||||
} else {
|
||||
draw_set_color(COLORS._main_text);
|
||||
draw_text_add(ui(32 + 12), _ty, item[j].toString());
|
||||
}
|
||||
}
|
||||
|
||||
_h += hh + ui(8);
|
||||
yy += hh + ui(8);
|
||||
}
|
||||
|
||||
if(hovering > -1) {
|
||||
draw_set_color(COLORS._main_accent);
|
||||
draw_line_width(ui(16), connect_line_st, ui(16), connect_line_ed, ui(3));
|
||||
}
|
||||
|
||||
if(mouse_release(mb_left))
|
||||
click_hold = noone;
|
||||
hovering = _hover;
|
||||
|
||||
if(action > -1) {
|
||||
if(action < red) {
|
||||
repeat(red - action)
|
||||
REDO();
|
||||
} else {
|
||||
repeat(action - red)
|
||||
UNDO();
|
||||
}
|
||||
hovering = -1;
|
||||
}
|
||||
|
||||
return _h + ui(64);
|
||||
})
|
||||
|
||||
function drawContent(panel) {
|
||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||
|
||||
var px = ui(padding);
|
||||
var py = ui(padding);
|
||||
var pw = w - ui(padding + padding);
|
||||
var ph = h - ui(padding + padding);
|
||||
|
||||
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
|
||||
sc_history.setFocusHover(pFOCUS, pHOVER);
|
||||
sc_history.draw(px, py, mx - px, my - py);
|
||||
}
|
||||
}
|
166
#backups/scripts/panel_history/panel_history.gml.backup1
Normal file
166
#backups/scripts/panel_history/panel_history.gml.backup1
Normal file
|
@ -0,0 +1,166 @@
|
|||
// 2024-04-24 16:31:27
|
||||
function Panel_History() : PanelContent() constructor {
|
||||
title = __txt("History");
|
||||
w = ui(400);
|
||||
h = ui(480);
|
||||
|
||||
anchor = ANCHOR.left | ANCHOR.top;
|
||||
hold = false;
|
||||
|
||||
w_min = 320;
|
||||
h_min = 320;
|
||||
hovering = -1;
|
||||
|
||||
redo_list = ds_list_create();
|
||||
undo_list = ds_list_create();
|
||||
click_hold = noone;
|
||||
|
||||
function refreshList() {
|
||||
ds_list_clear(redo_list);
|
||||
ds_list_clear(undo_list);
|
||||
|
||||
while(!ds_stack_empty(REDO_STACK))
|
||||
ds_list_insert(redo_list, 0, ds_stack_pop(REDO_STACK));
|
||||
|
||||
for( var i = 0; i < ds_list_size(redo_list); i++ )
|
||||
ds_stack_push(REDO_STACK, redo_list[| i]);
|
||||
|
||||
while(!ds_stack_empty(UNDO_STACK))
|
||||
ds_list_add(undo_list, ds_stack_pop(UNDO_STACK));
|
||||
|
||||
for( var i = ds_list_size(undo_list) - 1; i >= 0; i-- )
|
||||
ds_stack_push(UNDO_STACK, undo_list[| i]);
|
||||
|
||||
}
|
||||
refreshList();
|
||||
|
||||
onResize = function() {
|
||||
PANEL_PADDING
|
||||
|
||||
sc_history.resize(w - ui(padding + padding), h - ui(title_height + padding));
|
||||
}
|
||||
|
||||
sc_history = new scrollPane(w - ui(padding + padding), h - ui(title_height + padding), function(_y, _m) {
|
||||
draw_clear_alpha(COLORS._main_text, 0);
|
||||
|
||||
if((ds_list_size(redo_list) != ds_stack_size(REDO_STACK)) || (ds_list_size(undo_list) != ds_stack_size(UNDO_STACK)))
|
||||
refreshList();
|
||||
|
||||
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
|
||||
|
||||
var lh = line_get_height() + ui(8);
|
||||
var _h = 0, hh;
|
||||
var yy = _y + ui(8);
|
||||
|
||||
var lw = sc_history.surface_w - ui(32 + 2);
|
||||
var red = ds_list_size(redo_list);
|
||||
var amo = ds_list_size(redo_list) + ds_list_size(undo_list) + 1;
|
||||
var _hover = -1;
|
||||
var connect_line_st = 0;
|
||||
var connect_line_ed = 0;
|
||||
var action = -1;
|
||||
|
||||
for( var i = 0; i < amo; i++ ) {
|
||||
if(i == red) {
|
||||
draw_sprite_stretched_ext(THEME.ui_scrollbar, 0, 0, yy, sc_history.surface_w, ui(4), COLORS._main_accent, 1);
|
||||
connect_line_st = yy + ui(2);
|
||||
|
||||
_h += ui(4 + 8);
|
||||
yy += ui(4 + 8);
|
||||
continue;
|
||||
}
|
||||
|
||||
var item;
|
||||
if(i < red) item = redo_list[| i];
|
||||
else item = undo_list[| i - red - 1];
|
||||
|
||||
var itamo = array_length(item);
|
||||
var amoDisp = itamo;
|
||||
if(itamo > 3) {
|
||||
itamo = 3;
|
||||
amoDisp = 4;
|
||||
}
|
||||
hh = amoDisp * lh;
|
||||
|
||||
BLEND_OVERRIDE;
|
||||
if(pHOVER && sc_history.hover && point_in_rectangle(_m[0], _m[1], ui(32), yy - ui(4), lw, yy + hh + ui(4) - 1)) {
|
||||
draw_sprite_stretched_ext(THEME.node_bg, 0, ui(32), yy - ui(2), lw, hh + ui(4), COLORS._main_icon_light, 1);
|
||||
_hover = i;
|
||||
|
||||
if(array_length(item) > itamo) {
|
||||
TOOLTIP = "";
|
||||
for( var j = 0; j < array_length(item); j++ )
|
||||
TOOLTIP += (j? "\n" : "") + item[j].toString();
|
||||
}
|
||||
|
||||
if(mouse_click(mb_left) && click_hold != item) {
|
||||
click_hold = item;
|
||||
action = i;
|
||||
}
|
||||
} else
|
||||
draw_sprite_stretched_ext(THEME.node_bg, 0, ui(32), yy - ui(2), lw, hh + ui(4), COLORS._main_icon, 1);
|
||||
|
||||
var cc = COLORS._main_icon_dark;
|
||||
var _yc = yy;
|
||||
|
||||
if(i == hovering) cc = COLORS._main_accent;
|
||||
if(i < red) _yc = yy + ui(6);
|
||||
else _yc = yy + hh;
|
||||
|
||||
draw_sprite_ui(THEME.scroll_box_arrow, 0, ui(16), _yc, 1, 1 - (i > red) * 2, 0, cc, 1);
|
||||
BLEND_NORMAL;
|
||||
|
||||
if(i == hovering)
|
||||
connect_line_ed = _yc;
|
||||
|
||||
for( var j = 0; j < amoDisp; j++ ) {
|
||||
var _ty = yy + lh * (j + 0.5);
|
||||
if(j == 3) {
|
||||
draw_set_color(COLORS._main_text_sub);
|
||||
draw_text_add(ui(32 + 12), _ty, string(array_length(item) - 3) + __txtx("more_actions", " more actions..."));
|
||||
} else {
|
||||
draw_set_color(COLORS._main_text);
|
||||
draw_text_add(ui(32 + 12), _ty, item[j].toString());
|
||||
}
|
||||
}
|
||||
|
||||
_h += hh + ui(8);
|
||||
yy += hh + ui(8);
|
||||
}
|
||||
|
||||
if(hovering > -1) {
|
||||
draw_set_color(COLORS._main_accent);
|
||||
draw_line_width(ui(16), connect_line_st, ui(16), connect_line_ed, ui(3));
|
||||
}
|
||||
|
||||
if(mouse_release(mb_left))
|
||||
click_hold = noone;
|
||||
hovering = _hover;
|
||||
|
||||
if(action > -1) {
|
||||
if(action < red) {
|
||||
repeat(red - action)
|
||||
REDO();
|
||||
} else {
|
||||
repeat(action - red)
|
||||
UNDO();
|
||||
}
|
||||
hovering = -1;
|
||||
}
|
||||
|
||||
return _h + ui(64);
|
||||
})
|
||||
|
||||
function drawContent(panel) {
|
||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||
|
||||
var px = ui(padding);
|
||||
var py = ui(padding);
|
||||
var pw = w - ui(padding + padding);
|
||||
var ph = h - ui(padding + padding);
|
||||
|
||||
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
|
||||
sc_history.setFocusHover(pFOCUS, pHOVER);
|
||||
sc_history.draw(px, py, mx - px, my - py);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-24 10:09:11
|
||||
// 2024-04-24 10:13:46
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
|
@ -159,7 +159,7 @@ void main() { #region
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!isOutline) {
|
||||
gl_FragColor = col;
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-24 10:08:32
|
||||
// 2024-04-24 10:09:27
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
|
|
|
@ -129,7 +129,9 @@ event_inherited();
|
|||
if(!_node) return;
|
||||
|
||||
if(is_instanceof(context, Node_Canvas)) {
|
||||
UNDO_HOLDING = true;
|
||||
context.nodeTool = new canvas_tool_node(context, _node).init();
|
||||
UNDO_HOLDING = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,14 +12,14 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
}
|
||||
|
||||
static cleanUp = function() {
|
||||
|
||||
UNDO_HOLDING = true;
|
||||
surface_free_safe(targetSurface);
|
||||
surface_free_safe(maskedSurface);
|
||||
|
||||
if(is_struct(nodeObject)) {
|
||||
if(is_instanceof(nodeObject, Node))
|
||||
nodeObject.destroy();
|
||||
|
||||
|
||||
else {
|
||||
var keys = struct_get_names(nodeObject);
|
||||
for (var i = 0, n = array_length(keys); i < n; i++)
|
||||
|
@ -28,6 +28,8 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
}
|
||||
}
|
||||
|
||||
node.nodeTool = noone;
|
||||
UNDO_HOLDING = false;
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
@ -86,31 +88,48 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
|
||||
function apply() {
|
||||
var _surf = surface_create(sw, sh);
|
||||
var _repl = key_mod_press(SHIFT);
|
||||
|
||||
if(applySelection) {
|
||||
var _fore = canvas.tool_selection.selection_surface;
|
||||
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
if(_repl) {
|
||||
surface_set_shader(_surf, noone);
|
||||
draw_surface_safe(maskedSurface);
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface(canvas.tool_selection.selection_surface, 0, 0);
|
||||
surface_reset_shader();
|
||||
} else {
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
|
||||
draw_surface_safe(_fore);
|
||||
surface_reset_shader();
|
||||
}
|
||||
|
||||
surface_free(canvas.tool_selection.selection_surface);
|
||||
surface_free(_fore);
|
||||
canvas.tool_selection.selection_surface = _surf;
|
||||
canvas.tool_selection.apply();
|
||||
|
||||
} else {
|
||||
var _fore = canvas.getCanvasSurface();
|
||||
canvas.storeAction();
|
||||
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
if(_repl) {
|
||||
surface_set_shader(_surf, noone);
|
||||
draw_surface_safe(maskedSurface);
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface(canvas.getCanvasSurface(), 0, 0);
|
||||
surface_reset_shader();
|
||||
} else {
|
||||
surface_set_shader(_surf, sh_blend_normal);
|
||||
shader_set_surface("fore", maskedSurface);
|
||||
shader_set_f("dimension", 1, 1);
|
||||
shader_set_f("opacity", 1);
|
||||
|
||||
draw_surface_safe(_fore);
|
||||
surface_reset_shader();
|
||||
}
|
||||
|
||||
canvas.setCanvasSurface(_surf);
|
||||
canvas.surface_store_buffer();
|
||||
|
@ -158,16 +177,17 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
if(applySelection) {
|
||||
maskedSurface = surface_verify(maskedSurface, sw, sh);
|
||||
surface_set_shader(maskedSurface);
|
||||
draw_surface(_surf, 0, 0);
|
||||
draw_surface_safe(_surf);
|
||||
BLEND_MULTIPLY
|
||||
draw_surface(canvas.tool_selection.selection_mask, 0, 0);
|
||||
draw_surface_safe(canvas.tool_selection.selection_mask, 0, 0);
|
||||
BLEND_NORMAL
|
||||
surface_reset_shader();
|
||||
|
||||
} else
|
||||
maskedSurface = _surf;
|
||||
|
||||
draw_surface_ext_safe(destiSurface, _dx, _dy, _s, _s);
|
||||
|
||||
if(!key_mod_press(SHIFT))
|
||||
draw_surface_ext_safe(destiSurface, _dx, _dy, _s, _s);
|
||||
draw_surface_ext_safe(maskedSurface, _dx, _dy, _s, _s);
|
||||
|
||||
if(mouse_press(mb_left, active)) { apply(); MOUSE_BLOCK = true; }
|
||||
|
|
|
@ -824,7 +824,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
shader_set_f("dimension", _sw, _sh);
|
||||
draw_surface_ext_safe(preview_draw_mask, 0, 0, 1, 1, 0, c_white, 1);
|
||||
shader_reset();
|
||||
|
||||
|
||||
draw_set_color(COLORS._main_accent);
|
||||
if(tool_selection.is_selected) {
|
||||
var _spx = tool_selection.selection_position[0];
|
||||
|
|
|
@ -152,7 +152,6 @@ function Panel_History() : PanelContent() constructor {
|
|||
|
||||
function drawContent(panel) {
|
||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||
PANEL_PADDING
|
||||
|
||||
var px = ui(padding);
|
||||
var py = ui(padding);
|
||||
|
|
|
@ -158,7 +158,7 @@ void main() { #region
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!isOutline) {
|
||||
gl_FragColor = col;
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue