Fix selection sprite clipping on small scale.

This commit is contained in:
Tanasart 2023-11-10 07:50:16 +07:00
parent 19133ca97f
commit 6d3c70c726
6 changed files with 86 additions and 42 deletions

View File

@ -40,6 +40,17 @@ function draw_sprite_stretched_points(spr, ind, _x0, _y0, _x1, _y1, color = c_wh
__draw_sprite_stretched_ext(spr, ind, _xs, _ys, _w, _h, color, alpha);
}
function draw_sprite_stretched_points_clamp(spr, ind, _x0, _y0, _x1, _y1, color = c_white, alpha = 1, _min = 12) {
INLINE
var _xs = round(min(_x0, _x1));
var _ys = round(min(_y0, _y1));
var _w = max(_min, round(max(_x0, _x1) - _xs));
var _h = max(_min, round(max(_y0, _y1) - _ys));
__draw_sprite_stretched_ext(spr, ind, _xs, _ys, _w, _h, color, alpha);
}
function draw_sprite_bbox(spr, ind, _bbox) {
INLINE
if(_bbox == noone) return;

View File

@ -42,7 +42,7 @@ function Action(_type, _object, _data) constructor {
clear_action = noone;
static undo = function() {
static undo = function() { #region
var _n;
switch(type) {
@ -110,9 +110,9 @@ function Action(_type, _object, _data) constructor {
data = obj(data);
break;
}
}
} #endregion
static redo = function() {
static redo = function() { #region
var _n;
switch(type) {
case ACTION_TYPE.var_modify :
@ -179,9 +179,9 @@ function Action(_type, _object, _data) constructor {
data = obj(data);
break;
}
}
} #endregion
static toString = function() {
static toString = function() { #region
var ss = "";
switch(type) {
case ACTION_TYPE.var_modify :
@ -237,15 +237,15 @@ function Action(_type, _object, _data) constructor {
break;
}
return ss;
}
} #endregion
static destroy = function() {
static destroy = function() { #region
if(clear_action == noone) return;
clear_action(data);
}
} #endregion
}
function recordAction(_type, _object, _data = -1) {
function recordAction(_type, _object, _data = -1) { #region
if(IS_UNDOING) return;
if(LOADING) return;
if(UNDO_HOLDING) return;
@ -261,9 +261,9 @@ function recordAction(_type, _object, _data = -1) {
PANEL_MENU.undoUpdate();
return act;
}
} #endregion
function UNDO() {
function UNDO() { #region
if(ds_stack_empty(UNDO_STACK)) return;
if(instance_exists(_p_dialog_undo_block)) return;
@ -276,9 +276,9 @@ function UNDO() {
ds_stack_push(REDO_STACK, actions);
PANEL_MENU.undoUpdate();
}
} #endregion
function REDO() {
function REDO() { #region
if(ds_stack_empty(REDO_STACK)) return;
if(instance_exists(_p_dialog_undo_block)) return;
@ -291,4 +291,4 @@ function REDO() {
ds_stack_push(UNDO_STACK, actions);
PANEL_MENU.undoUpdate();
}
} #endregion

View File

@ -430,21 +430,6 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { #regio
ds_list_add(d3d, "Points");
addNodeObject(d3d, "Point Affector", s_node_3d_point_affector, "Node_3D_Point_Affector", [1, Node_3D_Point_Affector]).setVersion(11570);
//ds_list_add(d3d, "Legacy"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////
//addNodeObject(d3d, "3D Plane", s_node_3d_plane, "__Node_3D_Plane", [1, __Node_3D_Plane],, "Put 2D image on a plane in 3D space.").isDeprecated();
//addNodeObject(d3d, "3D Cube", s_node_3d_cube, "__Node_3D_Cube", [1, __Node_3D_Cube]).isDeprecated();
//addNodeObject(d3d, "3D Cylinder", s_node_3d_cylinder, "__Node_3D_Cylinder", [1, __Node_3D_Cylinder]).isDeprecated();
//addNodeObject(d3d, "3D Sphere", s_node_3d_sphere, "__Node_3D_Sphere", [1, __Node_3D_Sphere]).setVersion(1090).isDeprecated();
//addNodeObject(d3d, "3D Cone", s_node_3d_cone, "__Node_3D_Cone", [1, __Node_3D_Cone]).setVersion(1090).isDeprecated();
//addNodeObject(d3d, "3D Extrude", s_node_3d_extrude, "__Node_3D_Extrude", [1, __Node_3D_Extrude],, "Extrude 2D image into 3D object.").isDeprecated();
//addNodeObject(d3d, "3D Transform", s_node_3d_transform, "__Node_3D_Transform", [1, __Node_3D_Transform]).setVersion(1080).isDeprecated();
//addNodeObject(d3d, "3D Combine", s_node_3d_obj_combine, "__Node_3D_Combine", [1, __Node_3D_Combine],, "Combine multiple 3D object to a single scene,").setVersion(1080).isDeprecated();
//addNodeObject(d3d, "3D Repeat", s_node_3d_array, "__Node_3D_Repeat", [1, __Node_3D_Repeat], ["3d array"], "Repeat 3D object multiple times.").setVersion(1080).isDeprecated();
//addNodeObject(d3d, "3D Displace", s_node_3d_displace, "__Node_3D_Displace", [1, __Node_3D_Displace]).setVersion(1143).isDeprecated();
//addNodeObject(d3d, "3D Export", s_node_3d_export, "__Node_3D_Export", [1, __Node_3D_Export]).setVersion(1143).isDeprecated();
#endregion
var generator = ds_list_create(); #region

View File

@ -1632,7 +1632,7 @@ function Panel_Animation() : PanelContent() constructor {
#endregion
if(keyframe_boxing) { #region
draw_sprite_stretched_points(THEME.ui_selection, 0, keyframe_box_sx, keyframe_box_sy, msx, msy, COLORS._main_accent);
draw_sprite_stretched_points_clamp(THEME.ui_selection, 0, keyframe_box_sx, keyframe_box_sy, msx, msy, COLORS._main_accent);
if(mouse_release(mb_left))
keyframe_boxing = false;

View File

@ -1056,7 +1056,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
#region draw selection frame
if(nodes_select_drag) {
if(point_distance(nodes_select_mx, nodes_select_my, mx, my) > 16) {
draw_sprite_stretched_points(THEME.ui_selection, 0, nodes_select_mx, nodes_select_my, mx, my, COLORS._main_accent);
draw_sprite_stretched_points_clamp(THEME.ui_selection, 0, nodes_select_mx, nodes_select_my, mx, my, COLORS._main_accent);
for(var i = 0; i < ds_list_size(nodes_list); i++) {
var _node = nodes_list[| i];

View File

@ -59,6 +59,11 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
syntax_highlight = true;
undo_current_text = "";
undo_delay = 0;
undo_stack = ds_stack_create();
redo_stack = ds_stack_create();
_cl = -1;
static activate = function() { #region
@ -76,6 +81,7 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
keyboard_lastkey = -1;
cut_line();
undo_delay = 10;
} #endregion
static deactivate = function() { #region
@ -85,9 +91,7 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
UNDO_HOLDING = false;
} #endregion
static isCodeFormat = function() {
return format == TEXT_AREA_FORMAT.codeLUA || format == TEXT_AREA_FORMAT.codeHLSL
}
static isCodeFormat = function() { INLINE return format == TEXT_AREA_FORMAT.codeLUA || format == TEXT_AREA_FORMAT.codeHLSL; }
static onModified = function() { #region
if(!isCodeFormat()) return;
@ -355,11 +359,36 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
static editText = function() { #region
var _input_text_pre = _input_text;
var modified = false;
var undoed = true;
#region text editor
if(key_mod_press(CTRL) && keyboard_check_pressed(ord("A"))) {
cursor_select = 0;
cursor = string_length(_input_text);
} else if(key_mod_press(CTRL) && keyboard_check_pressed(ord("Z"))) {
if(!ds_stack_empty(undo_stack)) {
ds_stack_push(redo_stack, _input_text);
_input_text = ds_stack_pop(undo_stack);
undo_current_text = _input_text;
cut_line();
move_cursor(0);
modified = true;
undoed = false;
undo_delay = 10;
}
} else if(key_mod_press(CTRL) && key_mod_press(SHIFT) && keyboard_check_pressed(ord("Z"))) {
if(!ds_stack_empty(redo_stack)) {
ds_stack_push(undo_stack, _input_text);
_input_text = ds_stack_pop(redo_stack);
undo_current_text = _input_text;
cut_line();
move_cursor(0);
modified = true;
undoed = false;
undo_delay = 10;
}
} else if(key_mod_press(CTRL) && (keyboard_check_pressed(ord("C")) || keyboard_check_pressed(ord("X")))) {
if(cursor_select != -1) {
var minc = min(cursor, cursor_select);
@ -392,7 +421,8 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
cut_line();
cursor = minc + string_length(ch);
}
modified = true;
modified = true;
undo_delay = 10;
} else if(KEYBOARD_PRESSED == vk_backspace) {
if(cursor_select == -1) {
var str_before, str_after;
@ -403,6 +433,7 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
var ch = string_char_at(_input_text, _c);
if(breakCharacter(ch)) break;
_c--;
undo_delay++;
}
str_before = string_copy(_input_text, 1, _c);
@ -411,9 +442,10 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
} else {
str_before = string_copy(_input_text, 1, cursor - 1);
str_after = string_copy(_input_text, cursor + 1, string_length(_input_text) - cursor);
undo_delay++;
}
_input_text = str_before + str_after;
_input_text = str_before + str_after;
cut_line();
} else {
var minc = min(cursor, cursor_select);
@ -425,9 +457,10 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
cursor = minc + 1;
_input_text = str_before + str_after;
cut_line();
undo_delay += maxc - minc;
}
cursor_select = -1;
cursor_select = -1;
move_cursor(-1);
modified = true;
} else if(KEYBOARD_PRESSED == vk_delete || (keyboard_check_pressed(ord("X")) && key_mod_press(CTRL) && cursor_select != -1)) {
@ -437,6 +470,7 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
_input_text = str_before + str_after;
cut_line();
undo_delay++;
} else {
var minc = min(cursor, cursor_select);
var maxc = max(cursor, cursor_select);
@ -445,10 +479,12 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
var str_after = string_copy(_input_text, maxc + 1, string_length(_input_text) - maxc);
cursor = minc;
_input_text = str_before + str_after;
_input_text = str_before + str_after;
cut_line();
undo_delay += maxc - minc;
}
cursor_select = -1;
cursor_select = -1;
modified = true;
} else if(KEYBOARD_STRING != "" && KEYBOARD_STRING != "\b" && KEYBOARD_STRING != "\r") {
var ch = KEYBOARD_STRING;
@ -458,10 +494,10 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
var str_after = string_copy(_input_text, cursor + 1, string_length(_input_text) - cursor);
_input_text = str_before + ch + str_after;
//print($"{str_before} + {ch} + {str_after}");
cut_line();
move_cursor(string_length(ch));
undo_delay++;
} else {
var minc = min(cursor, cursor_select);
var maxc = max(cursor, cursor_select);
@ -472,9 +508,12 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
_input_text = str_before + ch + str_after;
cut_line();
cursor = minc + string_length(ch);
undo_delay += maxc - minc;
}
cursor_select = -1;
if(ch == " ") undo_delay = 10;
cursor_select = -1;
modified = true;
}
}
@ -483,7 +522,16 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
keyboard_lastkey = -1;
#endregion
if(modified) onModified();
if(modified) {
if(undoed && undo_delay >= 10) {
ds_stack_push(undo_stack, undo_current_text);
ds_stack_clear(redo_stack);
undo_current_text = _input_text_pre;
undo_delay = 0;
}
onModified();
}
if(auto_update && keyboard_check_pressed(vk_anykey))
apply();