mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-26 04:48:17 +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)
|
#event properties (no comments/etc. here are saved)
|
||||||
parent_index = _p_dialog;
|
parent_index = _p_dialog;
|
||||||
uses_physics = false;
|
uses_physics = false;
|
||||||
|
@ -134,7 +134,9 @@ event_inherited();
|
||||||
if(!_node) return;
|
if(!_node) return;
|
||||||
|
|
||||||
if(is_instanceof(context, Node_Canvas)) {
|
if(is_instanceof(context, Node_Canvas)) {
|
||||||
|
UNDO_HOLDING = true;
|
||||||
context.nodeTool = new canvas_tool_node(context, _node).init();
|
context.nodeTool = new canvas_tool_node(context, _node).init();
|
||||||
|
UNDO_HOLDING = false;
|
||||||
return;
|
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)
|
#event properties (no comments/etc. here are saved)
|
||||||
parent_index = _p_dialog;
|
parent_index = _p_dialog;
|
||||||
uses_physics = false;
|
uses_physics = false;
|
||||||
|
@ -134,7 +134,8 @@ event_inherited();
|
||||||
if(!_node) return;
|
if(!_node) return;
|
||||||
|
|
||||||
if(is_instanceof(context, Node_Canvas)) {
|
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;
|
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 {
|
function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
|
|
||||||
self.canvas = canvas;
|
self.canvas = canvas;
|
||||||
|
@ -13,7 +13,7 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
static cleanUp = function() {
|
static cleanUp = function() {
|
||||||
|
UNDO_HOLDING = true;
|
||||||
surface_free_safe(targetSurface);
|
surface_free_safe(targetSurface);
|
||||||
surface_free_safe(maskedSurface);
|
surface_free_safe(maskedSurface);
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node.nodeTool = noone;
|
||||||
|
UNDO_HOLDING = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
@ -87,31 +89,48 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
|
|
||||||
function apply() {
|
function apply() {
|
||||||
var _surf = surface_create(sw, sh);
|
var _surf = surface_create(sw, sh);
|
||||||
|
var _repl = key_mod_press(SHIFT);
|
||||||
|
|
||||||
if(applySelection) {
|
if(applySelection) {
|
||||||
|
var _fore = canvas.tool_selection.selection_surface;
|
||||||
|
|
||||||
surface_set_shader(_surf, sh_blend_normal);
|
if(_repl) {
|
||||||
shader_set_surface("fore", maskedSurface);
|
surface_set_shader(_surf, noone);
|
||||||
shader_set_f("dimension", 1, 1);
|
draw_surface_safe(maskedSurface);
|
||||||
shader_set_f("opacity", 1);
|
surface_reset_shader();
|
||||||
|
|
||||||
draw_surface(canvas.tool_selection.selection_surface, 0, 0);
|
} else {
|
||||||
surface_reset_shader();
|
surface_set_shader(_surf, sh_blend_normal);
|
||||||
|
shader_set_surface("fore", maskedSurface);
|
||||||
|
shader_set_f("dimension", 1, 1);
|
||||||
|
shader_set_f("opacity", 1);
|
||||||
|
|
||||||
surface_free(canvas.tool_selection.selection_surface);
|
draw_surface_safe(_fore);
|
||||||
|
surface_reset_shader();
|
||||||
|
}
|
||||||
|
|
||||||
|
surface_free(_fore);
|
||||||
canvas.tool_selection.selection_surface = _surf;
|
canvas.tool_selection.selection_surface = _surf;
|
||||||
canvas.tool_selection.apply();
|
canvas.tool_selection.apply();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
var _fore = canvas.getCanvasSurface();
|
||||||
canvas.storeAction();
|
canvas.storeAction();
|
||||||
|
|
||||||
surface_set_shader(_surf, sh_blend_normal);
|
if(_repl) {
|
||||||
shader_set_surface("fore", maskedSurface);
|
surface_set_shader(_surf, noone);
|
||||||
shader_set_f("dimension", 1, 1);
|
draw_surface_safe(maskedSurface);
|
||||||
shader_set_f("opacity", 1);
|
surface_reset_shader();
|
||||||
|
|
||||||
draw_surface(canvas.getCanvasSurface(), 0, 0);
|
} else {
|
||||||
surface_reset_shader();
|
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.setCanvasSurface(_surf);
|
||||||
canvas.surface_store_buffer();
|
canvas.surface_store_buffer();
|
||||||
|
@ -159,16 +178,17 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
if(applySelection) {
|
if(applySelection) {
|
||||||
maskedSurface = surface_verify(maskedSurface, sw, sh);
|
maskedSurface = surface_verify(maskedSurface, sw, sh);
|
||||||
surface_set_shader(maskedSurface);
|
surface_set_shader(maskedSurface);
|
||||||
draw_surface(_surf, 0, 0);
|
draw_surface_safe(_surf);
|
||||||
BLEND_MULTIPLY
|
BLEND_MULTIPLY
|
||||||
draw_surface(canvas.tool_selection.selection_mask, 0, 0);
|
draw_surface_safe(canvas.tool_selection.selection_mask, 0, 0);
|
||||||
BLEND_NORMAL
|
BLEND_NORMAL
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
||||||
} else
|
} else
|
||||||
maskedSurface = _surf;
|
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);
|
draw_surface_ext_safe(maskedSurface, _dx, _dy, _s, _s);
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) { apply(); MOUSE_BLOCK = true; }
|
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 {
|
function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
|
|
||||||
self.canvas = canvas;
|
self.canvas = canvas;
|
||||||
|
@ -13,7 +13,7 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
static cleanUp = function() {
|
static cleanUp = function() {
|
||||||
|
UNDO_HOLDING = true;
|
||||||
surface_free_safe(targetSurface);
|
surface_free_safe(targetSurface);
|
||||||
surface_free_safe(maskedSurface);
|
surface_free_safe(maskedSurface);
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node.nodeTool = noone;
|
||||||
|
UNDO_HOLDING = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
@ -87,31 +89,48 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
|
|
||||||
function apply() {
|
function apply() {
|
||||||
var _surf = surface_create(sw, sh);
|
var _surf = surface_create(sw, sh);
|
||||||
|
var _repl = key_mod_press(SHIFT);
|
||||||
|
|
||||||
if(applySelection) {
|
if(applySelection) {
|
||||||
|
var _fore = canvas.tool_selection.selection_surface;
|
||||||
|
|
||||||
surface_set_shader(_surf, sh_blend_normal);
|
if(_repl) {
|
||||||
shader_set_surface("fore", maskedSurface);
|
surface_set_shader(_surf, noone);
|
||||||
shader_set_f("dimension", 1, 1);
|
draw_surface_safe(maskedSurface);
|
||||||
shader_set_f("opacity", 1);
|
surface_reset_shader();
|
||||||
|
|
||||||
draw_surface(canvas.tool_selection.selection_surface, 0, 0);
|
} else {
|
||||||
surface_reset_shader();
|
surface_set_shader(_surf, sh_blend_normal);
|
||||||
|
shader_set_surface("fore", maskedSurface);
|
||||||
|
shader_set_f("dimension", 1, 1);
|
||||||
|
shader_set_f("opacity", 1);
|
||||||
|
|
||||||
surface_free(canvas.tool_selection.selection_surface);
|
draw_surface_safe(_fore);
|
||||||
|
surface_reset_shader();
|
||||||
|
}
|
||||||
|
|
||||||
|
surface_free(_fore);
|
||||||
canvas.tool_selection.selection_surface = _surf;
|
canvas.tool_selection.selection_surface = _surf;
|
||||||
canvas.tool_selection.apply();
|
canvas.tool_selection.apply();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
var _fore = canvas.getCanvasSurface();
|
||||||
canvas.storeAction();
|
canvas.storeAction();
|
||||||
|
|
||||||
surface_set_shader(_surf, sh_blend_normal);
|
if(_repl) {
|
||||||
shader_set_surface("fore", maskedSurface);
|
surface_set_shader(_surf, noone);
|
||||||
shader_set_f("dimension", 1, 1);
|
draw_surface_safe(maskedSurface);
|
||||||
shader_set_f("opacity", 1);
|
surface_reset_shader();
|
||||||
|
|
||||||
draw_surface(canvas.getCanvasSurface(), 0, 0);
|
} else {
|
||||||
surface_reset_shader();
|
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.setCanvasSurface(_surf);
|
||||||
canvas.surface_store_buffer();
|
canvas.surface_store_buffer();
|
||||||
|
@ -159,16 +178,17 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
if(applySelection) {
|
if(applySelection) {
|
||||||
maskedSurface = surface_verify(maskedSurface, sw, sh);
|
maskedSurface = surface_verify(maskedSurface, sw, sh);
|
||||||
surface_set_shader(maskedSurface);
|
surface_set_shader(maskedSurface);
|
||||||
draw_surface(_surf, 0, 0);
|
draw_surface_safe(_surf);
|
||||||
BLEND_MULTIPLY
|
BLEND_MULTIPLY
|
||||||
draw_surface(canvas.tool_selection.selection_mask, 0, 0);
|
draw_surface_safe(canvas.tool_selection.selection_mask, 0, 0);
|
||||||
BLEND_NORMAL
|
BLEND_NORMAL
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
||||||
} else
|
} else
|
||||||
maskedSurface = _surf;
|
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);
|
draw_surface_ext_safe(maskedSurface, _dx, _dy, _s, _s);
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) { apply(); MOUSE_BLOCK = true; }
|
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 {
|
function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
name = "Canvas";
|
name = "Canvas";
|
||||||
color = COLORS.node_blend_canvas;
|
color = COLORS.node_blend_canvas;
|
||||||
|
|
|
@ -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 {
|
function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
name = "Canvas";
|
name = "Canvas";
|
||||||
color = COLORS.node_blend_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
|
static storeAction = function() { #region
|
||||||
|
|
||||||
var action = recordAction(ACTION_TYPE.custom, function(data) {
|
var action = recordAction(ACTION_TYPE.custom, function(data) {
|
||||||
|
if(tool_selection.is_selected) tool_selection.apply();
|
||||||
|
|
||||||
var _canvas = surface_clone(getCanvasSurface(data.index));
|
var _canvas = surface_clone(getCanvasSurface(data.index));
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
name = "Number";
|
name = "Number";
|
||||||
color = COLORS.node_blend_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 {
|
function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
name = "Number";
|
name = "Number";
|
||||||
color = COLORS.node_blend_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 _dat = getInputData(0);
|
||||||
var _int = getInputData(1);
|
var _int = getInputData(1);
|
||||||
|
|
||||||
print(_dat);
|
|
||||||
var _res = processNumber(_dat, _int);
|
var _res = processNumber(_dat, _int);
|
||||||
outputs[| 0].setValue(_res);
|
outputs[| 0].setValue(_res);
|
||||||
} #endregion
|
} #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 vec2 v_vTexcoord;
|
||||||
varying vec4 v_vColour;
|
varying vec4 v_vColour;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// 2024-04-24 10:08:32
|
// 2024-04-24 10:09:27
|
||||||
varying vec2 v_vTexcoord;
|
varying vec2 v_vTexcoord;
|
||||||
varying vec4 v_vColour;
|
varying vec4 v_vColour;
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,9 @@ event_inherited();
|
||||||
if(!_node) return;
|
if(!_node) return;
|
||||||
|
|
||||||
if(is_instanceof(context, Node_Canvas)) {
|
if(is_instanceof(context, Node_Canvas)) {
|
||||||
|
UNDO_HOLDING = true;
|
||||||
context.nodeTool = new canvas_tool_node(context, _node).init();
|
context.nodeTool = new canvas_tool_node(context, _node).init();
|
||||||
|
UNDO_HOLDING = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
static cleanUp = function() {
|
static cleanUp = function() {
|
||||||
|
UNDO_HOLDING = true;
|
||||||
surface_free_safe(targetSurface);
|
surface_free_safe(targetSurface);
|
||||||
surface_free_safe(maskedSurface);
|
surface_free_safe(maskedSurface);
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node.nodeTool = noone;
|
||||||
|
UNDO_HOLDING = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
@ -86,31 +88,48 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
|
|
||||||
function apply() {
|
function apply() {
|
||||||
var _surf = surface_create(sw, sh);
|
var _surf = surface_create(sw, sh);
|
||||||
|
var _repl = key_mod_press(SHIFT);
|
||||||
|
|
||||||
if(applySelection) {
|
if(applySelection) {
|
||||||
|
var _fore = canvas.tool_selection.selection_surface;
|
||||||
|
|
||||||
surface_set_shader(_surf, sh_blend_normal);
|
if(_repl) {
|
||||||
shader_set_surface("fore", maskedSurface);
|
surface_set_shader(_surf, noone);
|
||||||
shader_set_f("dimension", 1, 1);
|
draw_surface_safe(maskedSurface);
|
||||||
shader_set_f("opacity", 1);
|
surface_reset_shader();
|
||||||
|
|
||||||
draw_surface(canvas.tool_selection.selection_surface, 0, 0);
|
} else {
|
||||||
surface_reset_shader();
|
surface_set_shader(_surf, sh_blend_normal);
|
||||||
|
shader_set_surface("fore", maskedSurface);
|
||||||
|
shader_set_f("dimension", 1, 1);
|
||||||
|
shader_set_f("opacity", 1);
|
||||||
|
|
||||||
surface_free(canvas.tool_selection.selection_surface);
|
draw_surface_safe(_fore);
|
||||||
|
surface_reset_shader();
|
||||||
|
}
|
||||||
|
|
||||||
|
surface_free(_fore);
|
||||||
canvas.tool_selection.selection_surface = _surf;
|
canvas.tool_selection.selection_surface = _surf;
|
||||||
canvas.tool_selection.apply();
|
canvas.tool_selection.apply();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
var _fore = canvas.getCanvasSurface();
|
||||||
canvas.storeAction();
|
canvas.storeAction();
|
||||||
|
|
||||||
surface_set_shader(_surf, sh_blend_normal);
|
if(_repl) {
|
||||||
shader_set_surface("fore", maskedSurface);
|
surface_set_shader(_surf, noone);
|
||||||
shader_set_f("dimension", 1, 1);
|
draw_surface_safe(maskedSurface);
|
||||||
shader_set_f("opacity", 1);
|
surface_reset_shader();
|
||||||
|
|
||||||
draw_surface(canvas.getCanvasSurface(), 0, 0);
|
} else {
|
||||||
surface_reset_shader();
|
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.setCanvasSurface(_surf);
|
||||||
canvas.surface_store_buffer();
|
canvas.surface_store_buffer();
|
||||||
|
@ -158,16 +177,17 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||||
if(applySelection) {
|
if(applySelection) {
|
||||||
maskedSurface = surface_verify(maskedSurface, sw, sh);
|
maskedSurface = surface_verify(maskedSurface, sw, sh);
|
||||||
surface_set_shader(maskedSurface);
|
surface_set_shader(maskedSurface);
|
||||||
draw_surface(_surf, 0, 0);
|
draw_surface_safe(_surf);
|
||||||
BLEND_MULTIPLY
|
BLEND_MULTIPLY
|
||||||
draw_surface(canvas.tool_selection.selection_mask, 0, 0);
|
draw_surface_safe(canvas.tool_selection.selection_mask, 0, 0);
|
||||||
BLEND_NORMAL
|
BLEND_NORMAL
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
||||||
} else
|
} else
|
||||||
maskedSurface = _surf;
|
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);
|
draw_surface_ext_safe(maskedSurface, _dx, _dy, _s, _s);
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) { apply(); MOUSE_BLOCK = true; }
|
if(mouse_press(mb_left, active)) { apply(); MOUSE_BLOCK = true; }
|
||||||
|
|
|
@ -152,7 +152,6 @@ function Panel_History() : PanelContent() constructor {
|
||||||
|
|
||||||
function drawContent(panel) {
|
function drawContent(panel) {
|
||||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||||
PANEL_PADDING
|
|
||||||
|
|
||||||
var px = ui(padding);
|
var px = ui(padding);
|
||||||
var py = ui(padding);
|
var py = ui(padding);
|
||||||
|
|
Loading…
Reference in a new issue