mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-23 21:46:17 +01:00
canvas undo
This commit is contained in:
parent
33ea9fd7e3
commit
63dae9b547
28 changed files with 782 additions and 449 deletions
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-16 11:36:08
|
||||
// 2024-04-21 14:51:29
|
||||
#event properties (no comments/etc. here are saved)
|
||||
parent_index = _p_dialog;
|
||||
uses_physics = false;
|
||||
|
@ -134,7 +134,7 @@ event_inherited();
|
|||
if(!_node) return;
|
||||
|
||||
if(is_instanceof(context, Node_Canvas)) {
|
||||
context.nodeTool = new canvas_tool_node(context, _node);
|
||||
context.nodeTool = new canvas_tool_node(context, _node).init();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-16 11:31:51
|
||||
// 2024-04-21 14:49:20
|
||||
#event properties (no comments/etc. here are saved)
|
||||
parent_index = _p_dialog;
|
||||
uses_physics = false;
|
||||
|
@ -134,7 +134,7 @@ event_inherited();
|
|||
if(!_node) return;
|
||||
|
||||
if(is_instanceof(context, Node_Canvas)) {
|
||||
context.nodeTool = new canvas_tool_node(context, _node);
|
||||
canvas_create_tool_node(context, _node);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-18 13:01:11
|
||||
// 2024-04-21 15:26:33
|
||||
#event properties (no comments/etc. here are saved)
|
||||
parent_index = -1;
|
||||
persistent = true;
|
||||
|
@ -470,11 +470,6 @@ if(PROJECT.active && !PROJECT.safeMode) { #region
|
|||
} #endregion
|
||||
|
||||
#region hotkey
|
||||
HOTKEY_MOD = 0;
|
||||
if(CTRL == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.ctrl;
|
||||
if(SHIFT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.shift;
|
||||
if(ALT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.alt;
|
||||
|
||||
if(!instance_exists(o_dialog_preference) && !HOTKEY_BLOCK) {
|
||||
if(ds_map_exists(HOTKEYS, "")) {
|
||||
var l = HOTKEYS[? ""];
|
||||
|
@ -786,44 +781,35 @@ _HOVERING_ELEMENT = noone;
|
|||
#endregion
|
||||
|
||||
#region modifiers
|
||||
if(CTRL == KEYBOARD_STATUS.up)
|
||||
CTRL = KEYBOARD_STATUS.idle;
|
||||
if(SHIFT == KEYBOARD_STATUS.up)
|
||||
SHIFT = KEYBOARD_STATUS.idle;
|
||||
if(ALT == KEYBOARD_STATUS.up)
|
||||
ALT = KEYBOARD_STATUS.idle;
|
||||
if(CTRL == KEYBOARD_STATUS.up) CTRL = KEYBOARD_STATUS.idle;
|
||||
if(SHIFT == KEYBOARD_STATUS.up) SHIFT = KEYBOARD_STATUS.idle;
|
||||
if(ALT == KEYBOARD_STATUS.up) ALT = KEYBOARD_STATUS.idle;
|
||||
|
||||
if(CTRL == KEYBOARD_STATUS.pressing && !keyboard_check(vk_control))
|
||||
if(CTRL == KEYBOARD_STATUS.pressing && !keyboard_check(vk_control))
|
||||
CTRL = KEYBOARD_STATUS.up;
|
||||
|
||||
if(SHIFT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_shift))
|
||||
SHIFT = KEYBOARD_STATUS.up;
|
||||
|
||||
if(ALT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.up;
|
||||
if(ALT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.up;
|
||||
|
||||
if(CTRL == KEYBOARD_STATUS.down)
|
||||
CTRL = KEYBOARD_STATUS.pressing;
|
||||
if(CTRL == KEYBOARD_STATUS.down) CTRL = KEYBOARD_STATUS.pressing;
|
||||
if(SHIFT == KEYBOARD_STATUS.down) SHIFT = KEYBOARD_STATUS.pressing;
|
||||
if(ALT == KEYBOARD_STATUS.down) ALT = KEYBOARD_STATUS.pressing;
|
||||
|
||||
if(SHIFT == KEYBOARD_STATUS.down)
|
||||
SHIFT = KEYBOARD_STATUS.pressing;
|
||||
if(keyboard_check_pressed(vk_control)) CTRL = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_shift)) SHIFT = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_alt)) ALT = KEYBOARD_STATUS.down;
|
||||
|
||||
if(ALT == KEYBOARD_STATUS.down)
|
||||
ALT = KEYBOARD_STATUS.pressing;
|
||||
if(keyboard_check_released(vk_control)) CTRL = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_shift)) SHIFT = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_alt)) ALT = KEYBOARD_STATUS.up;
|
||||
|
||||
if(keyboard_check_pressed(vk_control))
|
||||
CTRL = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_shift))
|
||||
SHIFT = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.down;
|
||||
|
||||
if(keyboard_check_released(vk_control))
|
||||
CTRL = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_shift))
|
||||
SHIFT = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.up;
|
||||
HOTKEY_MOD = 0;
|
||||
if(CTRL == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.ctrl;
|
||||
if(SHIFT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.shift;
|
||||
if(ALT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.alt;
|
||||
#endregion
|
||||
|
||||
#region mouse wrap
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-18 12:59:59
|
||||
// 2024-04-21 15:25:55
|
||||
#event properties (no comments/etc. here are saved)
|
||||
parent_index = -1;
|
||||
persistent = true;
|
||||
|
@ -470,11 +470,6 @@ if(PROJECT.active && !PROJECT.safeMode) { #region
|
|||
} #endregion
|
||||
|
||||
#region hotkey
|
||||
HOTKEY_MOD = 0;
|
||||
if(CTRL == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.ctrl;
|
||||
if(SHIFT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.shift;
|
||||
if(ALT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.alt;
|
||||
|
||||
if(!instance_exists(o_dialog_preference) && !HOTKEY_BLOCK) {
|
||||
if(ds_map_exists(HOTKEYS, "")) {
|
||||
var l = HOTKEYS[? ""];
|
||||
|
@ -786,44 +781,37 @@ _HOVERING_ELEMENT = noone;
|
|||
#endregion
|
||||
|
||||
#region modifiers
|
||||
if(CTRL == KEYBOARD_STATUS.up)
|
||||
CTRL = KEYBOARD_STATUS.idle;
|
||||
if(SHIFT == KEYBOARD_STATUS.up)
|
||||
SHIFT = KEYBOARD_STATUS.idle;
|
||||
if(ALT == KEYBOARD_STATUS.up)
|
||||
ALT = KEYBOARD_STATUS.idle;
|
||||
if(CTRL == KEYBOARD_STATUS.up) CTRL = KEYBOARD_STATUS.idle;
|
||||
if(SHIFT == KEYBOARD_STATUS.up) SHIFT = KEYBOARD_STATUS.idle;
|
||||
if(ALT == KEYBOARD_STATUS.up) ALT = KEYBOARD_STATUS.idle;
|
||||
|
||||
if(CTRL == KEYBOARD_STATUS.pressing && !keyboard_check(vk_control))
|
||||
if(CTRL == KEYBOARD_STATUS.pressing && !keyboard_check(vk_control))
|
||||
CTRL = KEYBOARD_STATUS.up;
|
||||
|
||||
if(SHIFT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_shift))
|
||||
SHIFT = KEYBOARD_STATUS.up;
|
||||
|
||||
if(ALT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.up;
|
||||
if(ALT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.up;
|
||||
|
||||
if(CTRL == KEYBOARD_STATUS.down)
|
||||
CTRL = KEYBOARD_STATUS.pressing;
|
||||
if(CTRL == KEYBOARD_STATUS.down) CTRL = KEYBOARD_STATUS.pressing;
|
||||
if(SHIFT == KEYBOARD_STATUS.down) SHIFT = KEYBOARD_STATUS.pressing;
|
||||
if(ALT == KEYBOARD_STATUS.down) ALT = KEYBOARD_STATUS.pressing;
|
||||
|
||||
if(SHIFT == KEYBOARD_STATUS.down)
|
||||
SHIFT = KEYBOARD_STATUS.pressing;
|
||||
if(keyboard_check_pressed(vk_control)) CTRL = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_shift)) SHIFT = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_alt)) ALT = KEYBOARD_STATUS.down;
|
||||
|
||||
if(ALT == KEYBOARD_STATUS.down)
|
||||
ALT = KEYBOARD_STATUS.pressing;
|
||||
if(keyboard_check_released(vk_control)) CTRL = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_shift)) SHIFT = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_alt)) ALT = KEYBOARD_STATUS.up;
|
||||
|
||||
if(keyboard_check_pressed(vk_control))
|
||||
CTRL = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_shift))
|
||||
SHIFT = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.down;
|
||||
HOTKEY_MOD = 0;
|
||||
if(CTRL == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.ctrl;
|
||||
if(SHIFT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.shift;
|
||||
if(ALT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.alt;
|
||||
|
||||
if(keyboard_check_released(vk_control))
|
||||
CTRL = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_shift))
|
||||
SHIFT = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.up;
|
||||
print(HOTKEY_MOD);
|
||||
#endregion
|
||||
|
||||
#region mouse wrap
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-16 11:00:41
|
||||
// 2024-04-21 15:03:47
|
||||
function canvas_tool_curve_bezier(brush) : canvas_tool() constructor {
|
||||
self.brush = brush;
|
||||
brush_resizable = true;
|
||||
|
@ -71,6 +71,8 @@ function canvas_tool_curve_bezier(brush) : canvas_tool() constructor {
|
|||
}
|
||||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
recordAction(ACTION_TYPE.var_modify, self, [ array_clone(anchors), "anchors" ]);
|
||||
|
||||
if(mouse_hovering[0] == noone) {
|
||||
array_push(anchors, [ 0, 0, mouse_cur_x, mouse_cur_y, 0, 0 ]);
|
||||
editing[0] = array_length(anchors) - 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-16 11:00:38
|
||||
// 2024-04-21 15:02:12
|
||||
function canvas_tool_curve_bezier(brush) : canvas_tool() constructor {
|
||||
self.brush = brush;
|
||||
brush_resizable = true;
|
||||
|
@ -71,6 +71,8 @@ function canvas_tool_curve_bezier(brush) : canvas_tool() constructor {
|
|||
}
|
||||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
recordAction(ACTION_TYPE.var_modify, self, [ array_clone(anchors), "anchors" ]);
|
||||
|
||||
if(mouse_hovering[0] == noone) {
|
||||
array_push(anchors, [ 0, 0, mouse_cur_x, mouse_cur_y, 0, 0 ]);
|
||||
editing[0] = array_length(anchors) - 1;
|
||||
|
|
|
@ -1,35 +1,19 @@
|
|||
// 2024-04-18 12:08:52
|
||||
// 2024-04-21 14:54:22
|
||||
function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||
|
||||
self.canvas = canvas;
|
||||
self.node = node;
|
||||
override = true;
|
||||
override = true;
|
||||
|
||||
applySelection = canvas.tool_selection.is_selected;
|
||||
|
||||
destiSurface = applySelection? canvas.tool_selection.selection_surface : canvas.getCanvasSurface();
|
||||
if(!is_surface(destiSurface)) {
|
||||
canvas.nodeTool = noone;
|
||||
return;
|
||||
}
|
||||
|
||||
sw = surface_get_width(destiSurface);
|
||||
sh = surface_get_height(destiSurface);
|
||||
targetSurface = surface_create(sw, sh);
|
||||
maskedSurface = surface_create(sw, sh);
|
||||
|
||||
surface_set_shader(targetSurface, noone);
|
||||
draw_surface_safe(destiSurface);
|
||||
surface_reset_shader();
|
||||
applySelection = false;
|
||||
|
||||
static destroy = function() {
|
||||
if(applySelection) canvas.tool_selection.apply();
|
||||
canvas.nodeTool = noone;
|
||||
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
static cleanUp = function() {
|
||||
|
||||
surface_free_safe(targetSurface);
|
||||
surface_free_safe(maskedSurface);
|
||||
|
||||
|
@ -47,37 +31,56 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
|
||||
}
|
||||
|
||||
nodeObject = node.build(0, 0);
|
||||
|
||||
if(nodeObject == noone || !is_instanceof(nodeObject, Node)) {
|
||||
noti_warning("Not tools only allows a single node.");
|
||||
destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
inputJunction = noone;
|
||||
outputJunction = noone;
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.inputs); i < n; i++ ) {
|
||||
var _in = nodeObject.inputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface || _in.name == "Dimension") {
|
||||
inputJunction = _in;
|
||||
break;
|
||||
function init() {
|
||||
|
||||
applySelection = canvas.tool_selection.is_selected;
|
||||
destiSurface = applySelection? canvas.tool_selection.selection_surface : canvas.getCanvasSurface();
|
||||
if(!is_surface(destiSurface))
|
||||
return noone;
|
||||
|
||||
sw = surface_get_width(destiSurface);
|
||||
sh = surface_get_height(destiSurface);
|
||||
targetSurface = surface_create(sw, sh);
|
||||
maskedSurface = surface_create(sw, sh);
|
||||
|
||||
surface_set_shader(targetSurface, noone);
|
||||
draw_surface_safe(destiSurface);
|
||||
surface_reset_shader();
|
||||
|
||||
nodeObject = node.build(0, 0);
|
||||
|
||||
if(nodeObject == noone || !is_instanceof(nodeObject, Node)) {
|
||||
noti_warning("Not tools only allows a single node.");
|
||||
destroy();
|
||||
return noone;
|
||||
}
|
||||
}
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.outputs); i < n; i++ ) {
|
||||
var _in = nodeObject.outputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface) {
|
||||
outputJunction = _in;
|
||||
break;
|
||||
|
||||
inputJunction = noone;
|
||||
outputJunction = noone;
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.inputs); i < n; i++ ) {
|
||||
var _in = nodeObject.inputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface || _in.name == "Dimension") {
|
||||
inputJunction = _in;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(outputJunction == noone) {
|
||||
noti_warning("Selected node has no surface output.");
|
||||
destroy();
|
||||
return;
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.outputs); i < n; i++ ) {
|
||||
var _in = nodeObject.outputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface) {
|
||||
outputJunction = _in;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(outputJunction == noone) {
|
||||
noti_warning("Selected node has no surface output.");
|
||||
destroy();
|
||||
return noone;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -115,7 +118,6 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
}
|
||||
|
||||
PANEL_PREVIEW.tool_current = noone;
|
||||
canvas.nodeTool = noone;
|
||||
|
||||
cleanUp();
|
||||
}
|
||||
|
|
|
@ -1,35 +1,19 @@
|
|||
// 2024-04-17 08:13:29
|
||||
// 2024-04-21 14:53:39
|
||||
function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
||||
|
||||
self.canvas = canvas;
|
||||
self.node = node;
|
||||
override = true;
|
||||
override = true;
|
||||
|
||||
applySelection = canvas.tool_selection.is_selected;
|
||||
|
||||
destiSurface = applySelection? canvas.tool_selection.selection_surface : canvas.getCanvasSurface();
|
||||
if(!is_surface(destiSurface)) {
|
||||
canvas.nodeTool = noone;
|
||||
return;
|
||||
}
|
||||
|
||||
sw = surface_get_width(destiSurface);
|
||||
sh = surface_get_height(destiSurface);
|
||||
targetSurface = surface_create(sw, sh);
|
||||
maskedSurface = surface_create(sw, sh);
|
||||
|
||||
surface_set_shader(targetSurface, noone);
|
||||
draw_surface_safe(destiSurface);
|
||||
surface_reset_shader();
|
||||
applySelection = false;
|
||||
|
||||
static destroy = function() {
|
||||
if(applySelection) canvas.tool_selection.apply();
|
||||
canvas.nodeTool = noone;
|
||||
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
static cleanUp = function() {
|
||||
|
||||
surface_free_safe(targetSurface);
|
||||
surface_free_safe(maskedSurface);
|
||||
|
||||
|
@ -47,37 +31,56 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
|
||||
}
|
||||
|
||||
nodeObject = node.build(0, 0);
|
||||
|
||||
if(nodeObject == noone || !is_instanceof(nodeObject, Node)) {
|
||||
noti_warning("Not tools only allows a single node.");
|
||||
destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
inputJunction = noone;
|
||||
outputJunction = noone;
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.inputs); i < n; i++ ) {
|
||||
var _in = nodeObject.inputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface || _in.name == "Dimension") {
|
||||
inputJunction = _in;
|
||||
break;
|
||||
function init() {
|
||||
|
||||
applySelection = canvas.tool_selection.is_selected;
|
||||
destiSurface = applySelection? canvas.tool_selection.selection_surface : canvas.getCanvasSurface();
|
||||
if(!is_surface(destiSurface))
|
||||
return noone;
|
||||
|
||||
sw = surface_get_width(destiSurface);
|
||||
sh = surface_get_height(destiSurface);
|
||||
targetSurface = surface_create(sw, sh);
|
||||
maskedSurface = surface_create(sw, sh);
|
||||
|
||||
surface_set_shader(targetSurface, noone);
|
||||
draw_surface_safe(destiSurface);
|
||||
surface_reset_shader();
|
||||
|
||||
nodeObject = node.build(0, 0);
|
||||
|
||||
if(nodeObject == noone || !is_instanceof(nodeObject, Node)) {
|
||||
noti_warning("Not tools only allows a single node.");
|
||||
destroy();
|
||||
return noone;
|
||||
}
|
||||
}
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.outputs); i < n; i++ ) {
|
||||
var _in = nodeObject.outputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface) {
|
||||
outputJunction = _in;
|
||||
break;
|
||||
|
||||
inputJunction = noone;
|
||||
outputJunction = noone;
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.inputs); i < n; i++ ) {
|
||||
var _in = nodeObject.inputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface || _in.name == "Dimension") {
|
||||
inputJunction = _in;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(outputJunction == noone) {
|
||||
noti_warning("Selected node has no surface output.");
|
||||
destroy();
|
||||
return;
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.outputs); i < n; i++ ) {
|
||||
var _in = nodeObject.outputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface) {
|
||||
outputJunction = _in;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(outputJunction == noone) {
|
||||
noti_warning("Selected node has no surface output.");
|
||||
destroy();
|
||||
return noone;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -115,7 +118,6 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
}
|
||||
|
||||
PANEL_PREVIEW.tool_current = noone;
|
||||
canvas.nodeTool = noone;
|
||||
|
||||
cleanUp();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-18 14:19:06
|
||||
// 2024-04-21 16:47:59
|
||||
function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
||||
|
||||
self.selector = selector;
|
||||
|
@ -23,7 +23,6 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
mouse_pre_y = 0;
|
||||
|
||||
function createSelection(_mask, sel_x0, sel_y0, sel_w, sel_h) { #region
|
||||
|
||||
if(is_selected)
|
||||
apply();
|
||||
else {
|
||||
|
@ -84,8 +83,7 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
var _nw = _x1 - _x0;
|
||||
var _nh = _y1 - _y0;
|
||||
|
||||
var _selection_surface = surface_create(_nw, _nh);
|
||||
var _selection_mask = surface_create(_nw, _nh);
|
||||
var _selection_mask = surface_create(_nw, _nh);
|
||||
|
||||
surface_set_target(_selection_mask);
|
||||
DRAW_CLEAR
|
||||
|
@ -100,33 +98,8 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
BLEND_NORMAL
|
||||
surface_reset_target();
|
||||
|
||||
surface_set_target(_selection_surface);
|
||||
DRAW_CLEAR
|
||||
draw_surface_safe(_canvas_surface, -_x0, -_y0);
|
||||
|
||||
BLEND_MULTIPLY
|
||||
draw_surface_safe(_selection_mask, 0, 0);
|
||||
BLEND_NORMAL
|
||||
surface_reset_target();
|
||||
|
||||
surface_free(selection_surface);
|
||||
surface_free(selection_mask);
|
||||
|
||||
selection_surface = _selection_surface;
|
||||
selection_mask = _selection_mask;
|
||||
|
||||
node.storeAction();
|
||||
surface_set_target(_canvas_surface);
|
||||
gpu_set_blendmode(bm_subtract);
|
||||
draw_surface_safe(selection_surface, _x0, _y0);
|
||||
gpu_set_blendmode(bm_normal);
|
||||
surface_reset_target();
|
||||
|
||||
node.surface_store_buffer();
|
||||
|
||||
selection_position = [ _x0, _y0 ];
|
||||
selection_size = [ _nw, _nh ];
|
||||
is_selected = true;
|
||||
createNewSelection(_selection_mask, _x0, _y0, _nw, _nh);
|
||||
surface_free(_selection_mask);
|
||||
} #endregion
|
||||
|
||||
function createNewSelection(_mask, sel_x0, sel_y0, sel_w, sel_h) { #region
|
||||
|
@ -164,8 +137,9 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
} #endregion
|
||||
|
||||
function copySelection() { #region
|
||||
var s = surface_encode(selection_surface);
|
||||
clipboard_set_text(s);
|
||||
var s = surface_encode(selection_surface, false);
|
||||
s.position = selection_position;
|
||||
clipboard_set_text(json_stringify(s));
|
||||
} #endregion
|
||||
|
||||
function apply() { #region
|
||||
|
@ -241,7 +215,7 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
} else if(key_press(vk_escape)) {
|
||||
apply();
|
||||
|
||||
} else if(key_press(ord("C"), MOD_KEY.ctrl)) copySelection();
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-18 14:17:33
|
||||
// 2024-04-21 16:47:25
|
||||
function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
||||
|
||||
self.selector = selector;
|
||||
|
@ -23,7 +23,6 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
mouse_pre_y = 0;
|
||||
|
||||
function createSelection(_mask, sel_x0, sel_y0, sel_w, sel_h) { #region
|
||||
|
||||
if(is_selected)
|
||||
apply();
|
||||
else {
|
||||
|
@ -84,8 +83,7 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
var _nw = _x1 - _x0;
|
||||
var _nh = _y1 - _y0;
|
||||
|
||||
var _selection_surface = surface_create(_nw, _nh);
|
||||
var _selection_mask = surface_create(_nw, _nh);
|
||||
var _selection_mask = surface_create(_nw, _nh);
|
||||
|
||||
surface_set_target(_selection_mask);
|
||||
DRAW_CLEAR
|
||||
|
@ -100,33 +98,8 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
BLEND_NORMAL
|
||||
surface_reset_target();
|
||||
|
||||
surface_set_target(_selection_surface);
|
||||
DRAW_CLEAR
|
||||
draw_surface_safe(_canvas_surface, -_x0, -_y0);
|
||||
|
||||
BLEND_MULTIPLY
|
||||
draw_surface_safe(_selection_mask, 0, 0);
|
||||
BLEND_NORMAL
|
||||
surface_reset_target();
|
||||
|
||||
surface_free(selection_surface);
|
||||
surface_free(selection_mask);
|
||||
|
||||
selection_surface = _selection_surface;
|
||||
selection_mask = _selection_mask;
|
||||
|
||||
node.storeAction();
|
||||
surface_set_target(_canvas_surface);
|
||||
gpu_set_blendmode(bm_subtract);
|
||||
draw_surface_safe(selection_surface, _x0, _y0);
|
||||
gpu_set_blendmode(bm_normal);
|
||||
surface_reset_target();
|
||||
|
||||
node.surface_store_buffer();
|
||||
|
||||
selection_position = [ _x0, _y0 ];
|
||||
selection_size = [ _nw, _nh ];
|
||||
is_selected = true;
|
||||
createNewSelection(_selection_mask, _x0, _y0, _nw, _nh);
|
||||
surface_free(_selection_mask);
|
||||
} #endregion
|
||||
|
||||
function createNewSelection(_mask, sel_x0, sel_y0, sel_w, sel_h) { #region
|
||||
|
@ -164,8 +137,9 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
} #endregion
|
||||
|
||||
function copySelection() { #region
|
||||
var s = surface_encode(selection_surface);
|
||||
clipboard_set_text(s);
|
||||
var s = surface_encode(selection_surface, false);
|
||||
s.position = selection_position;
|
||||
clipboard_set_text(json_stringify(s));
|
||||
} #endregion
|
||||
|
||||
function apply() { #region
|
||||
|
@ -241,7 +215,7 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
} else if(key_press(vk_escape)) {
|
||||
apply();
|
||||
|
||||
} else if(key_press(ord("C"), MOD_KEY.ctrl)) copySelection();
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
|
|
152
#backups/scripts/key_press/key_press.gml.backup0
Normal file
152
#backups/scripts/key_press/key_press.gml.backup0
Normal file
|
@ -0,0 +1,152 @@
|
|||
// 2024-04-21 15:16:18
|
||||
#region key map
|
||||
global.KEY_STRING_MAP = ds_map_create();
|
||||
|
||||
global.KEY_STRING_MAP[? 0] = ""
|
||||
global.KEY_STRING_MAP[? 48] = "0"
|
||||
global.KEY_STRING_MAP[? 49] = "1"
|
||||
global.KEY_STRING_MAP[? 50] = "2"
|
||||
global.KEY_STRING_MAP[? 51] = "3"
|
||||
global.KEY_STRING_MAP[? 52] = "4"
|
||||
global.KEY_STRING_MAP[? 53] = "5"
|
||||
global.KEY_STRING_MAP[? 54] = "6"
|
||||
global.KEY_STRING_MAP[? 55] = "7"
|
||||
global.KEY_STRING_MAP[? 56] = "8"
|
||||
global.KEY_STRING_MAP[? 57] = "9"
|
||||
|
||||
global.KEY_STRING_MAP[? 65] = "A"
|
||||
global.KEY_STRING_MAP[? 66] = "B"
|
||||
global.KEY_STRING_MAP[? 67] = "C"
|
||||
global.KEY_STRING_MAP[? 68] = "D"
|
||||
global.KEY_STRING_MAP[? 69] = "E"
|
||||
global.KEY_STRING_MAP[? 70] = "F"
|
||||
global.KEY_STRING_MAP[? 71] = "G"
|
||||
global.KEY_STRING_MAP[? 72] = "H"
|
||||
global.KEY_STRING_MAP[? 73] = "I"
|
||||
global.KEY_STRING_MAP[? 74] = "J"
|
||||
global.KEY_STRING_MAP[? 75] = "K"
|
||||
global.KEY_STRING_MAP[? 76] = "L"
|
||||
global.KEY_STRING_MAP[? 77] = "M"
|
||||
global.KEY_STRING_MAP[? 78] = "N"
|
||||
global.KEY_STRING_MAP[? 79] = "O"
|
||||
global.KEY_STRING_MAP[? 80] = "P"
|
||||
global.KEY_STRING_MAP[? 81] = "Q"
|
||||
global.KEY_STRING_MAP[? 82] = "R"
|
||||
global.KEY_STRING_MAP[? 83] = "S"
|
||||
global.KEY_STRING_MAP[? 84] = "T"
|
||||
global.KEY_STRING_MAP[? 85] = "U"
|
||||
global.KEY_STRING_MAP[? 86] = "V"
|
||||
global.KEY_STRING_MAP[? 87] = "W"
|
||||
global.KEY_STRING_MAP[? 88] = "X"
|
||||
global.KEY_STRING_MAP[? 89] = "Y"
|
||||
global.KEY_STRING_MAP[? 90] = "Z"
|
||||
|
||||
global.KEY_STRING_MAP[? 96] = "Num 0"
|
||||
global.KEY_STRING_MAP[? 97] = "Num 1"
|
||||
global.KEY_STRING_MAP[? 98] = "Num 2"
|
||||
global.KEY_STRING_MAP[? 99] = "Num 3"
|
||||
global.KEY_STRING_MAP[? 100] = "Num 4"
|
||||
global.KEY_STRING_MAP[? 101] = "Num 5"
|
||||
global.KEY_STRING_MAP[? 102] = "Num 6"
|
||||
global.KEY_STRING_MAP[? 103] = "Num 7"
|
||||
global.KEY_STRING_MAP[? 104] = "Num 8"
|
||||
global.KEY_STRING_MAP[? 105] = "Num 9"
|
||||
|
||||
global.KEY_STRING_MAP[? 106] = "Num *"
|
||||
global.KEY_STRING_MAP[? 107] = "Num +"
|
||||
global.KEY_STRING_MAP[? 109] = "Num -"
|
||||
global.KEY_STRING_MAP[? 110] = "Num ."
|
||||
global.KEY_STRING_MAP[? 111] = "Num /"
|
||||
|
||||
global.KEY_STRING_MAP[? 186] = ";"
|
||||
global.KEY_STRING_MAP[? 187] = "="
|
||||
global.KEY_STRING_MAP[? 188] = ","
|
||||
global.KEY_STRING_MAP[? 189] = "-"
|
||||
global.KEY_STRING_MAP[? 190] = "."
|
||||
global.KEY_STRING_MAP[? 191] = "/"
|
||||
global.KEY_STRING_MAP[? 192] = "`" // actually `
|
||||
|
||||
global.KEY_STRING_MAP[? 219] = "["
|
||||
global.KEY_STRING_MAP[? 220] = "\\"
|
||||
global.KEY_STRING_MAP[? 221] = "]"
|
||||
global.KEY_STRING_MAP[? 222] = "'" // actually # but that needs to be escaped
|
||||
|
||||
global.KEY_STRING_MAP[? 223] = "`" // actually ` but that needs to be escaped
|
||||
|
||||
function key_get_index(key) {
|
||||
var k = ds_map_find_first(global.KEY_STRING_MAP);
|
||||
repeat(ds_map_size(global.KEY_STRING_MAP)) {
|
||||
if(global.KEY_STRING_MAP[? k] == key) return k;
|
||||
k = ds_map_find_next(global.KEY_STRING_MAP, k);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region get name
|
||||
function key_get_name(_key, _mod) {
|
||||
if(_key == 0 && _mod == MOD_KEY.none)
|
||||
return "None";
|
||||
|
||||
var dk = "";
|
||||
if(_mod & MOD_KEY.ctrl) dk += "Ctrl+";
|
||||
if(_mod & MOD_KEY.shift) dk += "Shift+";
|
||||
if(_mod & MOD_KEY.alt) dk += "Alt+";
|
||||
|
||||
switch(_key) {
|
||||
case vk_space : dk += "Space"; break;
|
||||
case vk_left : dk += "Left"; break;
|
||||
case vk_right : dk += "Right"; break;
|
||||
case vk_up : dk += "Up"; break;
|
||||
case vk_down : dk += "Down"; break;
|
||||
case vk_backspace : dk += "Backspace"; break;
|
||||
case vk_tab : dk += "Tab"; break;
|
||||
case vk_home : dk += "Home"; break;
|
||||
case vk_end : dk += "End"; break;
|
||||
case vk_delete : dk += "Delete"; break;
|
||||
case vk_insert : dk += "Insert"; break;
|
||||
case vk_pageup : dk += "Page Up"; break;
|
||||
case vk_pagedown : dk += "Page Down"; break;
|
||||
case vk_pause : dk += "Pause"; break;
|
||||
case vk_printscreen : dk += "Printscreen"; break;
|
||||
case vk_f1 : dk += "F1"; break;
|
||||
case vk_f2 : dk += "F2"; break;
|
||||
case vk_f3 : dk += "F3"; break;
|
||||
case vk_f4 : dk += "F4"; break;
|
||||
case vk_f5 : dk += "F5"; break;
|
||||
case vk_f6 : dk += "F6"; break;
|
||||
case vk_f7 : dk += "F7"; break;
|
||||
case vk_f8 : dk += "F8"; break;
|
||||
case vk_f9 : dk += "F9"; break;
|
||||
case vk_f10 : dk += "F10"; break;
|
||||
case vk_f11 : dk += "F11"; break;
|
||||
case vk_f12 : dk += "F12"; break;
|
||||
case -1 : break;
|
||||
default :
|
||||
if(ds_map_exists(global.KEY_STRING_MAP, _key))
|
||||
dk += global.KEY_STRING_MAP[? _key];
|
||||
else
|
||||
dk += ansi_char(_key);
|
||||
break;
|
||||
}
|
||||
|
||||
if(string_char_at(dk, string_length(dk)) == "+")
|
||||
dk = string_copy(dk, 1, string_length(dk) - 1);
|
||||
|
||||
return dk;
|
||||
}
|
||||
#endregion
|
||||
|
||||
enum MOD_KEY {
|
||||
none = 0,
|
||||
ctrl = 1 << 0,
|
||||
shift = 1 << 1,
|
||||
alt = 1 << 2
|
||||
}
|
||||
|
||||
function key_press(_key, _mod = MOD_KEY.none) {
|
||||
if(WIDGET_CURRENT) return false;
|
||||
if(_mod == MOD_KEY.none && _key == 0) return false;
|
||||
|
||||
return keyboard_check_pressed(_key) && HOTKEY_MOD == _mod;
|
||||
}
|
152
#backups/scripts/key_press/key_press.gml.backup1
Normal file
152
#backups/scripts/key_press/key_press.gml.backup1
Normal file
|
@ -0,0 +1,152 @@
|
|||
// 2024-04-21 15:16:08
|
||||
#region key map
|
||||
global.KEY_STRING_MAP = ds_map_create();
|
||||
|
||||
global.KEY_STRING_MAP[? 0] = ""
|
||||
global.KEY_STRING_MAP[? 48] = "0"
|
||||
global.KEY_STRING_MAP[? 49] = "1"
|
||||
global.KEY_STRING_MAP[? 50] = "2"
|
||||
global.KEY_STRING_MAP[? 51] = "3"
|
||||
global.KEY_STRING_MAP[? 52] = "4"
|
||||
global.KEY_STRING_MAP[? 53] = "5"
|
||||
global.KEY_STRING_MAP[? 54] = "6"
|
||||
global.KEY_STRING_MAP[? 55] = "7"
|
||||
global.KEY_STRING_MAP[? 56] = "8"
|
||||
global.KEY_STRING_MAP[? 57] = "9"
|
||||
|
||||
global.KEY_STRING_MAP[? 65] = "A"
|
||||
global.KEY_STRING_MAP[? 66] = "B"
|
||||
global.KEY_STRING_MAP[? 67] = "C"
|
||||
global.KEY_STRING_MAP[? 68] = "D"
|
||||
global.KEY_STRING_MAP[? 69] = "E"
|
||||
global.KEY_STRING_MAP[? 70] = "F"
|
||||
global.KEY_STRING_MAP[? 71] = "G"
|
||||
global.KEY_STRING_MAP[? 72] = "H"
|
||||
global.KEY_STRING_MAP[? 73] = "I"
|
||||
global.KEY_STRING_MAP[? 74] = "J"
|
||||
global.KEY_STRING_MAP[? 75] = "K"
|
||||
global.KEY_STRING_MAP[? 76] = "L"
|
||||
global.KEY_STRING_MAP[? 77] = "M"
|
||||
global.KEY_STRING_MAP[? 78] = "N"
|
||||
global.KEY_STRING_MAP[? 79] = "O"
|
||||
global.KEY_STRING_MAP[? 80] = "P"
|
||||
global.KEY_STRING_MAP[? 81] = "Q"
|
||||
global.KEY_STRING_MAP[? 82] = "R"
|
||||
global.KEY_STRING_MAP[? 83] = "S"
|
||||
global.KEY_STRING_MAP[? 84] = "T"
|
||||
global.KEY_STRING_MAP[? 85] = "U"
|
||||
global.KEY_STRING_MAP[? 86] = "V"
|
||||
global.KEY_STRING_MAP[? 87] = "W"
|
||||
global.KEY_STRING_MAP[? 88] = "X"
|
||||
global.KEY_STRING_MAP[? 89] = "Y"
|
||||
global.KEY_STRING_MAP[? 90] = "Z"
|
||||
|
||||
global.KEY_STRING_MAP[? 96] = "Num 0"
|
||||
global.KEY_STRING_MAP[? 97] = "Num 1"
|
||||
global.KEY_STRING_MAP[? 98] = "Num 2"
|
||||
global.KEY_STRING_MAP[? 99] = "Num 3"
|
||||
global.KEY_STRING_MAP[? 100] = "Num 4"
|
||||
global.KEY_STRING_MAP[? 101] = "Num 5"
|
||||
global.KEY_STRING_MAP[? 102] = "Num 6"
|
||||
global.KEY_STRING_MAP[? 103] = "Num 7"
|
||||
global.KEY_STRING_MAP[? 104] = "Num 8"
|
||||
global.KEY_STRING_MAP[? 105] = "Num 9"
|
||||
|
||||
global.KEY_STRING_MAP[? 106] = "Num *"
|
||||
global.KEY_STRING_MAP[? 107] = "Num +"
|
||||
global.KEY_STRING_MAP[? 109] = "Num -"
|
||||
global.KEY_STRING_MAP[? 110] = "Num ."
|
||||
global.KEY_STRING_MAP[? 111] = "Num /"
|
||||
|
||||
global.KEY_STRING_MAP[? 186] = ";"
|
||||
global.KEY_STRING_MAP[? 187] = "="
|
||||
global.KEY_STRING_MAP[? 188] = ","
|
||||
global.KEY_STRING_MAP[? 189] = "-"
|
||||
global.KEY_STRING_MAP[? 190] = "."
|
||||
global.KEY_STRING_MAP[? 191] = "/"
|
||||
global.KEY_STRING_MAP[? 192] = "`" // actually `
|
||||
|
||||
global.KEY_STRING_MAP[? 219] = "["
|
||||
global.KEY_STRING_MAP[? 220] = "\\"
|
||||
global.KEY_STRING_MAP[? 221] = "]"
|
||||
global.KEY_STRING_MAP[? 222] = "'" // actually # but that needs to be escaped
|
||||
|
||||
global.KEY_STRING_MAP[? 223] = "`" // actually ` but that needs to be escaped
|
||||
|
||||
function key_get_index(key) {
|
||||
var k = ds_map_find_first(global.KEY_STRING_MAP);
|
||||
repeat(ds_map_size(global.KEY_STRING_MAP)) {
|
||||
if(global.KEY_STRING_MAP[? k] == key) return k;
|
||||
k = ds_map_find_next(global.KEY_STRING_MAP, k);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region get name
|
||||
function key_get_name(_key, _mod) {
|
||||
if(_key == 0 && _mod == MOD_KEY.none)
|
||||
return "None";
|
||||
|
||||
var dk = "";
|
||||
if(_mod & MOD_KEY.ctrl) dk += "Ctrl+";
|
||||
if(_mod & MOD_KEY.shift) dk += "Shift+";
|
||||
if(_mod & MOD_KEY.alt) dk += "Alt+";
|
||||
|
||||
switch(_key) {
|
||||
case vk_space : dk += "Space"; break;
|
||||
case vk_left : dk += "Left"; break;
|
||||
case vk_right : dk += "Right"; break;
|
||||
case vk_up : dk += "Up"; break;
|
||||
case vk_down : dk += "Down"; break;
|
||||
case vk_backspace : dk += "Backspace"; break;
|
||||
case vk_tab : dk += "Tab"; break;
|
||||
case vk_home : dk += "Home"; break;
|
||||
case vk_end : dk += "End"; break;
|
||||
case vk_delete : dk += "Delete"; break;
|
||||
case vk_insert : dk += "Insert"; break;
|
||||
case vk_pageup : dk += "Page Up"; break;
|
||||
case vk_pagedown : dk += "Page Down"; break;
|
||||
case vk_pause : dk += "Pause"; break;
|
||||
case vk_printscreen : dk += "Printscreen"; break;
|
||||
case vk_f1 : dk += "F1"; break;
|
||||
case vk_f2 : dk += "F2"; break;
|
||||
case vk_f3 : dk += "F3"; break;
|
||||
case vk_f4 : dk += "F4"; break;
|
||||
case vk_f5 : dk += "F5"; break;
|
||||
case vk_f6 : dk += "F6"; break;
|
||||
case vk_f7 : dk += "F7"; break;
|
||||
case vk_f8 : dk += "F8"; break;
|
||||
case vk_f9 : dk += "F9"; break;
|
||||
case vk_f10 : dk += "F10"; break;
|
||||
case vk_f11 : dk += "F11"; break;
|
||||
case vk_f12 : dk += "F12"; break;
|
||||
case -1 : break;
|
||||
default :
|
||||
if(ds_map_exists(global.KEY_STRING_MAP, _key))
|
||||
dk += global.KEY_STRING_MAP[? _key];
|
||||
else
|
||||
dk += ansi_char(_key);
|
||||
break;
|
||||
}
|
||||
|
||||
if(string_char_at(dk, string_length(dk)) == "+")
|
||||
dk = string_copy(dk, 1, string_length(dk) - 1);
|
||||
|
||||
return dk;
|
||||
}
|
||||
#endregion
|
||||
|
||||
enum MOD_KEY {
|
||||
none = 0,
|
||||
ctrl = 1 << 0,
|
||||
shift = 1 << 1,
|
||||
alt = 1 << 2
|
||||
}
|
||||
|
||||
function key_press(_key, _mod = MOD_KEY.none) {
|
||||
if(WIDGET_CURRENT) return false;
|
||||
if(_mod == MOD_KEY.none && _key == 0) return false;
|
||||
|
||||
return keyboard_check_pressed(_key) && HOTKEY_MOD == _mod;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-21 14:29:32
|
||||
// 2024-04-21 16:39:24
|
||||
function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Canvas";
|
||||
color = COLORS.node_blend_canvas;
|
||||
|
@ -468,21 +468,20 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
function setCanvasSurface(surface, index = preview_index) { INLINE canvas_surface[index] = surface; }
|
||||
|
||||
static storeAction = function() { #region
|
||||
|
||||
var action = recordAction(ACTION_TYPE.custom, function(data) {
|
||||
is_selected = false;
|
||||
if(tool_selection.is_selected) tool_selection.apply();
|
||||
|
||||
var _canvas = surface_clone(getCanvasSurface(data.index));
|
||||
|
||||
if(is_surface(data.surface))
|
||||
setCanvasSurface(surface_clone(data.surface), data.index);
|
||||
setCanvasSurface(data.surface, data.index);
|
||||
surface_store_buffer(data.index);
|
||||
surface_free(data.surface);
|
||||
|
||||
data.surface = _canvas;
|
||||
data.index = preview_index;
|
||||
}, { surface: surface_clone(getCanvasSurface()), tooltip: "Modify canvas", index: preview_index });
|
||||
}, { surface: surface_clone(getCanvasSurface(preview_index)), tooltip: $"Modify canvas {preview_index}", index: preview_index });
|
||||
|
||||
action.clear_action = function(data) { surface_free_safe(data.surface); };
|
||||
// action.clear_action = function(data) { surface_free_safe(data.surface); };
|
||||
} #endregion
|
||||
|
||||
static apply_surfaces = function() { #region
|
||||
|
@ -542,9 +541,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
static tool_pick_color = function(_x, _y) { #region
|
||||
if(tool_selection.is_selected)
|
||||
tool_attribute.pickColor = surface_get_pixel(tool_selection.selection_surface, _x - tool_selection.selection_position[0], _y - tool_selection.selection_position[1]);
|
||||
tool_attribute.pickColor = surface_get_pixel_ext(tool_selection.selection_surface, _x - tool_selection.selection_position[0], _y - tool_selection.selection_position[1]);
|
||||
else
|
||||
tool_attribute.pickColor = surface_get_pixel(getCanvasSurface(), _x, _y);
|
||||
tool_attribute.pickColor = surface_get_pixel_ext(getCanvasSurface(), _x, _y);
|
||||
} #endregion
|
||||
|
||||
function apply_draw_surface(_applyAlpha = true) { #region
|
||||
|
@ -553,9 +552,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
var _dim = attributes.dimension;
|
||||
var _tmp;
|
||||
|
||||
storeAction();
|
||||
|
||||
if(tool_selection.is_selected) {
|
||||
|
||||
var _tmp = surface_create(surface_get_width(tool_selection.selection_mask), surface_get_height(tool_selection.selection_mask));
|
||||
|
||||
var _spx = tool_selection.selection_position[0];
|
||||
|
@ -583,6 +581,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
_can = tool_selection.selection_surface;
|
||||
} else {
|
||||
storeAction();
|
||||
|
||||
var _tmp = surface_create(_dim[0], _dim[1]);
|
||||
|
||||
surface_set_target(_tmp);
|
||||
|
@ -617,7 +617,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
shader_set_f("channels", tool_attribute.channel);
|
||||
shader_set_f("alpha", _applyAlpha? _color_get_alpha(tool_attribute.color) : 1);
|
||||
shader_set_f("mirror", tool_attribute.mirror);
|
||||
shader_set_color("pickColor", tool_attribute.pickColor);
|
||||
shader_set_color("pickColor", tool_attribute.pickColor, _color_get_alpha(tool_attribute.pickColor));
|
||||
|
||||
shader_set_surface("back", _can);
|
||||
shader_set_surface("fore", _tmp);
|
||||
|
@ -874,21 +874,37 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
draw_rectangle(_x0, _y0, _x1 - 1, _y1 - 1, true);
|
||||
draw_set_alpha(1);
|
||||
|
||||
previewing = 1;
|
||||
|
||||
if((_tool == noone || !_tool.mouse_holding) && key_press(ord("V"), MOD_KEY.ctrl)) { #region
|
||||
var _str = json_try_parse(clipboard_get_text(), noone);
|
||||
|
||||
if(is_struct(_str) && struct_has(_str, "buffer")) {
|
||||
var _surf = surface_decode(_str);
|
||||
#region hotkeys
|
||||
if(key_press(ord("C"), MOD_KEY.ctrl) && tool_selection.is_selected) {
|
||||
tool_selection.copySelection();
|
||||
tool_selection.apply();
|
||||
}
|
||||
|
||||
if(key_press(ord("V"), MOD_KEY.ctrl) && (_tool == noone || !_tool.mouse_holding)) {
|
||||
var _str = json_try_parse(clipboard_get_text(), noone);
|
||||
|
||||
if(is_surface(_surf)) {
|
||||
tool_selection.selection_surface = _surf;
|
||||
tool_selection.is_selected = true;
|
||||
tool_selection.selection_position = [ 0, 0 ];
|
||||
if(is_struct(_str) && struct_has(_str, "buffer")) {
|
||||
print(_str);
|
||||
var _surf = surface_decode(_str);
|
||||
|
||||
if(is_surface(_surf)) {
|
||||
tool_selection.selection_surface = _surf;
|
||||
tool_selection.is_selected = true;
|
||||
|
||||
tool_selection.selection_position = [ 0, 0 ];
|
||||
tool_selection.selection_size = [ surface_get_width(_surf), surface_get_height(_surf) ];
|
||||
|
||||
if(key_mod_press(SHIFT)) {
|
||||
var _sel_pos = struct_try_get(_str, "position", [ 0, 0 ]);
|
||||
if(is_array(_sel_pos) && array_length(_sel_pos) == 2)
|
||||
tool_selection.selection_position = _sel_pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} #endregion
|
||||
#endregion
|
||||
|
||||
previewing = 1;
|
||||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-21 14:28:39
|
||||
// 2024-04-21 16:39:12
|
||||
function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Canvas";
|
||||
color = COLORS.node_blend_canvas;
|
||||
|
@ -468,21 +468,20 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
function setCanvasSurface(surface, index = preview_index) { INLINE canvas_surface[index] = surface; }
|
||||
|
||||
static storeAction = function() { #region
|
||||
|
||||
var action = recordAction(ACTION_TYPE.custom, function(data) {
|
||||
is_selected = false;
|
||||
|
||||
|
||||
var _canvas = surface_clone(getCanvasSurface(data.index));
|
||||
|
||||
if(is_surface(data.surface))
|
||||
setCanvasSurface(surface_clone(data.surface), data.index);
|
||||
setCanvasSurface(data.surface, data.index);
|
||||
surface_store_buffer(data.index);
|
||||
surface_free(data.surface);
|
||||
|
||||
data.surface = _canvas;
|
||||
data.index = preview_index;
|
||||
}, { surface: surface_clone(getCanvasSurface()), tooltip: "Modify canvas", index: preview_index });
|
||||
}, { surface: surface_clone(getCanvasSurface(preview_index)), tooltip: $"Modify canvas {preview_index}", index: preview_index });
|
||||
|
||||
action.clear_action = function(data) { surface_free_safe(data.surface); };
|
||||
// action.clear_action = function(data) { surface_free_safe(data.surface); };
|
||||
} #endregion
|
||||
|
||||
static apply_surfaces = function() { #region
|
||||
|
@ -542,9 +541,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
static tool_pick_color = function(_x, _y) { #region
|
||||
if(tool_selection.is_selected)
|
||||
tool_attribute.pickColor = surface_get_pixel(tool_selection.selection_surface, _x - tool_selection.selection_position[0], _y - tool_selection.selection_position[1]);
|
||||
tool_attribute.pickColor = surface_get_pixel_ext(tool_selection.selection_surface, _x - tool_selection.selection_position[0], _y - tool_selection.selection_position[1]);
|
||||
else
|
||||
tool_attribute.pickColor = surface_get_pixel(getCanvasSurface(), _x, _y);
|
||||
tool_attribute.pickColor = surface_get_pixel_ext(getCanvasSurface(), _x, _y);
|
||||
} #endregion
|
||||
|
||||
function apply_draw_surface(_applyAlpha = true) { #region
|
||||
|
@ -553,9 +552,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
var _dim = attributes.dimension;
|
||||
var _tmp;
|
||||
|
||||
storeAction();
|
||||
|
||||
if(tool_selection.is_selected) {
|
||||
|
||||
var _tmp = surface_create(surface_get_width(tool_selection.selection_mask), surface_get_height(tool_selection.selection_mask));
|
||||
|
||||
var _spx = tool_selection.selection_position[0];
|
||||
|
@ -583,6 +581,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
_can = tool_selection.selection_surface;
|
||||
} else {
|
||||
storeAction();
|
||||
|
||||
var _tmp = surface_create(_dim[0], _dim[1]);
|
||||
|
||||
surface_set_target(_tmp);
|
||||
|
@ -617,7 +617,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
shader_set_f("channels", tool_attribute.channel);
|
||||
shader_set_f("alpha", _applyAlpha? _color_get_alpha(tool_attribute.color) : 1);
|
||||
shader_set_f("mirror", tool_attribute.mirror);
|
||||
shader_set_color("pickColor", tool_attribute.pickColor);
|
||||
shader_set_color("pickColor", tool_attribute.pickColor, _color_get_alpha(tool_attribute.pickColor));
|
||||
|
||||
shader_set_surface("back", _can);
|
||||
shader_set_surface("fore", _tmp);
|
||||
|
@ -863,8 +863,6 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
}
|
||||
|
||||
if(_tool) _tool.drawPostOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
|
||||
canvas_draw_point_brush(brush, _x, _y, true);
|
||||
#endregion
|
||||
|
||||
var _x0 = _x;
|
||||
|
@ -876,21 +874,37 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
draw_rectangle(_x0, _y0, _x1 - 1, _y1 - 1, true);
|
||||
draw_set_alpha(1);
|
||||
|
||||
previewing = 1;
|
||||
|
||||
if((_tool == noone || !_tool.mouse_holding) && key_press(ord("V"), MOD_KEY.ctrl)) { #region
|
||||
var _str = json_try_parse(clipboard_get_text(), noone);
|
||||
|
||||
if(is_struct(_str) && struct_has(_str, "buffer")) {
|
||||
var _surf = surface_decode(_str);
|
||||
#region hotkeys
|
||||
if(key_press(ord("C"), MOD_KEY.ctrl) && tool_selection.is_selected) {
|
||||
tool_selection.copySelection();
|
||||
tool_selection.apply();
|
||||
}
|
||||
|
||||
if(key_press(ord("V"), MOD_KEY.ctrl) && (_tool == noone || !_tool.mouse_holding)) {
|
||||
var _str = json_try_parse(clipboard_get_text(), noone);
|
||||
|
||||
if(is_surface(_surf)) {
|
||||
tool_selection.selection_surface = _surf;
|
||||
tool_selection.is_selected = true;
|
||||
tool_selection.selection_position = [ 0, 0 ];
|
||||
if(is_struct(_str) && struct_has(_str, "buffer")) {
|
||||
print(_str);
|
||||
var _surf = surface_decode(_str);
|
||||
|
||||
if(is_surface(_surf)) {
|
||||
tool_selection.selection_surface = _surf;
|
||||
tool_selection.is_selected = true;
|
||||
|
||||
tool_selection.selection_position = [ 0, 0 ];
|
||||
tool_selection.selection_size = [ surface_get_width(_surf), surface_get_height(_surf) ];
|
||||
|
||||
if(key_mod_press(SHIFT)) {
|
||||
var _sel_pos = struct_try_get(_str, "position", [ 0, 0 ]);
|
||||
if(is_array(_sel_pos) && array_length(_sel_pos) == 2)
|
||||
tool_selection.selection_position = _sel_pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} #endregion
|
||||
#endregion
|
||||
|
||||
previewing = 1;
|
||||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-14 12:50:09
|
||||
// 2024-04-21 14:43:36
|
||||
#region funtion calls
|
||||
function __fnInit_Inspector() {
|
||||
__registerFunction("inspector_copy_prop", panel_inspector_copy_prop);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-14 12:24:14
|
||||
// 2024-04-14 12:50:09
|
||||
#region funtion calls
|
||||
function __fnInit_Inspector() {
|
||||
__registerFunction("inspector_copy_prop", panel_inspector_copy_prop);
|
||||
|
|
91
#backups/scripts/pathArrayBox/pathArrayBox.gml.backup0
Normal file
91
#backups/scripts/pathArrayBox/pathArrayBox.gml.backup0
Normal file
|
@ -0,0 +1,91 @@
|
|||
// 2024-04-21 14:36:01
|
||||
function pathArrayBox(_target, _data, _onClick) : widget() constructor {
|
||||
target = _target;
|
||||
data = _data;
|
||||
onClick = _onClick;
|
||||
|
||||
openPath = button(function() {
|
||||
var path = get_open_filenames_compat(data[0], data[1]);
|
||||
key_release();
|
||||
if(path == "") return noone;
|
||||
|
||||
var paths = string_splice(path, "\n");
|
||||
onClick(paths);
|
||||
}, THEME.button_path_icon);
|
||||
|
||||
static trigger = function() {
|
||||
with(dialogCall(o_dialog_image_array_edit, WIN_W / 2, WIN_H / 2))
|
||||
target = other.target;
|
||||
}
|
||||
|
||||
static drawParam = function(params) {
|
||||
setParam(params);
|
||||
|
||||
return draw(params.x, params.y, params.w, params.h, params.data, params.m);
|
||||
}
|
||||
|
||||
static draw = function(_x, _y, _w, _h, _files, _m) {
|
||||
x = _x;
|
||||
y = _y;
|
||||
w = _w;
|
||||
h = _h;
|
||||
|
||||
hovering = false;
|
||||
|
||||
var _bs = min(_h, ui(32));
|
||||
if(_w - _bs > ui(100)) {
|
||||
openPath.setFocusHover(active, hover);
|
||||
openPath.draw(_x + _w - _bs, _y + _h / 2 - _bs / 2, _bs, _bs, _m, THEME.button_hide);
|
||||
_w -= _bs + ui(4);
|
||||
}
|
||||
|
||||
var click = false;
|
||||
draw_sprite_stretched(THEME.textbox, 3, _x, _y, _w, _h);
|
||||
|
||||
if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h)) {
|
||||
hovering = true;
|
||||
draw_sprite_stretched(THEME.textbox, 1, _x, _y, _w, _h);
|
||||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
trigger();
|
||||
click = true;
|
||||
}
|
||||
|
||||
if(mouse_click(mb_left, active))
|
||||
draw_sprite_stretched(THEME.textbox, 2, _x, _y, _w, _h);
|
||||
} else {
|
||||
draw_sprite_stretched(THEME.textbox, 0, _x, _y, _w, _h);
|
||||
if(mouse_press(mb_left)) deactivate();
|
||||
}
|
||||
|
||||
var aa = interactable * 0.25 + 0.75;
|
||||
|
||||
if(!is_array(_files)) _files = [ _files ];
|
||||
var len = array_length(_files);
|
||||
|
||||
var txt = $"({len}) [";
|
||||
for( var i = 0; i < len; i++ )
|
||||
txt += (i? ", " : "") + filename_name_only(_files[i]);
|
||||
txt += "]";
|
||||
|
||||
draw_set_text(font, fa_left, fa_center, COLORS._main_text);
|
||||
if(_h >= line_get_height()) {
|
||||
draw_set_alpha(aa);
|
||||
draw_text_cut(_x + ui(8), _y + _h / 2, txt, _w - ui(16));
|
||||
draw_set_alpha(1);
|
||||
}
|
||||
|
||||
if(WIDGET_CURRENT == self)
|
||||
draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6), COLORS._main_accent, 1);
|
||||
|
||||
resetFocus();
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
static clone = function() { #region
|
||||
var cln = new pathArrayBox(target, data, onClick);
|
||||
|
||||
return cln;
|
||||
} #endregion
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-14 12:50:42
|
||||
// 2024-04-21 15:41:41
|
||||
#region ==================================== DRAW ====================================
|
||||
|
||||
function draw_surface_safe(surface, _x = 0, _y = 0) { #region
|
||||
|
@ -572,10 +572,10 @@
|
|||
return stringify? json_stringify(str) : str;
|
||||
} #endregion
|
||||
|
||||
function surface_decode(struct) { #region
|
||||
var buff = buffer_base64_decode(struct.buffer);
|
||||
function surface_decode(_struct) { #region
|
||||
var buff = buffer_base64_decode(_struct.buffer);
|
||||
var buff = buffer_decompress(buff);
|
||||
return surface_create_from_buffer(struct.width, struct.height, buff);
|
||||
return surface_create_from_buffer(_struct.width, _struct.height, buff);
|
||||
} #endregion
|
||||
|
||||
function surface_format_get_bytes(format) { #region
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-14 12:39:09
|
||||
// 2024-04-21 15:41:27
|
||||
#region ==================================== DRAW ====================================
|
||||
|
||||
function draw_surface_safe(surface, _x = 0, _y = 0) { #region
|
||||
|
@ -572,10 +572,10 @@
|
|||
return stringify? json_stringify(str) : str;
|
||||
} #endregion
|
||||
|
||||
function surface_decode(struct) { #region
|
||||
var buff = buffer_base64_decode(struct.buffer);
|
||||
function surface_decode(_struct) { #region
|
||||
var buff = buffer_base64_decode(_struct.buffer);
|
||||
var buff = buffer_decompress(buff);
|
||||
return surface_create_from_buffer(struct.width, struct.height, buff);
|
||||
return surface_create_from_buffer(_struct.width, _struct.height, buff);
|
||||
} #endregion
|
||||
|
||||
function surface_format_get_bytes(format) { #region
|
||||
|
|
|
@ -129,7 +129,7 @@ event_inherited();
|
|||
if(!_node) return;
|
||||
|
||||
if(is_instanceof(context, Node_Canvas)) {
|
||||
context.nodeTool = new canvas_tool_node(context, _node);
|
||||
context.nodeTool = new canvas_tool_node(context, _node).init();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,6 @@ if(PROJECT.active && !PROJECT.safeMode) { #region
|
|||
} #endregion
|
||||
|
||||
#region hotkey
|
||||
HOTKEY_MOD = 0;
|
||||
if(CTRL == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.ctrl;
|
||||
if(SHIFT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.shift;
|
||||
if(ALT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.alt;
|
||||
|
||||
if(!instance_exists(o_dialog_preference) && !HOTKEY_BLOCK) {
|
||||
if(ds_map_exists(HOTKEYS, "")) {
|
||||
var l = HOTKEYS[? ""];
|
||||
|
|
|
@ -196,44 +196,35 @@ _HOVERING_ELEMENT = noone;
|
|||
#endregion
|
||||
|
||||
#region modifiers
|
||||
if(CTRL == KEYBOARD_STATUS.up)
|
||||
CTRL = KEYBOARD_STATUS.idle;
|
||||
if(SHIFT == KEYBOARD_STATUS.up)
|
||||
SHIFT = KEYBOARD_STATUS.idle;
|
||||
if(ALT == KEYBOARD_STATUS.up)
|
||||
ALT = KEYBOARD_STATUS.idle;
|
||||
if(CTRL == KEYBOARD_STATUS.up) CTRL = KEYBOARD_STATUS.idle;
|
||||
if(SHIFT == KEYBOARD_STATUS.up) SHIFT = KEYBOARD_STATUS.idle;
|
||||
if(ALT == KEYBOARD_STATUS.up) ALT = KEYBOARD_STATUS.idle;
|
||||
|
||||
if(CTRL == KEYBOARD_STATUS.pressing && !keyboard_check(vk_control))
|
||||
if(CTRL == KEYBOARD_STATUS.pressing && !keyboard_check(vk_control))
|
||||
CTRL = KEYBOARD_STATUS.up;
|
||||
|
||||
if(SHIFT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_shift))
|
||||
SHIFT = KEYBOARD_STATUS.up;
|
||||
|
||||
if(ALT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.up;
|
||||
if(ALT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.up;
|
||||
|
||||
if(CTRL == KEYBOARD_STATUS.down)
|
||||
CTRL = KEYBOARD_STATUS.pressing;
|
||||
if(CTRL == KEYBOARD_STATUS.down) CTRL = KEYBOARD_STATUS.pressing;
|
||||
if(SHIFT == KEYBOARD_STATUS.down) SHIFT = KEYBOARD_STATUS.pressing;
|
||||
if(ALT == KEYBOARD_STATUS.down) ALT = KEYBOARD_STATUS.pressing;
|
||||
|
||||
if(SHIFT == KEYBOARD_STATUS.down)
|
||||
SHIFT = KEYBOARD_STATUS.pressing;
|
||||
if(keyboard_check_pressed(vk_control)) CTRL = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_shift)) SHIFT = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_alt)) ALT = KEYBOARD_STATUS.down;
|
||||
|
||||
if(ALT == KEYBOARD_STATUS.down)
|
||||
ALT = KEYBOARD_STATUS.pressing;
|
||||
if(keyboard_check_released(vk_control)) CTRL = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_shift)) SHIFT = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_alt)) ALT = KEYBOARD_STATUS.up;
|
||||
|
||||
if(keyboard_check_pressed(vk_control))
|
||||
CTRL = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_shift))
|
||||
SHIFT = KEYBOARD_STATUS.down;
|
||||
if(keyboard_check_pressed(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.down;
|
||||
|
||||
if(keyboard_check_released(vk_control))
|
||||
CTRL = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_shift))
|
||||
SHIFT = KEYBOARD_STATUS.up;
|
||||
if(keyboard_check_released(vk_alt))
|
||||
ALT = KEYBOARD_STATUS.up;
|
||||
HOTKEY_MOD = 0;
|
||||
if(CTRL == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.ctrl;
|
||||
if(SHIFT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.shift;
|
||||
if(ALT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.alt;
|
||||
#endregion
|
||||
|
||||
#region mouse wrap
|
||||
|
|
|
@ -70,6 +70,8 @@ function canvas_tool_curve_bezier(brush) : canvas_tool() constructor {
|
|||
}
|
||||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
recordAction(ACTION_TYPE.var_modify, self, [ array_clone(anchors), "anchors" ]);
|
||||
|
||||
if(mouse_hovering[0] == noone) {
|
||||
array_push(anchors, [ 0, 0, mouse_cur_x, mouse_cur_y, 0, 0 ]);
|
||||
editing[0] = array_length(anchors) - 1;
|
||||
|
|
|
@ -2,33 +2,17 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
|
||||
self.canvas = canvas;
|
||||
self.node = node;
|
||||
override = true;
|
||||
override = true;
|
||||
|
||||
applySelection = canvas.tool_selection.is_selected;
|
||||
|
||||
destiSurface = applySelection? canvas.tool_selection.selection_surface : canvas.getCanvasSurface();
|
||||
if(!is_surface(destiSurface)) {
|
||||
canvas.nodeTool = noone;
|
||||
return;
|
||||
}
|
||||
|
||||
sw = surface_get_width(destiSurface);
|
||||
sh = surface_get_height(destiSurface);
|
||||
targetSurface = surface_create(sw, sh);
|
||||
maskedSurface = surface_create(sw, sh);
|
||||
|
||||
surface_set_shader(targetSurface, noone);
|
||||
draw_surface_safe(destiSurface);
|
||||
surface_reset_shader();
|
||||
applySelection = false;
|
||||
|
||||
static destroy = function() {
|
||||
if(applySelection) canvas.tool_selection.apply();
|
||||
canvas.nodeTool = noone;
|
||||
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
static cleanUp = function() {
|
||||
|
||||
surface_free_safe(targetSurface);
|
||||
surface_free_safe(maskedSurface);
|
||||
|
||||
|
@ -46,37 +30,56 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
|
||||
}
|
||||
|
||||
nodeObject = node.build(0, 0);
|
||||
|
||||
if(nodeObject == noone || !is_instanceof(nodeObject, Node)) {
|
||||
noti_warning("Not tools only allows a single node.");
|
||||
destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
inputJunction = noone;
|
||||
outputJunction = noone;
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.inputs); i < n; i++ ) {
|
||||
var _in = nodeObject.inputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface || _in.name == "Dimension") {
|
||||
inputJunction = _in;
|
||||
break;
|
||||
function init() {
|
||||
|
||||
applySelection = canvas.tool_selection.is_selected;
|
||||
destiSurface = applySelection? canvas.tool_selection.selection_surface : canvas.getCanvasSurface();
|
||||
if(!is_surface(destiSurface))
|
||||
return noone;
|
||||
|
||||
sw = surface_get_width(destiSurface);
|
||||
sh = surface_get_height(destiSurface);
|
||||
targetSurface = surface_create(sw, sh);
|
||||
maskedSurface = surface_create(sw, sh);
|
||||
|
||||
surface_set_shader(targetSurface, noone);
|
||||
draw_surface_safe(destiSurface);
|
||||
surface_reset_shader();
|
||||
|
||||
nodeObject = node.build(0, 0);
|
||||
|
||||
if(nodeObject == noone || !is_instanceof(nodeObject, Node)) {
|
||||
noti_warning("Not tools only allows a single node.");
|
||||
destroy();
|
||||
return noone;
|
||||
}
|
||||
}
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.outputs); i < n; i++ ) {
|
||||
var _in = nodeObject.outputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface) {
|
||||
outputJunction = _in;
|
||||
break;
|
||||
|
||||
inputJunction = noone;
|
||||
outputJunction = noone;
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.inputs); i < n; i++ ) {
|
||||
var _in = nodeObject.inputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface || _in.name == "Dimension") {
|
||||
inputJunction = _in;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(outputJunction == noone) {
|
||||
noti_warning("Selected node has no surface output.");
|
||||
destroy();
|
||||
return;
|
||||
|
||||
for( var i = 0, n = ds_list_size(nodeObject.outputs); i < n; i++ ) {
|
||||
var _in = nodeObject.outputs[| i];
|
||||
if(_in.type == VALUE_TYPE.surface) {
|
||||
outputJunction = _in;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(outputJunction == noone) {
|
||||
noti_warning("Selected node has no surface output.");
|
||||
destroy();
|
||||
return noone;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -114,7 +117,6 @@ function canvas_tool_node(canvas, node) : canvas_tool() constructor {
|
|||
}
|
||||
|
||||
PANEL_PREVIEW.tool_current = noone;
|
||||
canvas.nodeTool = noone;
|
||||
|
||||
cleanUp();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
mouse_pre_y = 0;
|
||||
|
||||
function createSelection(_mask, sel_x0, sel_y0, sel_w, sel_h) { #region
|
||||
|
||||
if(is_selected)
|
||||
apply();
|
||||
else {
|
||||
|
@ -83,8 +82,7 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
var _nw = _x1 - _x0;
|
||||
var _nh = _y1 - _y0;
|
||||
|
||||
var _selection_surface = surface_create(_nw, _nh);
|
||||
var _selection_mask = surface_create(_nw, _nh);
|
||||
var _selection_mask = surface_create(_nw, _nh);
|
||||
|
||||
surface_set_target(_selection_mask);
|
||||
DRAW_CLEAR
|
||||
|
@ -99,33 +97,8 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
BLEND_NORMAL
|
||||
surface_reset_target();
|
||||
|
||||
surface_set_target(_selection_surface);
|
||||
DRAW_CLEAR
|
||||
draw_surface_safe(_canvas_surface, -_x0, -_y0);
|
||||
|
||||
BLEND_MULTIPLY
|
||||
draw_surface_safe(_selection_mask, 0, 0);
|
||||
BLEND_NORMAL
|
||||
surface_reset_target();
|
||||
|
||||
surface_free(selection_surface);
|
||||
surface_free(selection_mask);
|
||||
|
||||
selection_surface = _selection_surface;
|
||||
selection_mask = _selection_mask;
|
||||
|
||||
node.storeAction();
|
||||
surface_set_target(_canvas_surface);
|
||||
gpu_set_blendmode(bm_subtract);
|
||||
draw_surface_safe(selection_surface, _x0, _y0);
|
||||
gpu_set_blendmode(bm_normal);
|
||||
surface_reset_target();
|
||||
|
||||
node.surface_store_buffer();
|
||||
|
||||
selection_position = [ _x0, _y0 ];
|
||||
selection_size = [ _nw, _nh ];
|
||||
is_selected = true;
|
||||
createNewSelection(_selection_mask, _x0, _y0, _nw, _nh);
|
||||
surface_free(_selection_mask);
|
||||
} #endregion
|
||||
|
||||
function createNewSelection(_mask, sel_x0, sel_y0, sel_w, sel_h) { #region
|
||||
|
@ -163,8 +136,9 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
} #endregion
|
||||
|
||||
function copySelection() { #region
|
||||
var s = surface_encode(selection_surface);
|
||||
clipboard_set_text(s);
|
||||
var s = surface_encode(selection_surface, false);
|
||||
s.position = selection_position;
|
||||
clipboard_set_text(json_stringify(s));
|
||||
} #endregion
|
||||
|
||||
function apply() { #region
|
||||
|
@ -240,7 +214,7 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor {
|
|||
} else if(key_press(vk_escape)) {
|
||||
apply();
|
||||
|
||||
} else if(key_press(ord("C"), MOD_KEY.ctrl)) copySelection();
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
|
|
|
@ -138,16 +138,14 @@
|
|||
|
||||
enum MOD_KEY {
|
||||
none = 0,
|
||||
ctrl = 1,
|
||||
shift = 2,
|
||||
alt = 4
|
||||
ctrl = 1 << 0,
|
||||
shift = 1 << 1,
|
||||
alt = 1 << 2
|
||||
}
|
||||
|
||||
function key_press(_key, _mod = MOD_KEY.none) {
|
||||
if(WIDGET_CURRENT) return false;
|
||||
if(_mod == MOD_KEY.none && _key == 0) return false;
|
||||
|
||||
if(keyboard_check_pressed(_key) && HOTKEY_MOD == _mod)
|
||||
return true;
|
||||
return false;
|
||||
return keyboard_check_pressed(_key) && HOTKEY_MOD == _mod;
|
||||
}
|
|
@ -467,21 +467,20 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
function setCanvasSurface(surface, index = preview_index) { INLINE canvas_surface[index] = surface; }
|
||||
|
||||
static storeAction = function() { #region
|
||||
|
||||
var action = recordAction(ACTION_TYPE.custom, function(data) {
|
||||
is_selected = false;
|
||||
if(tool_selection.is_selected) tool_selection.apply();
|
||||
|
||||
var _canvas = surface_clone(getCanvasSurface(data.index));
|
||||
|
||||
if(is_surface(data.surface))
|
||||
setCanvasSurface(surface_clone(data.surface), data.index);
|
||||
setCanvasSurface(data.surface, data.index);
|
||||
surface_store_buffer(data.index);
|
||||
surface_free(data.surface);
|
||||
|
||||
data.surface = _canvas;
|
||||
data.index = preview_index;
|
||||
}, { surface: surface_clone(getCanvasSurface()), tooltip: "Modify canvas", index: preview_index });
|
||||
}, { surface: surface_clone(getCanvasSurface(preview_index)), tooltip: $"Modify canvas {preview_index}", index: preview_index });
|
||||
|
||||
action.clear_action = function(data) { surface_free_safe(data.surface); };
|
||||
// action.clear_action = function(data) { surface_free_safe(data.surface); };
|
||||
} #endregion
|
||||
|
||||
static apply_surfaces = function() { #region
|
||||
|
@ -541,9 +540,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
static tool_pick_color = function(_x, _y) { #region
|
||||
if(tool_selection.is_selected)
|
||||
tool_attribute.pickColor = surface_get_pixel(tool_selection.selection_surface, _x - tool_selection.selection_position[0], _y - tool_selection.selection_position[1]);
|
||||
tool_attribute.pickColor = surface_get_pixel_ext(tool_selection.selection_surface, _x - tool_selection.selection_position[0], _y - tool_selection.selection_position[1]);
|
||||
else
|
||||
tool_attribute.pickColor = surface_get_pixel(getCanvasSurface(), _x, _y);
|
||||
tool_attribute.pickColor = surface_get_pixel_ext(getCanvasSurface(), _x, _y);
|
||||
} #endregion
|
||||
|
||||
function apply_draw_surface(_applyAlpha = true) { #region
|
||||
|
@ -552,9 +551,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
var _dim = attributes.dimension;
|
||||
var _tmp;
|
||||
|
||||
storeAction();
|
||||
|
||||
if(tool_selection.is_selected) {
|
||||
|
||||
var _tmp = surface_create(surface_get_width(tool_selection.selection_mask), surface_get_height(tool_selection.selection_mask));
|
||||
|
||||
var _spx = tool_selection.selection_position[0];
|
||||
|
@ -582,6 +580,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
_can = tool_selection.selection_surface;
|
||||
} else {
|
||||
storeAction();
|
||||
|
||||
var _tmp = surface_create(_dim[0], _dim[1]);
|
||||
|
||||
surface_set_target(_tmp);
|
||||
|
@ -616,7 +616,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
shader_set_f("channels", tool_attribute.channel);
|
||||
shader_set_f("alpha", _applyAlpha? _color_get_alpha(tool_attribute.color) : 1);
|
||||
shader_set_f("mirror", tool_attribute.mirror);
|
||||
shader_set_color("pickColor", tool_attribute.pickColor);
|
||||
shader_set_color("pickColor", tool_attribute.pickColor, _color_get_alpha(tool_attribute.pickColor));
|
||||
|
||||
shader_set_surface("back", _can);
|
||||
shader_set_surface("fore", _tmp);
|
||||
|
@ -873,21 +873,37 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
draw_rectangle(_x0, _y0, _x1 - 1, _y1 - 1, true);
|
||||
draw_set_alpha(1);
|
||||
|
||||
previewing = 1;
|
||||
|
||||
if((_tool == noone || !_tool.mouse_holding) && key_press(ord("V"), MOD_KEY.ctrl)) { #region
|
||||
var _str = json_try_parse(clipboard_get_text(), noone);
|
||||
|
||||
if(is_struct(_str) && struct_has(_str, "buffer")) {
|
||||
var _surf = surface_decode(_str);
|
||||
#region hotkeys
|
||||
if(key_press(ord("C"), MOD_KEY.ctrl) && tool_selection.is_selected) {
|
||||
tool_selection.copySelection();
|
||||
tool_selection.apply();
|
||||
}
|
||||
|
||||
if(key_press(ord("V"), MOD_KEY.ctrl) && (_tool == noone || !_tool.mouse_holding)) {
|
||||
var _str = json_try_parse(clipboard_get_text(), noone);
|
||||
|
||||
if(is_surface(_surf)) {
|
||||
tool_selection.selection_surface = _surf;
|
||||
tool_selection.is_selected = true;
|
||||
tool_selection.selection_position = [ 0, 0 ];
|
||||
if(is_struct(_str) && struct_has(_str, "buffer")) {
|
||||
print(_str);
|
||||
var _surf = surface_decode(_str);
|
||||
|
||||
if(is_surface(_surf)) {
|
||||
tool_selection.selection_surface = _surf;
|
||||
tool_selection.is_selected = true;
|
||||
|
||||
tool_selection.selection_position = [ 0, 0 ];
|
||||
tool_selection.selection_size = [ surface_get_width(_surf), surface_get_height(_surf) ];
|
||||
|
||||
if(key_mod_press(SHIFT)) {
|
||||
var _sel_pos = struct_try_get(_str, "position", [ 0, 0 ]);
|
||||
if(is_array(_sel_pos) && array_length(_sel_pos) == 2)
|
||||
tool_selection.selection_position = _sel_pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} #endregion
|
||||
#endregion
|
||||
|
||||
previewing = 1;
|
||||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
|
|
|
@ -571,10 +571,10 @@
|
|||
return stringify? json_stringify(str) : str;
|
||||
} #endregion
|
||||
|
||||
function surface_decode(struct) { #region
|
||||
var buff = buffer_base64_decode(struct.buffer);
|
||||
function surface_decode(_struct) { #region
|
||||
var buff = buffer_base64_decode(_struct.buffer);
|
||||
var buff = buffer_decompress(buff);
|
||||
return surface_create_from_buffer(struct.width, struct.height, buff);
|
||||
return surface_create_from_buffer(_struct.width, _struct.height, buff);
|
||||
} #endregion
|
||||
|
||||
function surface_format_get_bytes(format) { #region
|
||||
|
|
Loading…
Reference in a new issue