- [Canvas] Fix holding shift + ctrl disable mouse click.

This commit is contained in:
Tanasart 2024-05-27 08:41:41 +07:00
parent 6bf7646951
commit 0453a3f58a
15 changed files with 663 additions and 621 deletions

View file

@ -31,6 +31,8 @@ event_inherited();
display_list_size = ui(28); display_list_size = ui(28);
display_list_size_to = display_list_size; display_list_size_to = display_list_size;
right_free = !mouse_click(mb_right);
is_global = PANEL_GRAPH.getCurrentContext() == noone; is_global = PANEL_GRAPH.getCurrentContext() == noone;
#region ---- category ---- #region ---- category ----
@ -59,7 +61,6 @@ event_inherited();
node_menu_selecting = node; node_menu_selecting = node;
var fav = array_exists(global.FAV_NODES, node.node); var fav = array_exists(global.FAV_NODES, node.node);
var menu = [ var menu = [
menuItem(fav? __txtx("add_node_remove_favourite", "Remove from favourite") : __txtx("add_node_add_favourite", "Add to favourite"), menuItem(fav? __txtx("add_node_remove_favourite", "Remove from favourite") : __txtx("add_node_add_favourite", "Add to favourite"),
function() { function() {
@ -482,7 +483,7 @@ event_inherited();
draw_sprite_stretched_ext(THEME.node_active, 0, _boxx, yy, grid_size, grid_size, COLORS._main_accent, 1); draw_sprite_stretched_ext(THEME.node_active, 0, _boxx, yy, grid_size, grid_size, COLORS._main_accent, 1);
if(mouse_release(mb_left, sFOCUS)) if(mouse_release(mb_left, sFOCUS))
buildNode(_node); buildNode(_node);
else if(mouse_release(mb_right, sFOCUS)) else if(mouse_release(mb_right, right_free && sFOCUS))
rightClick(_node); rightClick(_node);
} }
@ -610,7 +611,7 @@ event_inherited();
draw_sprite_stretched_ext(THEME.node_active, 0, ui(16), yy, list_width - ui(32), list_height, COLORS._main_accent, 1); draw_sprite_stretched_ext(THEME.node_active, 0, ui(16), yy, list_width - ui(32), list_height, COLORS._main_accent, 1);
if(mouse_release(mb_left, sFOCUS)) if(mouse_release(mb_left, sFOCUS))
buildNode(_node); buildNode(_node);
else if(mouse_release(mb_right, sFOCUS)) else if(mouse_release(mb_right, right_free && sFOCUS))
rightClick(_node); rightClick(_node);
} }
@ -848,7 +849,7 @@ event_inherited();
node_selecting = i; node_selecting = i;
if(mouse_release(mb_left, sFOCUS)) if(mouse_release(mb_left, sFOCUS))
buildNode(_node, _param); buildNode(_node, _param);
else if(struct_has(_node, "node") && mouse_release(mb_right, sFOCUS)) else if(struct_has(_node, "node") && mouse_release(mb_right, right_free && sFOCUS))
rightClick(_node); rightClick(_node);
} }
@ -966,7 +967,7 @@ event_inherited();
node_selecting = i; node_selecting = i;
if(mouse_release(mb_left, sFOCUS)) if(mouse_release(mb_left, sFOCUS))
buildNode(_node, _param); buildNode(_node, _param);
else if(struct_has(_node, "node") && mouse_release(mb_right, sFOCUS)) else if(struct_has(_node, "node") && mouse_release(mb_right, right_free && sFOCUS))
rightClick(_node); rightClick(_node);
} }

View file

@ -88,4 +88,7 @@ if !ready exit;
node_tooltip = noone; node_tooltip = noone;
ADD_NODE_SCROLL = content_pane.scroll_y_to; ADD_NODE_SCROLL = content_pane.scroll_y_to;
if(mouse_release(mb_right))
right_free = true;
#endregion #endregion

View file

@ -9,9 +9,9 @@ event_inherited();
mouse_inside = false; mouse_inside = false;
selecting = -1; selecting = -1;
alarm[0] = -1; alarm[0] = -1;
menu = 1; menu = 1;
hght = ui(36); hght = ui(36);
tooltips = []; tooltips = [];
show_icon = false; show_icon = false;
@ -22,6 +22,8 @@ event_inherited();
setFocus(self.id); setFocus(self.id);
function setMenu(_menu, align = fa_left) { function setMenu(_menu, align = fa_left) {
with(_p_dialog) { if(on_top) continue; other.depth = min(depth - 1, other.depth); }
menu = _menu; menu = _menu;
dialog_x = x; dialog_x = x;
dialog_y = y; dialog_y = y;

View file

@ -179,7 +179,7 @@ function areaBox(_onModify, _unit = noone) : widget() constructor {
var cy = array_safe_get_fast(_data, 1); var cy = array_safe_get_fast(_data, 1);
var sw = array_safe_get_fast(_data, 2); var sw = array_safe_get_fast(_data, 2);
var sh = array_safe_get_fast(_data, 3); var sh = array_safe_get_fast(_data, 3);
var ss = onSurfaceSize(); var ss = unit.mode == VALUE_UNIT.reference? [ 1, 1 ] : onSurfaceSize();
onModify(0, ss[0] - (cx + sw)); onModify(0, ss[0] - (cx + sw));
onModify(1, cy - sh); onModify(1, cy - sh);
@ -188,11 +188,11 @@ function areaBox(_onModify, _unit = noone) : widget() constructor {
break; break;
case AREA_MODE.padding : //padding to two points case AREA_MODE.padding : //padding to two points
var r = array_safe_get_fast(_data, 0); var r = array_safe_get_fast(_data, 0);
var t = array_safe_get_fast(_data, 1); var t = array_safe_get_fast(_data, 1);
var l = array_safe_get_fast(_data, 2); var l = array_safe_get_fast(_data, 2);
var b = array_safe_get_fast(_data, 3); var b = array_safe_get_fast(_data, 3);
var ss = onSurfaceSize(); var ss = unit.mode == VALUE_UNIT.reference? [ 1, 1 ] : onSurfaceSize();
onModify(0, l); onModify(0, l);
onModify(1, t); onModify(1, t);

View file

@ -3,6 +3,9 @@ function buttonAnchor(_onClick) : widget() constructor {
index = 4; index = 4;
click = true; click = true;
center = true;
context = noone;
static drawParam = function(params) { static drawParam = function(params) {
return draw(params.x, params.y, params.w, params.h, params.m); return draw(params.x, params.y, params.w, params.h, params.m);
} }
@ -21,6 +24,8 @@ function buttonAnchor(_onClick) : widget() constructor {
for( var i = -1; i <= 1; i++ ) for( var i = -1; i <= 1; i++ )
for( var j = -1; j <= 1; j++ ) { for( var j = -1; j <= 1; j++ ) {
if(!center && i == 0 && j == 0) continue;
var _bx = cx + j * spacing; var _bx = cx + j * spacing;
var _by = cy + i * spacing; var _by = cy + i * spacing;
var _in = (i + 1) * 3 + (j + 1); var _in = (i + 1) * 3 + (j + 1);

View file

@ -22,7 +22,7 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
mouse_cur_x = round((_mx - _x) / _s - 0.5); mouse_cur_x = round((_mx - _x) / _s - 0.5);
mouse_cur_y = round((_my - _y) / _s - 0.5); mouse_cur_y = round((_my - _y) / _s - 0.5);
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT) && key_mod_press(CTRL)) { if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_presses(SHIFT, CTRL)) {
var aa = point_direction(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y); var aa = point_direction(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
var dd = point_distance(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y); var dd = point_distance(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
var _a = round(aa / 45) * 45; var _a = round(aa / 45) * 45;

View file

@ -37,14 +37,18 @@
function key_mod_press_any() { function key_mod_press_any() {
INLINE INLINE
return CTRL == KEYBOARD_STATUS.pressing || ALT == KEYBOARD_STATUS.pressing || SHIFT == KEYBOARD_STATUS.pressing; return CTRL == KEYBOARD_STATUS.pressing || ALT == KEYBOARD_STATUS.pressing || SHIFT == KEYBOARD_STATUS.pressing;
} }
function key_mod_press(key) { function key_mod_press(key) { INLINE return key == KEYBOARD_STATUS.pressing; }
INLINE function key_mod_presses(keys) {
INLINE
return key == KEYBOARD_STATUS.pressing; switch(argument_count) {
case 1 : return argument[0] == KEYBOARD_STATUS.pressing;
case 2 : return argument[0] == KEYBOARD_STATUS.pressing && argument[1] == KEYBOARD_STATUS.pressing;
case 3 : return argument[0] == KEYBOARD_STATUS.pressing && argument[1] == KEYBOARD_STATUS.pressing && argument[2] == KEYBOARD_STATUS.pressing;
}
return false;
} }
function key_mod_press_index(keyindex) { function key_mod_press_index(keyindex) {

View file

@ -36,10 +36,10 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION; globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION;
LATEST_VERSION = 11700; LATEST_VERSION = 11700;
VERSION = 11711; VERSION = 11712;
SAVE_VERSION = 11690; SAVE_VERSION = 11690;
VERSION_STRING = "1.17.1.1"; VERSION_STRING = "1.17.1.2";
BUILD_NUMBER = 11711; BUILD_NUMBER = 11712;
globalvar HOTKEYS, HOTKEY_CONTEXT; globalvar HOTKEYS, HOTKEY_CONTEXT;
HOTKEYS = ds_map_create(); HOTKEYS = ds_map_create();

View file

@ -899,7 +899,6 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
} }
#endregion #endregion
previewing = 1;
} #endregion } #endregion
static step = function() { #region static step = function() { #region

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,10 @@
function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Outline"; name = "Outline";
filtering_vl = false; attributes.filter = array_create(9, 1);
filter_button = new buttonAnchor(function(ind) { filtering_vl = false;
filter_button = new buttonAnchor(function(ind) {
if(mouse_press(mb_left)) if(mouse_press(mb_left))
filtering_vl = !attributes.filter[ind]; filtering_vl = !attributes.filter[ind];
attributes.filter[ind] = filtering_vl; attributes.filter[ind] = filtering_vl;
@ -70,8 +72,6 @@ function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
attribute_surface_depth(); attribute_surface_depth();
attribute_oversample(); attribute_oversample();
attributes.filter = array_create(9, 1);
static step = function() { #region static step = function() { #region
var _wid = getInputData(1); var _wid = getInputData(1);
var _side = getInputData(5); var _side = getInputData(5);

View file

@ -1,88 +1,3 @@
function nodeValueUnit(_nodeValue) constructor { #region
self._nodeValue = _nodeValue;
mode = VALUE_UNIT.constant;
reference = noone;
triggerButton = button(function() {
mode = !mode;
_nodeValue.cache_value[0] = false;
_nodeValue.unitConvert(mode);
_nodeValue.node.doUpdate();
});
triggerButton.icon_blend = COLORS._main_icon_light;
triggerButton.icon = THEME.unit_ref;
triggerButton.tooltip = new tooltipSelector("Unit", ["Pixel", "Fraction"]);
static setMode = function(type) { #region
if(type == "constant" && mode == VALUE_UNIT.constant) return;
if(type == "relative" && mode == VALUE_UNIT.reference) return;
mode = type == "constant"? VALUE_UNIT.constant : VALUE_UNIT.reference;
_nodeValue.cache_value[0] = false;
_nodeValue.unitConvert(mode);
_nodeValue.node.doUpdate();
} #endregion
static draw = function(_x, _y, _w, _h, _m) { #region
triggerButton.icon_index = mode;
triggerButton.tooltip.index = mode;
triggerButton.draw(_x, _y, _w, _h, _m, THEME.button_hide);
} #endregion
static invApply = function(value, index = 0) { #region
if(mode == VALUE_UNIT.constant)
return value;
if(reference == noone)
return value;
return convertUnit(value, VALUE_UNIT.reference, index);
} #endregion
static apply = function(value, index = 0) { #region
if(mode == VALUE_UNIT.constant) return value;
if(reference == noone) return value;
return convertUnit(value, VALUE_UNIT.constant, index);
} #endregion
static convertUnit = function(value, unitTo, index = 0) { #region
var disp = _nodeValue.display_type;
var base = reference(index);
var inv = unitTo == VALUE_UNIT.reference;
if(!is_array(base) && !is_array(value))
return inv? value / base : value * base;
if(!is_array(base) && is_array(value)) {
var _val = array_create(array_length(value));
for( var i = 0, n = array_length(value); i < n; i++ )
_val[i] = inv? value[i] / base : value[i] * base;
return _val;
}
if(is_array(base) && !is_array(value))
return value;
var _val = array_clone(value);
switch(disp) {
case VALUE_DISPLAY.padding :
case VALUE_DISPLAY.vector :
case VALUE_DISPLAY.vector_range :
for( var i = 0, n = array_length(value); i < n; i++ )
_val[i] = inv? value[i] / base[i % 2] : value[i] * base[i % 2];
return _val;
case VALUE_DISPLAY.area :
for( var i = 0; i < 4; i++ )
_val[i] = inv? value[i] / base[i % 2] : value[i] * base[i % 2];
return _val;
}
return value;
} #endregion
} #endregion
function nodeValue(_name, _node, _connect, _type, _value, _tooltip = "") { return new NodeValue(_name, _node, _connect, _type, _value, _tooltip); } function nodeValue(_name, _node, _connect, _type, _value, _tooltip = "") { return new NodeValue(_name, _node, _connect, _type, _value, _tooltip); }
function nodeValueMap(_name, _node, _junc = noone) { return new NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone).setVisible(false, false).setMapped(_junc); } function nodeValueMap(_name, _node, _junc = noone) { return new NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone).setVisible(false, false).setMapped(_junc); }
function nodeValueGradientRange(_name, _node, _junc = noone) { return new NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 1, 0 ]).setDisplay(VALUE_DISPLAY.gradient_range).setVisible(false, false).setMapped(_junc); } function nodeValueGradientRange(_name, _node, _junc = noone) { return new NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 1, 0 ]).setDisplay(VALUE_DISPLAY.gradient_range).setVisible(false, false).setMapped(_junc); }
@ -346,7 +261,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static resetValue = function() { #region static resetValue = function() { #region
unit.mode = def_unit; unit.mode = def_unit;
setValue(unit.apply(def_val)); setValue(unit.apply(variable_clone(def_val)));
attributes.mapped = false; attributes.mapped = false;
is_modified = false; is_modified = false;
@ -1084,23 +999,22 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(display_type == VALUE_DISPLAY.area) { #region if(display_type == VALUE_DISPLAY.area) { #region
if(struct_has(nodeFrom.display_data, "onSurfaceSize")) { if(struct_has(nodeFrom.display_data, "onSurfaceSize")) {
var surf = nodeFrom.display_data.onSurfaceSize(); var surf = nodeFrom.display_data.onSurfaceSize();
var ww = surf[0];
var hh = surf[1];
var dispType = array_safe_get_fast(value, 5, AREA_MODE.area); var dispType = array_safe_get_fast(value, 5, AREA_MODE.area);
switch(dispType) { switch(dispType) {
case AREA_MODE.area : case AREA_MODE.area :
break; break;
case AREA_MODE.padding : case AREA_MODE.padding :
var ww = unit.mode == VALUE_UNIT.reference? 1 : surf[0];
var hh = unit.mode == VALUE_UNIT.reference? 1 : surf[1];
var cx = (ww - value[0] + value[2]) / 2 var cx = (ww - value[0] + value[2]) / 2
var cy = (value[1] + hh - value[3]) / 2; var cy = (value[1] + hh - value[3]) / 2;
var sw = abs((ww - value[0]) - value[2]) / 2; var sw = abs((ww - value[0]) - value[2]) / 2;
var sh = abs(value[1] - (hh - value[3])) / 2; var sh = abs(value[1] - (hh - value[3])) / 2;
value = [cx, cy, sw, sh, value[4], value[5]]; value = [cx, cy, sw, sh, value[4], value[5]];
break; break;
@ -1448,13 +1362,13 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} #endregion } #endregion
show_val = []; show_val = [];
static showValue = function() { #region static showValue = function() { #region ////showValue
INLINE INLINE
var val = 0; var val = 0;
if(value_from != noone || is_anim || expUse) if(value_from != noone || is_anim || expUse)
val = getValue(CURRENT_FRAME, false, 0, true, true); val = getValue(CURRENT_FRAME, false);
else if(sep_axis) { else if(sep_axis) {
show_val = array_verify(show_val, array_length(animators)); show_val = array_verify(show_val, array_length(animators));

View file

@ -431,4 +431,99 @@ function isGraphable(prop) { #region
return true; return true;
return false; return false;
} #endregion
function nodeValueUnit(_nodeValue) constructor { #region
self._nodeValue = _nodeValue;
mode = VALUE_UNIT.constant;
reference = noone;
triggerButton = button(function() {
mode = !mode;
_nodeValue.cache_value[0] = false;
_nodeValue.unitConvert(mode);
_nodeValue.node.doUpdate();
});
triggerButton.icon_blend = COLORS._main_icon_light;
triggerButton.icon = THEME.unit_ref;
triggerButton.tooltip = new tooltipSelector("Unit", ["Pixel", "Fraction"]);
static setMode = function(type) { #region
if(type == "constant" && mode == VALUE_UNIT.constant) return;
if(type == "relative" && mode == VALUE_UNIT.reference) return;
mode = type == "constant"? VALUE_UNIT.constant : VALUE_UNIT.reference;
_nodeValue.cache_value[0] = false;
_nodeValue.unitConvert(mode);
_nodeValue.node.doUpdate();
} #endregion
static draw = function(_x, _y, _w, _h, _m) { #region
triggerButton.icon_index = mode;
triggerButton.tooltip.index = mode;
triggerButton.draw(_x, _y, _w, _h, _m, THEME.button_hide);
} #endregion
static invApply = function(value, index = 0) { #region
if(mode == VALUE_UNIT.constant)
return value;
if(reference == noone)
return value;
return convertUnit(value, VALUE_UNIT.reference, index);
} #endregion
static apply = function(value, index = 0) { #region
if(mode == VALUE_UNIT.constant) return value;
if(reference == noone) return value;
return convertUnit(value, VALUE_UNIT.constant, index);
} #endregion
static convertUnit = function(value, unitTo, index = 0) { #region
var disp = _nodeValue.display_type;
var base = reference(index);
var inv = unitTo == VALUE_UNIT.reference;
if(!is_array(base)) {
if(inv) base = base == 0? 0 : 1 / base;
if(!is_array(value))
return value * base;
var _val = array_create(array_length(value));
for( var i = 0, n = array_length(value); i < n; i++ )
_val[i] = value[i] * base;
return _val;
} else if(is_array(value)) {
if(inv) {
base = [
base[0] == 0? 0 : 1 / base[0],
base[1] == 0? 0 : 1 / base[1],
];
}
switch(disp) {
case VALUE_DISPLAY.padding :
case VALUE_DISPLAY.vector :
case VALUE_DISPLAY.vector_range :
var _val = array_create(array_length(value));
for( var i = 0, n = array_length(value); i < n; i++ )
_val[i] = value[i] * base[i % 2];
return _val;
case VALUE_DISPLAY.area :
var _val = array_clone(value);
for( var i = 0; i < 4; i++ )
_val[i] = value[i] * base[i % 2];
return _val;
}
}
return value;
} #endregion
} #endregion } #endregion

View file

@ -1217,10 +1217,12 @@ function Panel_Preview() : PanelContent() constructor {
mouse_on_preview = 0; mouse_on_preview = 0;
} }
var _dragging = key_mod_press(CTRL) && !key_mod_press(SHIFT) && !key_mod_press(ALT);
var overlayHover = tool_hovering == noone && !overlay_hovering; var overlayHover = tool_hovering == noone && !overlay_hovering;
overlayHover &= active && isHover; overlayHover &= active && isHover;
overlayHover &= point_in_rectangle(mx, my, (_node.tools != -1) * toolbar_width, toolbar_height, w, h - toolbar_height); overlayHover &= point_in_rectangle(mx, my, (_node.tools != -1) * toolbar_width, toolbar_height, w, h - toolbar_height);
overlayHover &= !key_mod_press(CTRL); overlayHover &= !_dragging;
var params = { w, h, toolbar_height }; var params = { w, h, toolbar_height };
var mouse_free = false; var mouse_free = false;

View file

@ -53,13 +53,23 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s
else if(drag_type == 4) _b = value_snap(drag_sy - (_my - drag_my) / _s, _sny); else if(drag_type == 4) _b = value_snap(drag_sy - (_my - drag_my) / _s, _sny);
if(drag_type) { if(drag_type) {
var _val = array_clone(showValue()); var _svl = showValue();
if(drag_type == 1) _val[0] = _r; var _sval = array_clone(_svl);
else if(drag_type == 2) _val[1] = _t; if(unit.mode == VALUE_UNIT.reference) {
else if(drag_type == 3) _val[2] = _l; var _ref = unit.reference();
else if(drag_type == 4) _val[3] = _b; _sval[0] *= _ref[0];
_sval[1] *= _ref[1];
_sval[2] *= _ref[0];
_sval[3] *= _ref[1];
}
if(setValueInspector(_val)) UNDO_HOLDING = true; if(drag_type == 1) _sval[0] = _r;
else if(drag_type == 2) _sval[1] = _t;
else if(drag_type == 3) _sval[2] = _l;
else if(drag_type == 4) _sval[3] = _b;
if(setValueInspector(_sval))
UNDO_HOLDING = true;
if(mouse_release(mb_left)) { if(mouse_release(mb_left)) {
drag_type = 0; drag_type = 0;