preview, crop

This commit is contained in:
Tanasart 2024-06-04 11:48:23 +07:00
parent 35cf8d023c
commit c8c6247907
7 changed files with 528 additions and 316 deletions

Binary file not shown.

View file

@ -280,6 +280,12 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
var widH = widExtend? editBoxH : 0;
var mbRight = true;
var un = jun.unit;
if(un.reference != noone) {
un.triggerButton.icon_index = un.mode;
un.triggerButton.tooltip.index = un.mode;
}
if(jun.expUse) { #region expression editor
var expValid = jun.expTree != noone && jun.expTree.validate();
jun.express_edit.boxColor = expValid? COLORS._main_value_positive : COLORS._main_value_negative;
@ -291,12 +297,6 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
var wd_h = jun.express_edit.draw(editBoxX, editBoxY, editBoxW, editBoxH, jun.expression, _m);
widH = wd_h - (TEXTBOX_HEIGHT * !widExtend);
var un = jun.unit;
if(un.reference != noone) {
un.triggerButton.icon_index = un.mode;
un.triggerButton.tooltip.index = un.mode;
}
#endregion
} else if(wid && jun.display_type != VALUE_DISPLAY.none) { #region edit widget

View file

@ -11,15 +11,59 @@ function Node_Crop(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[| 2] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 2;
inputs[| 3] = nodeValue("Aspect Ratio", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "None", "Manual", "1:1", "3:2", "4:3", "16:9" ]);
inputs[| 4] = nodeValue("Ratio", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 5] = nodeValue("Center", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ .5, .5 ])
.setDisplay(VALUE_DISPLAY.vector)
.setUnitRef(function(index) { return getDimension(index); }, VALUE_UNIT.reference);
inputs[| 6] = nodeValue("Width", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 8 );
inputs[| 7] = nodeValue("Fit Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Manual", "Width", "Height", "Minimum" ]);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [ 2,
["Effect", false], 0, 1,
["Surface", true], 0,
["Crop", false], 3, 4, 1, 7, 5, 6,
]
attribute_surface_depth();
tools = [ new NodeTool("Draw crop area", THEME.crop_tool, "Node_Crop") ]
tool_drag = new NodeTool("Draw crop area", THEME.crop_tool, "Node_Crop");
tool_fitw = new NodeTool("Fit Width", THEME.crop_fit_width)
.setToolFn(function() {
var _dim = getDimension(preview_index);
var _asp = current_data[3];
var _rat = current_data[4];
var _cen = current_data[5];
var _ratio = getRatio(_asp, _rat);
inputs[| 5].setValue([ _dim[0] / 2, _cen[1] ]);
inputs[| 6].setValue(_dim[0]);
});
tool_fith = new NodeTool("Fit Height", THEME.crop_fit_height)
.setToolFn(function() {
var _dim = getDimension(preview_index);
var _asp = current_data[3];
var _rat = current_data[4];
var _cen = current_data[5];
var _ratio = getRatio(_asp, _rat);
inputs[| 5].setValue([ _cen[0], _dim[1] / 2 ]);
inputs[| 6].setValue(_dim[1] * _ratio);
});
tools = [ tool_drag ];
drag_side = noone;
drag_mx = 0;
@ -28,13 +72,39 @@ function Node_Crop(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
static getPreviewValues = function() { return getInputData(0); }
static getRatio = function(_asp, _rat) {
switch(_asp) {
case 1 : return _rat[0] / _rat[1]; break;
case 2 : return 1 / 1; break;
case 3 : return 3 / 2; break;
case 4 : return 4 / 3; break;
case 5 : return 16 / 9; break;
}
return 1;
}
static step = function() {
var _asp = getInputData(3);
var _fit = getInputData(7);
inputs[| 1].setVisible(_asp == 0);
inputs[| 4].setVisible(_asp == 1);
inputs[| 5].setVisible(_asp > 0 && _fit == 0);
inputs[| 6].setVisible(_asp > 0 && _fit == 0);
}
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, params) { #region
PROCESSOR_OVERLAY_CHECK
var _inSurf = current_data[0];
var _spRaw = current_data[1];
var _asp = current_data[3];
var _fit = current_data[7];
var _splice;
if(_asp == 0) {
tools = [ tool_drag ];
for( var i = 0, n = array_length(_spRaw); i < n; i++ )
_splice[i] = round(_spRaw[i]);
@ -158,6 +228,7 @@ function Node_Crop(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
draw_set_color(merge_color(c_white, COLORS._main_accent, 0.5));
if(hover) {
if(drag_side == 4 || point_in_circle(_mx, _my, sp_l, sp_t, 12)) {
draw_line_width(sp_l, 0, sp_l, params.h, 4);
draw_line_width(0, sp_t, params.w, sp_t, 4);
@ -197,6 +268,7 @@ function Node_Crop(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
draw_line_width(sp_l - 1, sp_b, sp_r + 1, sp_b, 4);
_hov = 8;
}
}
if(_hov != 4) draw_sprite_colored(THEME.anchor_selector, 0, sp_l, sp_t);
if(_hov != 5) draw_sprite_colored(THEME.anchor_selector, 0, sp_r, sp_t);
@ -211,13 +283,84 @@ function Node_Crop(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
drag_sv = _hov < 4? _splice[_hov] : _splice;
}
}
} else if(_fit == 0) {
tools = [ tool_fitw, tool_fith ];
var _rat = current_data[4];
var _cent = current_data[5];
var _width = abs(current_data[6]);
var _ratio = getRatio(_asp, _rat);
var _height = ceil(_width / _ratio);
var _x0 = round(_cent[0] - _width / 2);
var _y0 = round(_cent[1] - _height / 2);
var _px0 = _x + _x0 * _s;
var _py0 = _y + _y0 * _s;
var _px1 = _px0 + _width * _s;
var _py1 = _py0 + _height * _s;
var _out = getSingleValue(0,, true);
draw_surface_ext_safe(_out, _px0, _py0, _s, _s);
draw_set_color(COLORS._main_accent);
draw_rectangle(_px0, _py0, _px1, _py1, true);
var _px = _x + _cent[0] * _s;
var _py = _y + _cent[1] * _s;
var a = inputs[| 5].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); active &= !a;
var a = inputs[| 6].drawOverlay(hover, active, _px, _py, _s / 2, _mx, _my, _snx, _sny); active &= !a;
} else {
var _idim = surface_get_dimension(_inSurf);
var _out = getSingleValue(0,, true);
var _odim = surface_get_dimension(_out);
var _x0 = _idim[0] / 2 - _odim[0] / 2;
var _y0 = _idim[1] / 2 - _odim[1] / 2;
var _px0 = _x + _x0 * _s;
var _py0 = _y + _y0 * _s;
var _px1 = _px0 + _odim[0] * _s;
var _py1 = _py0 + _odim[1] * _s;
draw_surface_ext_safe(_out, _px0, _py0, _s, _s);
draw_set_color(COLORS._main_accent);
draw_rectangle(_px0, _py0, _px1, _py1, true);
}
} #endregion
static onValueUpdate = function(index) {
if(index != 3) return;
var _dim = getDimension(0);
var _asp = inputs[| 3].getValue();
var _rat = inputs[| 4].getValue();
var _ratio = getRatio(_asp, _rat);
inputs[| 5].setValue([ _dim[0] / 2, _dim[1] / 2 ]);
inputs[| 6].setValue(min(_dim[0], _dim[1] * _ratio));
}
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
var _inSurf = _data[0];
var _crop = _data[1];
var _asp = _data[3];
var _rat = _data[4];
var _cent = _data[5];
var _width = abs(_data[6]);
var _fit = _data[7];
var _sdim = surface_get_dimension(_inSurf);
var _dim = [ _sdim[0] - _crop[0] - _crop[2], _sdim[1] - _crop[1] - _crop[3] ];
if(_asp == 0) {
var _dim = [ _sdim[0] - _crop[0] - _crop[2],
_sdim[1] - _crop[1] - _crop[3] ];
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1]);
@ -225,6 +368,47 @@ function Node_Crop(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
draw_surface_safe(_inSurf, -_crop[2], -_crop[1]);
surface_reset_shader();
} else if(_fit == 0) {
var _ratio = getRatio(_asp, _rat);
var _height = ceil(_width / _ratio);
var _x0 = round(_cent[0] - _width / 2);
var _y0 = round(_cent[1] - _height / 2);
_outSurf = surface_verify(_outSurf, _width, _height);
surface_set_shader(_outSurf, noone);
draw_surface_safe(_inSurf, -_x0, -_y0);
surface_reset_shader();
} else {
var _ratio = getRatio(_asp, _rat);
var _w = 1, _h = 1, _x0, _y0;
if(_fit == 1) {
_w = _sdim[0];
_h = _w * _ratio;
} else if(_fit == 2) {
_h = _sdim[1];
_w = _h / _ratio;
} else if(_fit == 3) {
_w = min(_sdim[0], _sdim[1] * _ratio);
_h = _w * _ratio;
}
var _x0 = round(_sdim[0] / 2 - _w / 2);
var _y0 = round(_sdim[1] / 2 - _h / 2);
_outSurf = surface_verify(_outSurf, _w, _h);
surface_set_shader(_outSurf, noone);
draw_surface_safe(_inSurf, -_x0, -_y0);
surface_reset_shader();
}
return _outSurf;
} #endregion
}

View file

@ -149,6 +149,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
drag_my = 0;
drag_sx = 0;
drag_sy = 0;
drag_rx = 0;
drag_ry = 0;
color = -1;
color_display = 0;
@ -299,6 +301,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static setUnitRef = function(ref, mode = VALUE_UNIT.constant) { #region
express_edit.side_button = unit.triggerButton;
if(is_instanceof(editWidget, textBox))
editWidget.side_button = unit.triggerButton;
unit.reference = ref;
unit.mode = mode;
def_unit = mode;
@ -1445,11 +1450,11 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
}
} #endregion
static setValueInspector = function(val = 0, index = noone) { #region
static setValueInspector = function(_val = 0, index = noone) { #region
INLINE
var res = false;
val = unit.invApply(val);
var val = unit.invApply(_val);
if(PANEL_INSPECTOR && PANEL_INSPECTOR.inspectGroup == 1) {
var ind = self.index;

View file

@ -521,6 +521,10 @@ function nodeValueUnit(_nodeValue) constructor { #region
return _val;
}
} else {
base = array_safe_get(base, 0, 1);
if(inv) base = base == 0? 0 : 1 / base;
return value * base;
}
return value;

View file

@ -1135,138 +1135,6 @@ function Panel_Preview() : PanelContent() constructor {
} #endregion
function drawPreviewOverlay() { #region
#region view controller
if(show_view_control) {
var _side = show_view_control == 1? 1 : -1;
var _view_x = show_view_control == 1?
tool_side_draw_l * toolbar_width + ui(8) :
w - tool_side_draw_r * toolbar_width - ui(8);
var _view_y = topbar_height + ui(8);
var _hab = pHOVER && tool_hovering == noone && !view_pan_tool && !view_zoom_tool;
view_hovering = false;
if(d3_active) {
var d3_view_wr = ui(32);
var _d3x = _view_x + d3_view_wr * _side;
var _d3y = _view_y + d3_view_wr;
var _hv = false;
if(_hab && point_in_circle(mx, my, _d3x, _d3y, d3_view_wr)) {
_hv = true;
view_hovering = true;
if(mouse_press(mb_left, pFOCUS)) {
canvas_drag_key = mb_left;
d3_camPanning = true;
d3_camPan_mx = mx;
d3_camPan_my = my;
view_pan_tool = true;
}
}
if(view_pan_tool)
_hv = true;
draw_circle_ui(_d3x, _d3y, d3_view_wr, _hv? 0 : 0.02, COLORS._main_icon, 0.3);
var _qview = new BBMOD_Quaternion().FromEuler(d3_view_camera.focus_angle_y, -d3_view_camera.focus_angle_x, 0);
var _as = [
new BBMOD_Vec3(-1, 0, 0),
new BBMOD_Vec3(0, 0, 1),
new BBMOD_Vec3(0, -1, 0),
];
for(var i = 0; i < 3; i++) {
_as[i] = _qview.Rotate(_as[i]);
draw_set_color(COLORS.axis[i]);
draw_line_round(_d3x, _d3y, _d3x + _as[i].X * (d3_view_wr * 0.75), _d3y + _as[i].Y * (d3_view_wr * 0.75), 3);
}
var d3_view_wz = ui(16);
var _d3x = _view_x + (d3_view_wr * 2 + ui(20)) * _side;
var _d3y = _view_y + d3_view_wz;
var _hv = false;
if(_hab && point_in_circle(mx, my, _d3x, _d3y, d3_view_wz)) {
_hv = true;
view_hovering = true;
if(mouse_press(mb_left, pFOCUS)) {
canvas_drag_key = mb_left;
canvas_zooming = true;
canvas_zoom_m = my;
view_zoom_tool = true;
}
}
if(view_zoom_tool)
_hv = true;
draw_circle_ui(_d3x, _d3y, d3_view_wz, _hv? 0 : 0.04, COLORS._main_icon, 0.3);
draw_sprite_ext(THEME.view_zoom, 0, _d3x, _d3y, 1, 1, 0, view_zoom_tool? COLORS._main_accent : COLORS._main_icon, 1);
} else {
var d3_view_wz = ui(16);
var _d3x = _view_x + d3_view_wz * _side;
var _d3y = _view_y + d3_view_wz;
var _hv = false;
if(_hab && point_in_circle(mx, my, _d3x, _d3y, d3_view_wz)) {
_hv = true;
view_hovering = true;
if(mouse_press(mb_left, pFOCUS)) {
canvas_drag_key = mb_left;
canvas_dragging = true;
canvas_drag_mx = mx;
canvas_drag_my = my;
canvas_drag_sx = canvas_x;
canvas_drag_sy = canvas_y;
view_pan_tool = true;
}
}
if(view_pan_tool)
_hv = true;
draw_circle_ui(_d3x, _d3y, d3_view_wz, _hv? 0 : 0.04, COLORS._main_icon, 0.3);
draw_sprite_ext(THEME.view_pan, 0, _d3x, _d3y, 1, 1, 0, view_pan_tool? COLORS._main_accent : COLORS._main_icon, 1);
_d3x += (d3_view_wz + ui(4) + d3_view_wz) * _side;
_d3y = _view_y + d3_view_wz;
_hv = false;
if(_hab && point_in_circle(mx, my, _d3x, _d3y, d3_view_wz)) {
_hv = true;
view_hovering = true;
if(mouse_press(mb_left, pFOCUS)) {
canvas_drag_key = mb_left;
canvas_zooming = true;
canvas_zoom_mx = w / 2;
canvas_zoom_my = h / 2;
canvas_zoom_m = my;
canvas_zoom_s = canvas_s;
view_zoom_tool = true;
}
}
if(view_zoom_tool)
_hv = true;
draw_circle_ui(_d3x, _d3y, d3_view_wz, _hv? 0 : 0.04, COLORS._main_icon, 0.3);
draw_sprite_ext(THEME.view_zoom, 0, _d3x, _d3y, 1, 1, 0, view_zoom_tool? COLORS._main_accent : COLORS._main_icon, 1);
}
}
#endregion
right_menu_y = toolbar_height - ui(4);
if(show_view_control == 2) {
if(d3_active) right_menu_y += ui(72);
@ -1406,10 +1274,141 @@ function Panel_Preview() : PanelContent() constructor {
preview_x_max = max(preview_x_max - ui(100), 0);
} #endregion
function drawViewController() {
if(!show_view_control) return;
var _side = show_view_control == 1? 1 : -1;
var _view_x = show_view_control == 1?
tool_side_draw_l * toolbar_width + ui(8) :
w - tool_side_draw_r * toolbar_width - ui(8);
var _view_y = topbar_height + ui(8);
var _hab = pHOVER && tool_hovering == noone && !view_pan_tool && !view_zoom_tool;
view_hovering = false;
if(d3_active) {
var d3_view_wr = ui(32);
var _d3x = _view_x + d3_view_wr * _side;
var _d3y = _view_y + d3_view_wr;
var _hv = false;
if(_hab && point_in_circle(mx, my, _d3x, _d3y, d3_view_wr)) {
_hv = true;
view_hovering = true;
if(mouse_press(mb_left, pFOCUS)) {
canvas_drag_key = mb_left;
d3_camPanning = true;
d3_camPan_mx = mx;
d3_camPan_my = my;
view_pan_tool = true;
}
}
if(view_pan_tool)
_hv = true;
draw_circle_ui(_d3x, _d3y, d3_view_wr, _hv? 0 : 0.02, COLORS._main_icon, 0.3);
var _qview = new BBMOD_Quaternion().FromEuler(d3_view_camera.focus_angle_y, -d3_view_camera.focus_angle_x, 0);
var _as = [
new BBMOD_Vec3(-1, 0, 0),
new BBMOD_Vec3(0, 0, 1),
new BBMOD_Vec3(0, -1, 0),
];
for(var i = 0; i < 3; i++) {
_as[i] = _qview.Rotate(_as[i]);
draw_set_color(COLORS.axis[i]);
draw_line_round(_d3x, _d3y, _d3x + _as[i].X * (d3_view_wr * 0.75), _d3y + _as[i].Y * (d3_view_wr * 0.75), 3);
}
var d3_view_wz = ui(16);
var _d3x = _view_x + (d3_view_wr * 2 + ui(20)) * _side;
var _d3y = _view_y + d3_view_wz;
var _hv = false;
if(_hab && point_in_circle(mx, my, _d3x, _d3y, d3_view_wz)) {
_hv = true;
view_hovering = true;
if(mouse_press(mb_left, pFOCUS)) {
canvas_drag_key = mb_left;
canvas_zooming = true;
canvas_zoom_m = my;
view_zoom_tool = true;
}
}
if(view_zoom_tool)
_hv = true;
draw_circle_ui(_d3x, _d3y, d3_view_wz, _hv? 0 : 0.04, COLORS._main_icon, 0.3);
draw_sprite_ext(THEME.view_zoom, 0, _d3x, _d3y, 1, 1, 0, view_zoom_tool? COLORS._main_accent : COLORS._main_icon, 1);
} else {
var d3_view_wz = ui(16);
var _d3x = _view_x + d3_view_wz * _side;
var _d3y = _view_y + d3_view_wz;
var _hv = false;
if(_hab && point_in_circle(mx, my, _d3x, _d3y, d3_view_wz)) {
_hv = true;
view_hovering = true;
if(mouse_press(mb_left, pFOCUS)) {
canvas_drag_key = mb_left;
canvas_dragging = true;
canvas_drag_mx = mx;
canvas_drag_my = my;
canvas_drag_sx = canvas_x;
canvas_drag_sy = canvas_y;
view_pan_tool = true;
}
}
if(view_pan_tool)
_hv = true;
draw_circle_ui(_d3x, _d3y, d3_view_wz, _hv? 0 : 0.04, COLORS._main_icon, 0.3);
draw_sprite_ext(THEME.view_pan, 0, _d3x, _d3y, 1, 1, 0, view_pan_tool? COLORS._main_accent : COLORS._main_icon, 1);
_d3x += (d3_view_wz + ui(4) + d3_view_wz) * _side;
_d3y = _view_y + d3_view_wz;
_hv = false;
if(_hab && point_in_circle(mx, my, _d3x, _d3y, d3_view_wz)) {
_hv = true;
view_hovering = true;
if(mouse_press(mb_left, pFOCUS)) {
canvas_drag_key = mb_left;
canvas_zooming = true;
canvas_zoom_mx = w / 2;
canvas_zoom_my = h / 2;
canvas_zoom_m = my;
canvas_zoom_s = canvas_s;
view_zoom_tool = true;
}
}
if(view_zoom_tool)
_hv = true;
draw_circle_ui(_d3x, _d3y, d3_view_wz, _hv? 0 : 0.04, COLORS._main_icon, 0.3);
draw_sprite_ext(THEME.view_zoom, 0, _d3x, _d3y, 1, 1, 0, view_zoom_tool? COLORS._main_accent : COLORS._main_icon, 1);
}
}
function drawNodeTools(active, _node) { #region
var _mx = mx;
var _my = my;
var isHover = pHOVER && mouse_on_preview == 1;
var overHover = pHOVER && mouse_on_preview == 1;
var tool_size = ui(32);
var cx = canvas_x + _node.preview_x * canvas_s;
@ -1420,17 +1419,19 @@ function Panel_Preview() : PanelContent() constructor {
tool_side_draw_r = _node.rightTools != -1;
if(_node.tools != -1 && point_in_rectangle(_mx, _my, 0, 0, toolbar_width, h)) {
isHover = false;
overHover = false;
mouse_on_preview = 0;
}
var _dragging = key_mod_press(CTRL) && !key_mod_press(SHIFT) && !key_mod_press(ALT);
overHover &= !view_hovering;
overHover &= tool_hovering == noone && !overlay_hovering;
overHover &= !(view_pan_tool || view_zoom_tool);
overHover &= point_in_rectangle(mx, my, (_node.tools != -1) * toolbar_width, toolbar_height, w, h - toolbar_height);
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 &= !_dragging;
overlayHover &= !view_hovering;
var overActive = active && overHover;
var _dragging = key_mod_press(CTRL) && !key_mod_press(SHIFT) && !key_mod_press(ALT);
overActive &= !_dragging;
var params = { w, h, toolbar_height };
var mouse_free = false;
@ -1441,7 +1442,7 @@ function Panel_Preview() : PanelContent() constructor {
_sny = d3_tool_snap_rotation;
}
mouse_free = _node.drawOverlay3D(overlayHover, d3_scene, _mx, _my, _snx, _sny, params);
mouse_free = _node.drawOverlay3D(overActive, d3_scene, _mx, _my, _snx, _sny, params);
} else {
if(key_mod_press(CTRL)) {
_snx = PROJECT.previewGrid.show? PROJECT.previewGrid.size[0] : 1;
@ -1451,7 +1452,7 @@ function Panel_Preview() : PanelContent() constructor {
_sny = PROJECT.previewGrid.size[1];
}
mouse_free = _node.drawOverlay(isHover, overlayHover, cx, cy, canvas_s, _mx, _my, _snx, _sny, params);
mouse_free = _node.drawOverlay(overHover, overActive, cx, cy, canvas_s, _mx, _my, _snx, _sny, params);
}
#region node overlay
@ -1942,6 +1943,8 @@ function Panel_Preview() : PanelContent() constructor {
} else
tool_current = noone;
drawViewController();
if(mouse_on_preview && mouse_press(mb_right, pFOCUS) && !key_mod_press(SHIFT)) {
menuCall("preview_context_menu",,, [
menuItem(__txtx("panel_graph_preview_window", "Send to preview window"), function() { create_preview_window(getNodePreview()); }, noone, ["Preview", "Preview window"]),

View file

@ -15,8 +15,22 @@ function preview_overlay_vector(interact, active, _x, _y, _s, _mx, _my, _snx, _s
if(drag_type) {
_index = 1;
var _nx = value_snap((drag_sx + (_mx - drag_mx) - _x) / _s, _snx);
var _ny = value_snap((drag_sy + (_my - drag_my) - _y) / _s, _sny);
var _nx = (drag_sx + (_mx - drag_mx) - _x) / _s;
var _ny = (drag_sy + (_my - drag_my) - _y) / _s;
_nx = value_snap(_nx, _snx);
_ny = value_snap(_ny, _sny);
if(key_mod_press(SHIFT)) {
if(abs(_mx - drag_mx) > abs(_my - drag_my))
_ny = drag_ry;
else
_nx = drag_rx;
draw_set_color(COLORS._main_accent);
draw_line(drag_sx, drag_sy, _x + _nx * _s, _y + _ny * _s);
}
if(key_mod_press(CTRL)) {
_val[0] = round(_nx);
_val[1] = round(_ny);
@ -44,6 +58,8 @@ function preview_overlay_vector(interact, active, _x, _y, _s, _mx, _my, _snx, _s
drag_my = _my;
drag_sx = _ax;
drag_sy = _ay;
drag_rx = __ax;
drag_ry = __ay;
}
}