mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-02-04 01:05:16 +01:00
- [Canvas] Fix holding shift + ctrl disable mouse click.
This commit is contained in:
parent
6bf7646951
commit
0453a3f58a
15 changed files with 663 additions and 621 deletions
|
@ -31,6 +31,8 @@ event_inherited();
|
|||
display_list_size = ui(28);
|
||||
display_list_size_to = display_list_size;
|
||||
|
||||
right_free = !mouse_click(mb_right);
|
||||
|
||||
is_global = PANEL_GRAPH.getCurrentContext() == noone;
|
||||
|
||||
#region ---- category ----
|
||||
|
@ -59,7 +61,6 @@ event_inherited();
|
|||
|
||||
node_menu_selecting = node;
|
||||
var fav = array_exists(global.FAV_NODES, node.node);
|
||||
|
||||
var menu = [
|
||||
menuItem(fav? __txtx("add_node_remove_favourite", "Remove from favourite") : __txtx("add_node_add_favourite", "Add to favourite"),
|
||||
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);
|
||||
if(mouse_release(mb_left, sFOCUS))
|
||||
buildNode(_node);
|
||||
else if(mouse_release(mb_right, sFOCUS))
|
||||
else if(mouse_release(mb_right, right_free && sFOCUS))
|
||||
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);
|
||||
if(mouse_release(mb_left, sFOCUS))
|
||||
buildNode(_node);
|
||||
else if(mouse_release(mb_right, sFOCUS))
|
||||
else if(mouse_release(mb_right, right_free && sFOCUS))
|
||||
rightClick(_node);
|
||||
}
|
||||
|
||||
|
@ -848,7 +849,7 @@ event_inherited();
|
|||
node_selecting = i;
|
||||
if(mouse_release(mb_left, sFOCUS))
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -966,7 +967,7 @@ event_inherited();
|
|||
node_selecting = i;
|
||||
if(mouse_release(mb_left, sFOCUS))
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,4 +88,7 @@ if !ready exit;
|
|||
|
||||
node_tooltip = noone;
|
||||
ADD_NODE_SCROLL = content_pane.scroll_y_to;
|
||||
|
||||
if(mouse_release(mb_right))
|
||||
right_free = true;
|
||||
#endregion
|
|
@ -9,9 +9,9 @@ event_inherited();
|
|||
mouse_inside = false;
|
||||
selecting = -1;
|
||||
|
||||
alarm[0] = -1;
|
||||
menu = 1;
|
||||
hght = ui(36);
|
||||
alarm[0] = -1;
|
||||
menu = 1;
|
||||
hght = ui(36);
|
||||
|
||||
tooltips = [];
|
||||
show_icon = false;
|
||||
|
@ -22,6 +22,8 @@ event_inherited();
|
|||
setFocus(self.id);
|
||||
|
||||
function setMenu(_menu, align = fa_left) {
|
||||
with(_p_dialog) { if(on_top) continue; other.depth = min(depth - 1, other.depth); }
|
||||
|
||||
menu = _menu;
|
||||
dialog_x = x;
|
||||
dialog_y = y;
|
||||
|
|
|
@ -179,7 +179,7 @@ function areaBox(_onModify, _unit = noone) : widget() constructor {
|
|||
var cy = array_safe_get_fast(_data, 1);
|
||||
var sw = array_safe_get_fast(_data, 2);
|
||||
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(1, cy - sh);
|
||||
|
@ -188,11 +188,11 @@ function areaBox(_onModify, _unit = noone) : widget() constructor {
|
|||
break;
|
||||
|
||||
case AREA_MODE.padding : //padding to two points
|
||||
var r = array_safe_get_fast(_data, 0);
|
||||
var t = array_safe_get_fast(_data, 1);
|
||||
var l = array_safe_get_fast(_data, 2);
|
||||
var b = array_safe_get_fast(_data, 3);
|
||||
var ss = onSurfaceSize();
|
||||
var r = array_safe_get_fast(_data, 0);
|
||||
var t = array_safe_get_fast(_data, 1);
|
||||
var l = array_safe_get_fast(_data, 2);
|
||||
var b = array_safe_get_fast(_data, 3);
|
||||
var ss = unit.mode == VALUE_UNIT.reference? [ 1, 1 ] : onSurfaceSize();
|
||||
|
||||
onModify(0, l);
|
||||
onModify(1, t);
|
||||
|
|
|
@ -3,6 +3,9 @@ function buttonAnchor(_onClick) : widget() constructor {
|
|||
index = 4;
|
||||
click = true;
|
||||
|
||||
center = true;
|
||||
context = noone;
|
||||
|
||||
static drawParam = function(params) {
|
||||
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 j = -1; j <= 1; j++ ) {
|
||||
if(!center && i == 0 && j == 0) continue;
|
||||
|
||||
var _bx = cx + j * spacing;
|
||||
var _by = cy + i * spacing;
|
||||
var _in = (i + 1) * 3 + (j + 1);
|
||||
|
|
|
@ -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_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 dd = point_distance(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
||||
var _a = round(aa / 45) * 45;
|
||||
|
|
|
@ -37,14 +37,18 @@
|
|||
|
||||
function key_mod_press_any() {
|
||||
INLINE
|
||||
|
||||
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; }
|
||||
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) {
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION;
|
||||
|
||||
LATEST_VERSION = 11700;
|
||||
VERSION = 11711;
|
||||
VERSION = 11712;
|
||||
SAVE_VERSION = 11690;
|
||||
VERSION_STRING = "1.17.1.1";
|
||||
BUILD_NUMBER = 11711;
|
||||
VERSION_STRING = "1.17.1.2";
|
||||
BUILD_NUMBER = 11712;
|
||||
|
||||
globalvar HOTKEYS, HOTKEY_CONTEXT;
|
||||
HOTKEYS = ds_map_create();
|
||||
|
|
|
@ -899,7 +899,6 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
}
|
||||
#endregion
|
||||
|
||||
previewing = 1;
|
||||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,9 @@
|
|||
function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "Outline";
|
||||
|
||||
filtering_vl = false;
|
||||
attributes.filter = array_create(9, 1);
|
||||
filtering_vl = false;
|
||||
|
||||
filter_button = new buttonAnchor(function(ind) {
|
||||
if(mouse_press(mb_left))
|
||||
filtering_vl = !attributes.filter[ind];
|
||||
|
@ -70,8 +72,6 @@ function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
|
|||
attribute_surface_depth();
|
||||
attribute_oversample();
|
||||
|
||||
attributes.filter = array_create(9, 1);
|
||||
|
||||
static step = function() { #region
|
||||
var _wid = getInputData(1);
|
||||
var _side = getInputData(5);
|
||||
|
|
|
@ -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 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); }
|
||||
|
@ -346,7 +261,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
|
||||
static resetValue = function() { #region
|
||||
unit.mode = def_unit;
|
||||
setValue(unit.apply(def_val));
|
||||
setValue(unit.apply(variable_clone(def_val)));
|
||||
attributes.mapped = false;
|
||||
|
||||
is_modified = false;
|
||||
|
@ -1084,11 +999,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
if(display_type == VALUE_DISPLAY.area) { #region
|
||||
|
||||
if(struct_has(nodeFrom.display_data, "onSurfaceSize")) {
|
||||
var surf = nodeFrom.display_data.onSurfaceSize();
|
||||
|
||||
var ww = surf[0];
|
||||
var hh = surf[1];
|
||||
|
||||
var surf = nodeFrom.display_data.onSurfaceSize();
|
||||
var dispType = array_safe_get_fast(value, 5, AREA_MODE.area);
|
||||
|
||||
switch(dispType) {
|
||||
|
@ -1096,6 +1007,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
break;
|
||||
|
||||
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 cy = (value[1] + hh - value[3]) / 2;
|
||||
var sw = abs((ww - value[0]) - value[2]) / 2;
|
||||
|
@ -1448,13 +1362,13 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
} #endregion
|
||||
|
||||
show_val = [];
|
||||
static showValue = function() { #region
|
||||
static showValue = function() { #region ////showValue
|
||||
INLINE
|
||||
|
||||
var val = 0;
|
||||
|
||||
if(value_from != noone || is_anim || expUse)
|
||||
val = getValue(CURRENT_FRAME, false, 0, true, true);
|
||||
val = getValue(CURRENT_FRAME, false);
|
||||
|
||||
else if(sep_axis) {
|
||||
show_val = array_verify(show_val, array_length(animators));
|
||||
|
|
|
@ -432,3 +432,98 @@ function isGraphable(prop) { #region
|
|||
|
||||
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
|
|
@ -1217,10 +1217,12 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
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;
|
||||
overlayHover &= active && isHover;
|
||||
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 mouse_free = false;
|
||||
|
|
|
@ -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);
|
||||
|
||||
if(drag_type) {
|
||||
var _val = array_clone(showValue());
|
||||
if(drag_type == 1) _val[0] = _r;
|
||||
else if(drag_type == 2) _val[1] = _t;
|
||||
else if(drag_type == 3) _val[2] = _l;
|
||||
else if(drag_type == 4) _val[3] = _b;
|
||||
var _svl = showValue();
|
||||
var _sval = array_clone(_svl);
|
||||
if(unit.mode == VALUE_UNIT.reference) {
|
||||
var _ref = unit.reference();
|
||||
_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)) {
|
||||
drag_type = 0;
|
||||
|
|
Loading…
Reference in a new issue