2022-11-14 03:16:15 +01:00
|
|
|
function Panel_Preview() : PanelContent() constructor {
|
2023-06-04 18:28:29 +02:00
|
|
|
title = __txt("Preview");
|
2022-01-13 05:24:03 +01:00
|
|
|
context_str = "Preview";
|
2023-03-21 03:01:53 +01:00
|
|
|
icon = THEME.panel_preview;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
last_focus = noone;
|
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
#region ---- canvas control & sample ----
|
|
|
|
function initSize() {
|
|
|
|
canvas_x = w / 2;
|
|
|
|
canvas_y = h / 2;
|
|
|
|
}
|
|
|
|
run_in(1, function() { initSize() });
|
2022-11-14 03:16:15 +01:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
canvas_x = 0;
|
|
|
|
canvas_y = 0;
|
|
|
|
canvas_s = ui(1);
|
|
|
|
canvas_w = ui(128);
|
|
|
|
canvas_h = ui(128);
|
|
|
|
canvas_a = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
canvas_bg = -1;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
do_fullView = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
canvas_hover = true;
|
|
|
|
canvas_dragging_key = false;
|
|
|
|
canvas_dragging = false;
|
|
|
|
canvas_drag_key = 0;
|
|
|
|
canvas_drag_mx = 0;
|
|
|
|
canvas_drag_my = 0;
|
|
|
|
canvas_drag_sx = 0;
|
|
|
|
canvas_drag_sy = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
canvas_zooming_key = false;
|
|
|
|
canvas_zooming = false;
|
|
|
|
canvas_zoom_mx = 0;
|
|
|
|
canvas_zoom_my = 0;
|
|
|
|
canvas_zoom_m = 0;
|
|
|
|
canvas_zoom_s = 0;
|
|
|
|
|
|
|
|
sample_color = noone;
|
|
|
|
sample_x = noone;
|
|
|
|
sample_y = noone;
|
2023-07-30 13:56:22 +02:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
#endregion
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
#region ---- preview ----
|
|
|
|
preview_node = [ noone, noone ];
|
|
|
|
preview_surface = [ 0, 0 ];
|
|
|
|
tile_surface = surface_create(1, 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
preview_x = 0;
|
|
|
|
preview_x_to = 0;
|
|
|
|
preview_x_max = 0;
|
|
|
|
preview_sequence = [ 0, 0 ];
|
|
|
|
_preview_sequence = preview_sequence;
|
|
|
|
preview_rate = 10;
|
|
|
|
|
2023-10-04 07:21:45 +02:00
|
|
|
right_menu_y = 8;
|
|
|
|
mouse_on_preview = 0;
|
|
|
|
_mouse_on_preview = 0;
|
2023-08-14 19:22:04 +02:00
|
|
|
|
|
|
|
resetViewOnDoubleClick = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
splitView = 0;
|
|
|
|
splitPosition = 0.5;
|
|
|
|
splitSelection = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
splitViewDragging = false;
|
|
|
|
splitViewStart = 0;
|
|
|
|
splitViewMouse = 0;
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
tileMode = 0;
|
2023-08-17 16:56:54 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
bg_color = COLORS.panel_bg_clear;
|
2023-08-14 19:22:04 +02:00
|
|
|
#endregion
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
#region ---- tool ----
|
|
|
|
tool_x = 0;
|
|
|
|
tool_x_to = 0;
|
|
|
|
tool_x_max = 0;
|
|
|
|
tool_current = noone;
|
2023-08-23 20:01:09 +02:00
|
|
|
|
2023-10-18 14:58:55 +02:00
|
|
|
tool_hovering = false;
|
|
|
|
tool_side_drawing = false;
|
|
|
|
overlay_hovering = false;
|
|
|
|
|
2023-08-23 20:01:09 +02:00
|
|
|
sbChannel = new scrollBox([], function(index) { #region
|
|
|
|
var node = getNodePreview();
|
|
|
|
if(node == noone) return;
|
|
|
|
|
|
|
|
node.preview_channel = array_safe_get(sbChannelIndex, index);
|
|
|
|
}); #endregion
|
2023-09-05 20:31:36 +02:00
|
|
|
sbChannelIndex = [];
|
|
|
|
sbChannel.font = f_p1;
|
2023-08-23 20:01:09 +02:00
|
|
|
sbChannel.align = fa_left;
|
2023-08-14 19:22:04 +02:00
|
|
|
#endregion
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
#region ---- 3d ----
|
|
|
|
d3_active = false;
|
2023-08-17 16:56:54 +02:00
|
|
|
_d3_active = false;
|
|
|
|
d3_active_transition = 0;
|
2023-08-23 20:01:09 +02:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
d3_surface = noone;
|
2023-08-23 20:01:09 +02:00
|
|
|
d3_surface_normal = noone;
|
|
|
|
d3_surface_depth = noone;
|
|
|
|
d3_surface_outline = noone;
|
2023-08-28 12:56:00 +02:00
|
|
|
d3_surface_bg = noone;
|
2023-08-23 20:01:09 +02:00
|
|
|
d3_preview_channel = 0;
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-09-05 20:31:36 +02:00
|
|
|
d3_deferData = noone;
|
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
global.SKY_SPHERE = new __3dUVSphere(0.5, 16, 8, true);
|
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
#region camera
|
|
|
|
d3_view_camera = new __3dCamera();
|
|
|
|
d3_camW = 1;
|
|
|
|
d3_camH = 1;
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-23 20:01:09 +02:00
|
|
|
d3_view_camera.setFocusAngle(135, 45, 4);
|
2023-08-22 11:51:45 +02:00
|
|
|
d3_camLerp = false;
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
d3_camTarget = new __vec3();
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
d3_camPanning = false;
|
|
|
|
d3_camPan_mx = 0;
|
|
|
|
d3_camPan_my = 0;
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
d3_zoom_speed = 0.2;
|
|
|
|
d3_pan_speed = 2;
|
|
|
|
#endregion
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
#region scene
|
2023-12-20 03:54:26 +01:00
|
|
|
d3_scene = new __3dScene(d3_view_camera, "Preview panel");
|
2023-08-22 11:51:45 +02:00
|
|
|
d3_scene.lightAmbient = $404040;
|
2023-10-05 06:29:20 +02:00
|
|
|
d3_scene.cull_mode = cull_counterclockwise;
|
|
|
|
d3_scene_preview = d3_scene;
|
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
d3_scene_light_enabled = true;
|
|
|
|
|
|
|
|
d3_scene_light0 = new __3dLightDirectional();
|
2023-08-30 16:40:45 +02:00
|
|
|
d3_scene_light0.transform.position.set(-1, -2, 3);
|
2023-08-22 11:51:45 +02:00
|
|
|
d3_scene_light0.color = $FFFFFF;
|
|
|
|
d3_scene_light0.shadow_active = false;
|
2023-08-23 20:01:09 +02:00
|
|
|
d3_scene_light0.shadow_map_scale = 4;
|
2023-08-22 11:51:45 +02:00
|
|
|
|
|
|
|
d3_scene_light1 = new __3dLightDirectional();
|
2023-08-30 16:40:45 +02:00
|
|
|
d3_scene_light1.transform.position.set(1, 2, -3);
|
2023-08-22 11:51:45 +02:00
|
|
|
d3_scene_light1.color = $505050;
|
|
|
|
#endregion
|
2023-08-16 20:16:31 +02:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
#region tool
|
|
|
|
d3_tool_snap = false;
|
|
|
|
d3_tool_snap_position = 1;
|
|
|
|
d3_tool_snap_rotation = 15;
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region shadow map
|
|
|
|
|
|
|
|
#endregion
|
2023-08-23 20:01:09 +02:00
|
|
|
|
|
|
|
#region view channel
|
|
|
|
d3ChannelNames = [ "Rendered", "Normal", "Depth" ];
|
|
|
|
d3Channel = new scrollBox(d3ChannelNames, function(index) { d3_preview_channel = index; });
|
|
|
|
d3Channel.align = fa_left;
|
|
|
|
#endregion
|
2023-08-14 19:22:04 +02:00
|
|
|
#endregion
|
2022-12-10 05:06:01 +01:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
tb_framerate = new textBox(TEXTBOX_INPUT.number, function(val) { preview_rate = real(val); });
|
|
|
|
|
|
|
|
#region ++++ toolbars & actions ++++
|
2023-08-22 11:51:45 +02:00
|
|
|
topbar_height = ui(32);
|
2022-11-03 11:44:49 +01:00
|
|
|
toolbar_height = ui(40);
|
2022-08-30 07:36:37 +02:00
|
|
|
toolbars = [
|
|
|
|
[
|
2022-11-18 03:20:31 +01:00
|
|
|
THEME.icon_reset_when_preview,
|
2022-08-30 07:36:37 +02:00
|
|
|
function() { return resetViewOnDoubleClick; },
|
2023-06-04 18:28:29 +02:00
|
|
|
function() { return resetViewOnDoubleClick? __txtx("panel_preview_center_canvas_on_preview", "Center canvas on preview") :
|
|
|
|
__txtx("panel_preview_keep_canvas_on_preview", "Keep canvas on preview"); },
|
2022-08-30 07:36:37 +02:00
|
|
|
function() { resetViewOnDoubleClick = !resetViewOnDoubleClick; }
|
|
|
|
],
|
|
|
|
[
|
2022-11-18 03:20:31 +01:00
|
|
|
THEME.icon_split_view,
|
2022-08-30 07:36:37 +02:00
|
|
|
function() { return splitView; },
|
|
|
|
function() {
|
|
|
|
switch(splitView) {
|
2023-06-04 18:28:29 +02:00
|
|
|
case 0 : return __txtx("panel_preview_split_view_off", "Split view off");
|
|
|
|
case 1 : return __txtx("panel_preview_horizontal_split_view", "Horizontal split view");
|
|
|
|
case 2 : return __txtx("panel_preview_vertical_split_view", "Vertical split view");
|
2022-08-30 07:36:37 +02:00
|
|
|
}
|
2023-06-04 18:28:29 +02:00
|
|
|
return __txtx("panel_preview_split_view", "Split view");
|
2022-08-30 07:36:37 +02:00
|
|
|
},
|
|
|
|
function() { splitView = (splitView + 1) % 3; }
|
|
|
|
],
|
2022-12-10 05:06:01 +01:00
|
|
|
[
|
|
|
|
THEME.icon_tile_view,
|
2023-02-19 02:13:19 +01:00
|
|
|
function() { var t = [3, 0, 1, 2]; return array_safe_get(t, tileMode); },
|
2022-12-10 05:06:01 +01:00
|
|
|
function() {
|
|
|
|
switch(tileMode) {
|
2023-06-04 18:28:29 +02:00
|
|
|
case 0 : return __txtx("panel_preview_tile_off", "Tile off");
|
|
|
|
case 1 : return __txtx("panel_preview_tile_horizontal", "Tile horizontal");
|
|
|
|
case 2 : return __txtx("panel_preview_tile_vertical", "Tile vertical");
|
|
|
|
case 3 : return __txtx("panel_preview_tile_both", "Tile both");
|
2022-12-10 05:06:01 +01:00
|
|
|
}
|
2023-06-04 18:28:29 +02:00
|
|
|
return __txtx("panel_preview_tile_mode", "Tile mode");
|
2022-12-10 05:06:01 +01:00
|
|
|
},
|
2023-02-19 02:13:19 +01:00
|
|
|
function(data) {
|
2023-05-03 21:42:17 +02:00
|
|
|
menuCall("preview_tile_menu", data.x + ui(28), data.y + ui(28), [
|
2023-08-01 19:21:51 +02:00
|
|
|
menuItem(__txtx("panel_preview_tile_off", "Tile off"), function() { tileMode = 0; }),
|
2023-06-04 18:28:29 +02:00
|
|
|
menuItem(__txtx("panel_preview_tile_horizontal", "Tile horizontal"), function() { tileMode = 1; }),
|
|
|
|
menuItem(__txtx("panel_preview_tile_vertical", "Tile vertical"), function() { tileMode = 2; }),
|
|
|
|
menuItem(__txtx("panel_preview_tile_both", "Tile both"), function() { tileMode = 3; }),
|
2023-02-19 02:13:19 +01:00
|
|
|
]);
|
|
|
|
}
|
2022-12-10 05:06:01 +01:00
|
|
|
],
|
2022-09-21 06:09:40 +02:00
|
|
|
[
|
2022-11-18 03:20:31 +01:00
|
|
|
THEME.icon_grid_setting,
|
2022-09-21 06:09:40 +02:00
|
|
|
function() { return 0; },
|
2023-06-04 18:28:29 +02:00
|
|
|
function() { return __txtx("grid_title", "Grid setting") },
|
2022-09-21 06:09:40 +02:00
|
|
|
function(param) {
|
2023-08-29 14:33:44 +02:00
|
|
|
var dia = dialogPanelCall(new Panel_Preview_Grid_Setting(), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
|
2022-09-21 06:09:40 +02:00
|
|
|
}
|
|
|
|
],
|
2023-07-08 20:29:23 +02:00
|
|
|
[
|
|
|
|
THEME.onion_skin,
|
|
|
|
function() { return 0; },
|
|
|
|
function() { return __txt("Onion Skin") },
|
|
|
|
function(param) {
|
2023-08-29 14:33:44 +02:00
|
|
|
var dia = dialogPanelCall(new Panel_Preview_Onion_Setting(), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
|
2023-07-08 20:29:23 +02:00
|
|
|
}
|
|
|
|
],
|
2022-08-30 07:36:37 +02:00
|
|
|
];
|
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
toolbars_3d = [
|
|
|
|
[
|
|
|
|
THEME.d3d_preview_settings,
|
|
|
|
function() { return 0; },
|
|
|
|
function() { return __txt("3D Preview Settings") },
|
|
|
|
function(param) {
|
2023-08-29 14:33:44 +02:00
|
|
|
var dia = dialogPanelCall(new Panel_Preview_3D_Setting(self), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
|
2023-08-22 11:51:45 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
THEME.d3d_snap_settings,
|
|
|
|
function() { return 0; },
|
|
|
|
function() { return __txt("3D Snap Settings") },
|
|
|
|
function(param) {
|
2023-08-29 14:33:44 +02:00
|
|
|
var dia = dialogPanelCall(new Panel_Preview_Snap_Setting(self), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
|
2023-08-22 11:51:45 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
actions = [
|
2022-09-21 06:09:40 +02:00
|
|
|
[
|
2022-11-18 03:20:31 +01:00
|
|
|
THEME.icon_preview_export,
|
2023-06-04 18:28:29 +02:00
|
|
|
__txtx("panel_preview_export_canvas", "Export canvas"),
|
2022-09-21 06:09:40 +02:00
|
|
|
function() { saveCurrentFrame(); }
|
|
|
|
],
|
2023-05-29 13:06:05 +02:00
|
|
|
[
|
|
|
|
THEME.icon_center_canvas,
|
2023-06-04 18:28:29 +02:00
|
|
|
__txtx("panel_preview_center_canvas", "Center canvas"),
|
2023-05-29 13:06:05 +02:00
|
|
|
function() { fullView(); }
|
|
|
|
],
|
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
]
|
2023-08-13 13:10:20 +02:00
|
|
|
#endregion
|
2022-01-16 05:17:35 +01:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
#region ++++ hotkey ++++
|
2023-03-21 03:01:53 +01:00
|
|
|
addHotkey("Preview", "Focus content", "F", MOD_KEY.none, function() { PANEL_PREVIEW.fullView(); });
|
|
|
|
addHotkey("Preview", "Save current frame", "S", MOD_KEY.shift, function() { PANEL_PREVIEW.saveCurrentFrame(); });
|
|
|
|
addHotkey("Preview", "Save all current frame", -1, MOD_KEY.none, function() { PANEL_PREVIEW.saveAllCurrentFrames(); });
|
2023-06-13 14:42:06 +02:00
|
|
|
addHotkey("Preview", "Preview window", "P", MOD_KEY.ctrl, function() { create_preview_window(PANEL_PREVIEW.getNodePreview()); });
|
2023-08-01 19:21:51 +02:00
|
|
|
addHotkey("Preview", "Toggle grid", "G", MOD_KEY.ctrl, function() { PROJECT.previewGrid.show = !PROJECT.previewGrid.show; });
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-11-15 14:42:53 +01:00
|
|
|
addHotkey("Preview", "Pan", "", MOD_KEY.ctrl, function() { PANEL_PREVIEW.canvas_dragging_key = true; });
|
|
|
|
addHotkey("Preview", "Zoom", "", MOD_KEY.alt | MOD_KEY.ctrl, function() { PANEL_PREVIEW.canvas_zooming_key = true; });
|
2023-08-13 13:10:20 +02:00
|
|
|
#endregion
|
2023-04-21 19:08:10 +02:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function setNodePreview(node) { #region
|
2022-08-30 07:36:37 +02:00
|
|
|
if(resetViewOnDoubleClick)
|
|
|
|
do_fullView = true;
|
|
|
|
|
2023-10-09 16:07:33 +02:00
|
|
|
if(is_instanceof(node, Node) && node.getPreviewingNode != noone)
|
|
|
|
node = node.getPreviewingNode();
|
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
preview_node[splitView? splitSelection : 0] = node;
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function removeNodePreview(node) { #region
|
2023-07-17 19:58:33 +02:00
|
|
|
if(preview_node[0] == node) preview_node[0] = noone;
|
|
|
|
if(preview_node[1] == node) preview_node[1] = noone;
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2023-07-17 19:58:33 +02:00
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
function resetNodePreview() { preview_node = [ noone, noone ]; }
|
2023-07-17 19:58:33 +02:00
|
|
|
|
|
|
|
function getNodePreview() { return preview_node[splitView? splitSelection : 0]; }
|
|
|
|
function getNodePreviewSurface() { return preview_surface[splitView? splitSelection : 0]; }
|
|
|
|
function getNodePreviewSequence() { return preview_sequence[splitView? splitSelection : 0]; }
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function getPreviewData() { #region
|
2023-08-31 18:49:57 +02:00
|
|
|
preview_surface = [ noone, noone ];
|
|
|
|
preview_sequence = [ noone, noone ];
|
2022-08-30 07:36:37 +02:00
|
|
|
|
|
|
|
for( var i = 0; i < 2; i++ ) {
|
|
|
|
var node = preview_node[i];
|
|
|
|
|
|
|
|
if(node == noone) continue;
|
2023-07-28 19:41:57 +02:00
|
|
|
if(!node.active) {
|
2023-08-01 19:21:51 +02:00
|
|
|
resetNodePreview();
|
|
|
|
return;
|
2023-07-28 19:41:57 +02:00
|
|
|
}
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
var value = node.getPreviewValues();
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(is_array(value)) {
|
2022-08-30 07:36:37 +02:00
|
|
|
preview_sequence[i] = value;
|
2023-01-25 06:49:00 +01:00
|
|
|
canvas_a = array_length(value);
|
|
|
|
} else {
|
2022-08-30 07:36:37 +02:00
|
|
|
preview_surface[i] = value;
|
2023-01-25 06:49:00 +01:00
|
|
|
canvas_a = 0;
|
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
|
2023-08-31 18:49:57 +02:00
|
|
|
if(preview_sequence[i] != noone) {
|
2022-08-30 07:36:37 +02:00
|
|
|
if(array_length(preview_sequence[i]) == 0) return;
|
|
|
|
preview_surface[i] = preview_sequence[i][safe_mod(node.preview_index, array_length(preview_sequence[i]))];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var prevS = getNodePreviewSurface();
|
2023-12-06 05:09:39 +01:00
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
if(is_surface(prevS)) {
|
2023-09-08 21:37:36 +02:00
|
|
|
canvas_w = surface_get_width_safe(prevS);
|
|
|
|
canvas_h = surface_get_height_safe(prevS);
|
2022-08-30 07:36:37 +02:00
|
|
|
}
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-03-13 10:45:56 +01:00
|
|
|
function onFocusBegin() { PANEL_PREVIEW = self; }
|
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function dragCanvas() { #region
|
2022-01-13 05:24:03 +01:00
|
|
|
if(canvas_dragging) {
|
2022-12-23 04:45:52 +01:00
|
|
|
if(!MOUSE_WRAPPING) {
|
|
|
|
var dx = mx - canvas_drag_mx;
|
|
|
|
var dy = my - canvas_drag_my;
|
|
|
|
|
|
|
|
canvas_x += dx;
|
|
|
|
canvas_y += dy;
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
canvas_drag_mx = mx;
|
|
|
|
canvas_drag_my = my;
|
2022-12-23 04:45:52 +01:00
|
|
|
setMouseWrap();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(mouse_release(canvas_drag_key))
|
2022-01-13 05:24:03 +01:00
|
|
|
canvas_dragging = false;
|
|
|
|
}
|
|
|
|
|
2023-07-30 13:56:22 +02:00
|
|
|
if(canvas_zooming) {
|
|
|
|
if(!MOUSE_WRAPPING) {
|
|
|
|
var dy = -(my - canvas_zoom_m) / 200;
|
|
|
|
|
|
|
|
var _s = canvas_s;
|
|
|
|
canvas_s = clamp(canvas_s * (1 + dy), 0.10, 64);
|
|
|
|
|
|
|
|
if(_s != canvas_s) {
|
|
|
|
var dx = (canvas_s - _s) * ((canvas_zoom_mx - canvas_x) / _s);
|
|
|
|
var dy = (canvas_s - _s) * ((canvas_zoom_my - canvas_y) / _s);
|
|
|
|
canvas_x -= dx;
|
|
|
|
canvas_y -= dy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas_zoom_m = my;
|
|
|
|
setMouseWrap();
|
|
|
|
|
|
|
|
if(mouse_release(canvas_drag_key))
|
|
|
|
canvas_zooming = false;
|
|
|
|
}
|
|
|
|
|
2023-12-18 04:40:21 +01:00
|
|
|
if(pHOVER && canvas_hover) {
|
2023-07-30 13:56:22 +02:00
|
|
|
var _doDragging = false;
|
|
|
|
var _doZooming = false;
|
|
|
|
|
2023-12-18 04:40:21 +01:00
|
|
|
if(mouse_press(PREFERENCES.pan_mouse_key, pFOCUS)) {
|
2023-07-30 13:56:22 +02:00
|
|
|
_doDragging = true;
|
2023-10-31 05:30:42 +01:00
|
|
|
canvas_drag_key = PREFERENCES.pan_mouse_key;
|
2023-12-18 04:40:21 +01:00
|
|
|
} else if(mouse_press(mb_left, pFOCUS) && canvas_dragging_key) {
|
2023-07-30 13:56:22 +02:00
|
|
|
_doDragging = true;
|
|
|
|
canvas_drag_key = mb_left;
|
2023-12-18 04:40:21 +01:00
|
|
|
} else if(mouse_press(mb_left, pFOCUS) && canvas_zooming_key) {
|
2023-07-30 13:56:22 +02:00
|
|
|
_doZooming = true;
|
2023-01-25 06:49:00 +01:00
|
|
|
canvas_drag_key = mb_left;
|
|
|
|
}
|
|
|
|
|
2023-07-30 13:56:22 +02:00
|
|
|
if(_doDragging) {
|
2022-01-13 05:24:03 +01:00
|
|
|
canvas_dragging = true;
|
|
|
|
canvas_drag_mx = mx;
|
|
|
|
canvas_drag_my = my;
|
|
|
|
canvas_drag_sx = canvas_x;
|
|
|
|
canvas_drag_sy = canvas_y;
|
|
|
|
}
|
|
|
|
|
2023-07-30 13:56:22 +02:00
|
|
|
if(_doZooming) {
|
|
|
|
canvas_zooming = true;
|
|
|
|
canvas_zoom_mx = mx;
|
|
|
|
canvas_zoom_my = my;
|
|
|
|
canvas_zoom_m = my;
|
|
|
|
canvas_zoom_s = canvas_s;
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
var _canvas_s = canvas_s;
|
2023-03-21 03:01:53 +01:00
|
|
|
var inc = 0.1;
|
2022-01-13 05:24:03 +01:00
|
|
|
if(canvas_s > 16) inc = 2;
|
|
|
|
else if(canvas_s > 8) inc = 1;
|
2023-03-21 03:01:53 +01:00
|
|
|
else if(canvas_s > 3) inc = 0.5;
|
|
|
|
else if(canvas_s > 1) inc = 0.25;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
if(mouse_wheel_down()) canvas_s = max(round(canvas_s / inc) * inc - inc, 0.10);
|
|
|
|
if(mouse_wheel_up()) canvas_s = min(round(canvas_s / inc) * inc + inc, 64);
|
2022-01-13 05:24:03 +01:00
|
|
|
if(_canvas_s != canvas_s) {
|
|
|
|
var dx = (canvas_s - _canvas_s) * ((mx - canvas_x) / _canvas_s);
|
|
|
|
var dy = (canvas_s - _canvas_s) * ((my - canvas_y) / _canvas_s);
|
|
|
|
canvas_x -= dx;
|
|
|
|
canvas_y -= dy;
|
|
|
|
}
|
|
|
|
}
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-04-21 19:08:10 +02:00
|
|
|
canvas_dragging_key = false;
|
2023-07-30 13:56:22 +02:00
|
|
|
canvas_zooming_key = false;
|
2023-03-11 01:40:17 +01:00
|
|
|
canvas_hover = point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height);
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
function dragCanvas3D() { #region
|
|
|
|
if(d3_camPanning) {
|
|
|
|
if(!MOUSE_WRAPPING) {
|
|
|
|
var dx = mx - d3_camPan_mx;
|
|
|
|
var dy = my - d3_camPan_my;
|
|
|
|
|
|
|
|
d3_view_camera.focus_angle_x += dx * 0.2 * d3_pan_speed;
|
|
|
|
d3_view_camera.focus_angle_y += dy * 0.1 * d3_pan_speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
d3_camPan_mx = mx;
|
|
|
|
d3_camPan_my = my;
|
|
|
|
setMouseWrap();
|
|
|
|
|
|
|
|
if(mouse_release(canvas_drag_key))
|
|
|
|
d3_camPanning = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(canvas_zooming) {
|
|
|
|
if(!MOUSE_WRAPPING) {
|
|
|
|
var dy = -(my - canvas_zoom_m) / 200;
|
|
|
|
d3_view_camera.focus_dist = clamp(d3_view_camera.focus_dist + dy, 1, 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas_zoom_m = my;
|
|
|
|
setMouseWrap();
|
|
|
|
|
|
|
|
if(mouse_release(canvas_drag_key))
|
|
|
|
canvas_zooming = false;
|
|
|
|
}
|
|
|
|
|
2023-12-18 04:40:21 +01:00
|
|
|
if(pHOVER && canvas_hover) {
|
2023-08-16 20:16:31 +02:00
|
|
|
var _doDragging = false;
|
|
|
|
var _doZooming = false;
|
|
|
|
|
2023-12-18 04:40:21 +01:00
|
|
|
if(mouse_press(PREFERENCES.pan_mouse_key, pFOCUS)) {
|
2023-08-16 20:16:31 +02:00
|
|
|
_doDragging = true;
|
2023-10-31 05:30:42 +01:00
|
|
|
canvas_drag_key = PREFERENCES.pan_mouse_key;
|
2023-12-18 04:40:21 +01:00
|
|
|
} else if(mouse_press(mb_left, pFOCUS) && canvas_dragging_key) {
|
2023-08-16 20:16:31 +02:00
|
|
|
_doDragging = true;
|
|
|
|
canvas_drag_key = mb_left;
|
2023-12-18 04:40:21 +01:00
|
|
|
} else if(mouse_press(mb_left, pFOCUS) && canvas_zooming_key) {
|
2023-08-16 20:16:31 +02:00
|
|
|
_doZooming = true;
|
|
|
|
canvas_drag_key = mb_left;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_doDragging) {
|
|
|
|
d3_camPanning = true;
|
|
|
|
d3_camPan_mx = mx;
|
|
|
|
d3_camPan_my = my;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_doZooming) {
|
|
|
|
canvas_zooming = true;
|
|
|
|
canvas_zoom_m = my;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mouse_wheel_up()) d3_view_camera.focus_dist = max( 1, d3_view_camera.focus_dist * (1 - d3_zoom_speed));
|
|
|
|
if(mouse_wheel_down()) d3_view_camera.focus_dist = min(1000, d3_view_camera.focus_dist * (1 + d3_zoom_speed));
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas_dragging_key = false;
|
|
|
|
canvas_zooming_key = false;
|
|
|
|
canvas_hover = point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height);
|
|
|
|
} #endregion
|
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function fullView() { #region
|
2023-11-03 14:43:28 +01:00
|
|
|
var bbox = noone;
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-11-03 14:43:28 +01:00
|
|
|
var node = getNodePreview();
|
|
|
|
if(node != noone) bbox = node.getPreviewBoundingBox();
|
|
|
|
if(bbox == noone) bbox = BBOX().fromWH(0, 0, PROJECT.attributes.surface_dimension[0], PROJECT.attributes.surface_dimension[1]);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
var ss = min((w - 32 - tool_side_drawing * 40) / bbox.w, (h - 32 - toolbar_height * 2) / bbox.h);
|
2022-01-13 05:24:03 +01:00
|
|
|
canvas_s = ss;
|
2023-07-14 20:34:35 +02:00
|
|
|
canvas_x = w / 2 - bbox.w * canvas_s / 2 - bbox.x0 * canvas_s + (tool_side_drawing * 40 / 2);
|
2023-07-10 20:14:10 +02:00
|
|
|
canvas_y = h / 2 - bbox.h * canvas_s / 2 - bbox.y0 * canvas_s;
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function drawNodeChannel(_x, _y) { #region
|
2022-08-30 07:36:37 +02:00
|
|
|
var _node = getNodePreview();
|
|
|
|
if(_node == noone) return;
|
2022-01-16 05:17:35 +01:00
|
|
|
if(ds_list_size(_node.outputs) < 2) return;
|
|
|
|
|
|
|
|
var chName = [];
|
2023-01-09 03:14:20 +01:00
|
|
|
sbChannelIndex = [];
|
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
var currName = _node.outputs[| _node.preview_channel].name;
|
2023-09-05 20:31:36 +02:00
|
|
|
draw_set_text(sbChannel.font, fa_center, fa_center);
|
|
|
|
var ww = 0;
|
|
|
|
var hh = TEXTBOX_HEIGHT - ui(2);
|
2022-01-16 05:17:35 +01:00
|
|
|
|
|
|
|
for( var i = 0; i < ds_list_size(_node.outputs); i++ ) {
|
2022-09-21 06:09:40 +02:00
|
|
|
if(_node.outputs[| i].type != VALUE_TYPE.surface) continue;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
2022-01-16 05:17:35 +01:00
|
|
|
array_push(chName, _node.outputs[| i].name);
|
2023-01-09 03:14:20 +01:00
|
|
|
array_push(sbChannelIndex, i);
|
2022-11-03 11:44:49 +01:00
|
|
|
ww = max(ww, string_width(_node.outputs[| i].name) + ui(40));
|
2022-01-16 05:17:35 +01:00
|
|
|
}
|
2023-09-05 20:31:36 +02:00
|
|
|
|
2022-01-16 05:17:35 +01:00
|
|
|
sbChannel.data_list = chName;
|
2023-06-21 20:36:53 +02:00
|
|
|
sbChannel.setFocusHover(pFOCUS, pHOVER);
|
2023-03-11 01:40:17 +01:00
|
|
|
sbChannel.draw(_x - ww, _y - hh / 2, ww, hh, currName, [mx, my], x, y);
|
2022-11-03 11:44:49 +01:00
|
|
|
right_menu_y += ui(40);
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-01-16 05:17:35 +01:00
|
|
|
|
2023-08-23 20:01:09 +02:00
|
|
|
function drawNodeChannel3D(_x, _y) { #region
|
|
|
|
var _node = getNodePreview();
|
|
|
|
if(_node == noone) return;
|
|
|
|
|
|
|
|
var ww = ui(128);
|
|
|
|
var hh = toolbar_height - ui(12);
|
|
|
|
|
|
|
|
d3Channel.setFocusHover(pFOCUS, pHOVER);
|
|
|
|
d3Channel.draw(_x - ww, _y - hh / 2, ww, hh, d3ChannelNames[d3_preview_channel], [mx, my], x, y);
|
|
|
|
right_menu_y += ui(40);
|
|
|
|
} #endregion
|
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function drawOnionSkin(node, psx, psy, ss) { #region
|
2023-07-08 20:29:23 +02:00
|
|
|
var _surf = preview_surface[0];
|
|
|
|
var _rang = PROJECT.onion_skin.range;
|
|
|
|
|
|
|
|
var _alph = PROJECT.onion_skin.alpha;
|
|
|
|
var _colr = PROJECT.onion_skin.color;
|
|
|
|
|
|
|
|
var _step = PROJECT.onion_skin.step;
|
|
|
|
var _top = PROJECT.onion_skin.on_top;
|
|
|
|
|
2023-10-09 16:07:33 +02:00
|
|
|
var fr = CURRENT_FRAME;
|
2023-07-08 20:29:23 +02:00
|
|
|
var st = min(_rang[0], _rang[1]);
|
|
|
|
var ed = max(_rang[0], _rang[1]);
|
|
|
|
|
|
|
|
st = sign(st) * floor(abs(st) / _step) * _step;
|
|
|
|
ed = sign(ed) * floor(abs(ed) / _step) * _step;
|
|
|
|
|
|
|
|
st += fr;
|
|
|
|
ed += fr;
|
|
|
|
|
|
|
|
for( var i = st; i <= ed; i += _step ) {
|
|
|
|
var surf = node.getCacheFrame(i);
|
|
|
|
if(!is_surface(surf)) continue;
|
|
|
|
|
|
|
|
var aa = power(_alph, abs((i - fr) / _step));
|
|
|
|
var cc = c_white;
|
|
|
|
if(i < fr) cc = _colr[0];
|
|
|
|
else if(i > fr) cc = _colr[1];
|
|
|
|
|
|
|
|
draw_surface_ext_safe(surf, psx, psy, ss, ss, 0, cc, aa);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_top) draw_surface_ext_safe(_surf, psx, psy, ss, ss);
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function drawNodePreview() { #region
|
2023-08-28 12:56:00 +02:00
|
|
|
var ss = canvas_s;
|
|
|
|
var psx = 0, psy = 0;
|
|
|
|
var psw = 0, psh = 0;
|
2022-09-21 06:09:40 +02:00
|
|
|
var pswd = 0, pshd = 0;
|
|
|
|
var psx1 = 0, psy1 = 0;
|
|
|
|
|
|
|
|
var ssx = 0, ssy = 0;
|
|
|
|
var ssw = 0, ssh = 0;
|
2022-01-16 05:17:35 +01:00
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
if(is_surface(preview_surface[0])) {
|
2022-09-21 06:09:40 +02:00
|
|
|
psx = canvas_x + preview_node[0].preview_x * ss;
|
|
|
|
psy = canvas_y + preview_node[0].preview_y * ss;
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
psw = surface_get_width_safe(preview_surface[0]);
|
|
|
|
psh = surface_get_height_safe(preview_surface[0]);
|
2022-09-21 06:09:40 +02:00
|
|
|
pswd = psw * ss;
|
|
|
|
pshd = psh * ss;
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
psx1 = psx + pswd;
|
|
|
|
psy1 = psy + pshd;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
if(is_surface(preview_surface[1])) {
|
|
|
|
var ssx = canvas_x + preview_node[1].preview_x * ss;
|
|
|
|
var ssy = canvas_y + preview_node[1].preview_y * ss;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var ssw = surface_get_width_safe(preview_surface[1]);
|
|
|
|
var ssh = surface_get_height_safe(preview_surface[1]);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-03-21 03:01:53 +01:00
|
|
|
var _node = getNodePreview();
|
2023-11-21 02:53:15 +01:00
|
|
|
if(_node) title = _node.renamed? _node.display_name : _node.name;
|
2023-03-21 03:01:53 +01:00
|
|
|
|
2023-11-21 02:53:15 +01:00
|
|
|
if(splitView == 0 && tileMode == 0) {
|
2023-07-08 20:29:23 +02:00
|
|
|
var node = preview_node[0];
|
2023-11-21 02:53:15 +01:00
|
|
|
if(is_surface(preview_surface[0])) {
|
|
|
|
node.previewing = 1;
|
|
|
|
var aa = node.preview_alpha;
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2023-11-21 02:53:15 +01:00
|
|
|
if(PROJECT.onion_skin.enabled) drawOnionSkin(node, psx, psy, ss);
|
|
|
|
else draw_surface_ext_safe(preview_surface[0], psx, psy, ss, ss, 0, c_white, aa);
|
|
|
|
}
|
2023-07-08 20:29:23 +02:00
|
|
|
}
|
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
switch(splitView) { #region draw surfaces
|
2022-08-30 07:36:37 +02:00
|
|
|
case 0 :
|
|
|
|
if(is_surface(preview_surface[0])) {
|
|
|
|
preview_node[0].previewing = 1;
|
2022-12-10 05:06:01 +01:00
|
|
|
|
|
|
|
switch(tileMode) {
|
2023-02-19 02:13:19 +01:00
|
|
|
case 1 :
|
2023-09-08 21:37:36 +02:00
|
|
|
tile_surface = surface_verify(tile_surface, w, surface_get_height_safe(preview_surface[0]) * ss);
|
2023-02-19 02:13:19 +01:00
|
|
|
surface_set_target(tile_surface);
|
2023-03-19 09:17:39 +01:00
|
|
|
DRAW_CLEAR
|
2023-02-19 02:13:19 +01:00
|
|
|
draw_surface_tiled_ext_safe(preview_surface[0], psx, 0, ss, ss, c_white, 1);
|
|
|
|
surface_reset_target();
|
2023-03-19 09:17:39 +01:00
|
|
|
draw_surface_safe(tile_surface, 0, psy);
|
2023-02-19 02:13:19 +01:00
|
|
|
break;
|
|
|
|
case 2 :
|
2023-09-08 21:37:36 +02:00
|
|
|
tile_surface = surface_verify(tile_surface, surface_get_width_safe(preview_surface[0]) * ss, h);
|
2023-02-19 02:13:19 +01:00
|
|
|
surface_set_target(tile_surface);
|
2023-03-19 09:17:39 +01:00
|
|
|
DRAW_CLEAR
|
2023-02-28 09:43:01 +01:00
|
|
|
draw_surface_tiled_ext_safe(preview_surface[0], 0, psy, ss, ss, c_white, 1);
|
2023-02-19 02:13:19 +01:00
|
|
|
surface_reset_target();
|
2023-03-19 09:17:39 +01:00
|
|
|
draw_surface_safe(tile_surface, psx, 0);
|
2023-02-19 02:13:19 +01:00
|
|
|
break;
|
2022-12-10 05:06:01 +01:00
|
|
|
case 3 : draw_surface_tiled_ext_safe(preview_surface[0], psx, psy, ss, ss, c_white, 1); break;
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-08-30 07:36:37 +02:00
|
|
|
break;
|
|
|
|
case 1 :
|
|
|
|
var sp = splitPosition * w;
|
|
|
|
|
|
|
|
if(is_surface(preview_surface[0])) {
|
|
|
|
preview_node[0].previewing = 2;
|
|
|
|
var maxX = min(sp, psx1);
|
|
|
|
var sW = min(psw, (maxX - psx) / ss);
|
|
|
|
|
|
|
|
if(sW > 0)
|
|
|
|
draw_surface_part_ext_safe(preview_surface[0], 0, 0, sW, psh, psx, psy, ss, ss, 0, c_white, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(is_surface(preview_surface[1])) {
|
|
|
|
preview_node[1].previewing = 3;
|
|
|
|
var minX = max(ssx, sp);
|
|
|
|
var sX = (minX - ssx) / ss;
|
|
|
|
var spx = max(sp, ssx);
|
|
|
|
|
|
|
|
if(sX >= 0 && sX < ssw)
|
|
|
|
draw_surface_part_ext_safe(preview_surface[1], sX, 0, ssw - sX, ssh, spx, ssy, ss, ss, 0, c_white, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
var sp = splitPosition * h;
|
|
|
|
|
|
|
|
if(is_surface(preview_surface[0])) {
|
|
|
|
preview_node[0].previewing = 4;
|
|
|
|
var maxY = min(sp, psy1);
|
|
|
|
var sH = min(psh, (maxY - psy) / ss);
|
|
|
|
|
|
|
|
if(sH > 0)
|
|
|
|
draw_surface_part_ext_safe(preview_surface[0], 0, 0, psw, sH, psx, psy, ss, ss, 0, c_white, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(is_surface(preview_surface[1])) {
|
|
|
|
preview_node[1].previewing = 5;
|
|
|
|
var minY = max(ssy, sp);
|
|
|
|
var sY = (minY - ssy) / ss;
|
|
|
|
var spy = max(sp, ssy);
|
|
|
|
|
|
|
|
if(sY >= 0 && sY < ssh)
|
|
|
|
draw_surface_part_ext_safe(preview_surface[1], 0, sY, ssw, ssh - sY, ssx, spy, ss, ss, 0, c_white, 1);
|
|
|
|
}
|
|
|
|
break;
|
2023-08-28 12:56:00 +02:00
|
|
|
} #endregion
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
if(!instance_exists(o_dialog_menubox)) { #region color sample
|
2023-02-28 09:43:01 +01:00
|
|
|
sample_color = noone;
|
|
|
|
sample_x = noone;
|
|
|
|
sample_y = noone;
|
|
|
|
|
|
|
|
if(mouse_on_preview && (mouse_press(mb_right) || key_mod_press(CTRL))) {
|
|
|
|
var _sx = sample_x;
|
|
|
|
var _sy = sample_y;
|
|
|
|
|
|
|
|
sample_x = floor((mx - canvas_x) / canvas_s);
|
|
|
|
sample_y = floor((my - canvas_y) / canvas_s);
|
|
|
|
var surf = getNodePreviewSurface();
|
|
|
|
if(is_surface(surf))
|
2023-03-31 06:59:08 +02:00
|
|
|
sample_color = surface_get_pixel_ext(surf, sample_x, sample_y);
|
2023-02-28 09:43:01 +01:00
|
|
|
}
|
2023-08-28 12:56:00 +02:00
|
|
|
} #endregion
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
if(is_surface(preview_surface[0])) { #region outline
|
2023-08-01 19:21:51 +02:00
|
|
|
if(PROJECT.previewGrid.show) {
|
2023-10-18 14:58:55 +02:00
|
|
|
var _gw = PROJECT.previewGrid.size[0] * canvas_s;
|
2023-09-27 14:55:21 +02:00
|
|
|
var _gh = PROJECT.previewGrid.size[1] * canvas_s;
|
2023-10-18 14:58:55 +02:00
|
|
|
|
2023-09-27 14:55:21 +02:00
|
|
|
var gw = pswd / _gw;
|
|
|
|
var gh = pshd / _gh;
|
2022-09-21 06:09:40 +02:00
|
|
|
|
|
|
|
var cx = canvas_x;
|
|
|
|
var cy = canvas_y;
|
|
|
|
|
2023-08-01 19:21:51 +02:00
|
|
|
draw_set_color(PROJECT.previewGrid.color);
|
|
|
|
draw_set_alpha(PROJECT.previewGrid.opacity);
|
2022-11-03 11:44:49 +01:00
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
for( var i = 1; i < gw; i++ ) {
|
|
|
|
var _xx = cx + i * _gw;
|
|
|
|
draw_line(_xx, cy, _xx, cy + pshd);
|
|
|
|
}
|
|
|
|
|
|
|
|
for( var i = 1; i < gh; i++ ) {
|
|
|
|
var _yy = cy + i * _gh;
|
|
|
|
draw_line(cx, _yy, cx + pswd, _yy);
|
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
|
|
|
|
draw_set_alpha(1);
|
2022-09-21 06:09:40 +02:00
|
|
|
}
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS.panel_preview_surface_outline);
|
2023-05-03 21:42:17 +02:00
|
|
|
draw_rectangle(psx, psy, psx + pswd - 1, psy + pshd - 1, true);
|
2023-08-28 12:56:00 +02:00
|
|
|
} #endregion
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
function draw3D() { #region
|
|
|
|
var _prev_node = getNodePreview();
|
2023-08-29 14:33:44 +02:00
|
|
|
if(_prev_node == noone) return;
|
2023-11-21 02:53:15 +01:00
|
|
|
if(!_prev_node.is_3D) return;
|
2023-09-05 18:05:18 +02:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
_prev_node.previewing = 1;
|
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
d3_scene_preview = struct_has(_prev_node, "scene")? _prev_node.scene : d3_scene;
|
|
|
|
d3_scene_preview.camera = d3_view_camera;
|
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
#region view
|
2023-08-17 16:56:54 +02:00
|
|
|
var _pos, targ, _blend = 1;
|
2023-08-28 12:56:00 +02:00
|
|
|
|
2023-08-15 11:36:26 +02:00
|
|
|
targ = d3_camTarget;
|
2023-11-21 02:53:15 +01:00
|
|
|
_pos = d3d_PolarToCart(targ.x, targ.y, targ.z, d3_view_camera.focus_angle_x, d3_view_camera.focus_angle_y, d3_view_camera.focus_dist);
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
if(d3_active_transition == 1) {
|
|
|
|
var _up = new __vec3(0, 0, -1);
|
|
|
|
|
|
|
|
d3_view_camera.position._lerp_float(_pos, 5, 0.1);
|
|
|
|
d3_view_camera.focus._lerp_float( targ, 5, 0.1);
|
|
|
|
d3_view_camera.up._lerp_float( _up, 5, 0.1);
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-15 11:36:26 +02:00
|
|
|
if(d3_view_camera.position.equal(_pos) && d3_view_camera.focus.equal(targ))
|
2023-08-17 16:56:54 +02:00
|
|
|
d3_active_transition = 0;
|
|
|
|
} else if(d3_active_transition == -1) {
|
|
|
|
var _pos = new __vec3(0, 0, 8);
|
|
|
|
var targ = new __vec3(0, 0, 0);
|
|
|
|
var _up = new __vec3(0, 1, 0);
|
|
|
|
|
|
|
|
d3_view_camera.position._lerp_float(_pos, 5, 0.1);
|
|
|
|
d3_view_camera.focus._lerp_float( targ, 5, 0.1);
|
|
|
|
d3_view_camera.up._lerp_float( _up, 5, 0.1);
|
|
|
|
|
|
|
|
_blend = d3_view_camera.position.distance(_pos) / 2;
|
|
|
|
_blend = clamp(_blend, 0, 1);
|
|
|
|
|
|
|
|
if(d3_view_camera.position.equal(_pos) && d3_view_camera.focus.equal(targ))
|
|
|
|
d3_active_transition = 0;
|
2023-08-14 19:22:04 +02:00
|
|
|
} else {
|
2023-08-15 11:36:26 +02:00
|
|
|
d3_view_camera.position.set(_pos);
|
|
|
|
d3_view_camera.focus.set(targ);
|
2023-08-14 19:22:04 +02:00
|
|
|
}
|
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
d3_view_camera.setViewSize(w, h);
|
2023-08-15 11:36:26 +02:00
|
|
|
d3_view_camera.setMatrix();
|
2023-08-16 20:16:31 +02:00
|
|
|
#endregion
|
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
#region background
|
|
|
|
surface_free_safe(d3_surface_bg);
|
|
|
|
|
2023-09-05 18:05:18 +02:00
|
|
|
if(d3_scene_preview != d3_scene)
|
2023-08-28 12:56:00 +02:00
|
|
|
d3_surface_bg = d3_scene_preview.renderBackground(w, h);
|
|
|
|
#endregion
|
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
#region shadow
|
2023-09-05 18:05:18 +02:00
|
|
|
if(d3_scene_preview == d3_scene) {
|
2023-08-23 20:01:09 +02:00
|
|
|
d3_scene_light0.shadow_map_scale = d3_view_camera.focus_dist * 2;
|
|
|
|
|
2023-10-05 06:29:20 +02:00
|
|
|
var _prev_obj = _prev_node.getPreviewObject();
|
2023-10-23 14:33:55 +02:00
|
|
|
if(_prev_obj != noone) {
|
|
|
|
d3_scene_light0.submitShadow(d3_scene_preview, _prev_obj);
|
|
|
|
_prev_obj.submitShadow(d3_scene_preview, _prev_obj);
|
|
|
|
}
|
2023-08-22 11:51:45 +02:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
2023-08-23 20:01:09 +02:00
|
|
|
d3_surface = surface_verify(d3_surface, w, h);
|
|
|
|
d3_surface_normal = surface_verify(d3_surface_normal, w, h);
|
|
|
|
d3_surface_depth = surface_verify(d3_surface_depth, w, h);
|
|
|
|
d3_surface_outline = surface_verify(d3_surface_outline, w, h);
|
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
#region defer
|
2023-09-05 18:05:18 +02:00
|
|
|
var _prev_obj = _prev_node.getPreviewObject();
|
2023-09-05 20:31:36 +02:00
|
|
|
d3_deferData = d3_scene_preview.deferPass(_prev_obj, w, h, d3_deferData);
|
2023-08-28 12:56:00 +02:00
|
|
|
#endregion
|
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
#region grid
|
2023-08-23 20:01:09 +02:00
|
|
|
surface_set_target_ext(0, d3_surface);
|
|
|
|
surface_set_target_ext(1, d3_surface_normal);
|
|
|
|
surface_set_target_ext(2, d3_surface_depth);
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
draw_clear_alpha(bg_color, 0);
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
d3_view_camera.applyCamera();
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-12-07 15:08:09 +01:00
|
|
|
gpu_set_ztestenable(true);
|
|
|
|
gpu_set_zwriteenable(false);
|
|
|
|
|
2023-12-06 13:51:22 +01:00
|
|
|
if(OS != os_macosx) {
|
|
|
|
gpu_set_cullmode(cull_noculling);
|
2023-12-07 15:08:09 +01:00
|
|
|
|
2023-12-06 13:51:22 +01:00
|
|
|
shader_set(sh_d3d_grid_view);
|
|
|
|
var _dist = round(d3_view_camera.focus.distance(d3_view_camera.position));
|
|
|
|
var _tx = round(d3_view_camera.focus.x);
|
|
|
|
var _ty = round(d3_view_camera.focus.y);
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-12-06 13:51:22 +01:00
|
|
|
var _scale = _dist * 2;
|
|
|
|
while(_scale > 32) _scale /= 2;
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-12-06 13:51:22 +01:00
|
|
|
shader_set_f("axisBlend", _blend);
|
|
|
|
shader_set_f("scale", _scale);
|
|
|
|
shader_set_f("shift", _tx / _dist / 2, _ty / _dist / 2);
|
|
|
|
draw_sprite_stretched(s_fx_pixel, 0, _tx - _dist, _ty - _dist, _dist * 2, _dist * 2);
|
|
|
|
shader_reset();
|
|
|
|
}
|
2023-12-07 15:08:09 +01:00
|
|
|
|
|
|
|
gpu_set_zwriteenable(true);
|
2023-08-22 11:51:45 +02:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region draw
|
2023-09-05 18:05:18 +02:00
|
|
|
d3_scene_preview.reset();
|
2023-08-23 20:01:09 +02:00
|
|
|
gpu_set_cullmode(cull_counterclockwise);
|
2023-08-28 12:56:00 +02:00
|
|
|
|
2023-09-05 18:05:18 +02:00
|
|
|
var _prev_obj = _prev_node.getPreviewObjects();
|
2023-08-17 16:56:54 +02:00
|
|
|
|
2023-09-05 18:05:18 +02:00
|
|
|
if(d3_scene_preview == d3_scene) {
|
|
|
|
if(d3_scene_light_enabled) {
|
|
|
|
d3_scene_preview.addLightDirectional(d3_scene_light0);
|
|
|
|
d3_scene_preview.addLightDirectional(d3_scene_light1);
|
2023-08-22 11:51:45 +02:00
|
|
|
}
|
2023-09-05 18:05:18 +02:00
|
|
|
}
|
2023-10-05 06:29:20 +02:00
|
|
|
|
2023-09-05 18:05:18 +02:00
|
|
|
for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) {
|
|
|
|
var _prev = _prev_obj[i];
|
|
|
|
if(_prev == noone) continue;
|
2023-08-17 16:56:54 +02:00
|
|
|
|
2023-09-05 18:05:18 +02:00
|
|
|
_prev.submitShader(d3_scene_preview);
|
|
|
|
}
|
2023-08-17 16:56:54 +02:00
|
|
|
|
2023-09-05 20:31:36 +02:00
|
|
|
d3_scene_preview.apply(d3_deferData);
|
2023-10-05 06:29:20 +02:00
|
|
|
|
2023-12-20 03:54:26 +01:00
|
|
|
//print("========= Submit begin =========");
|
2023-09-05 18:05:18 +02:00
|
|
|
for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) {
|
|
|
|
var _prev = _prev_obj[i];
|
|
|
|
if(_prev == noone) continue;
|
|
|
|
_prev.submitUI(d3_scene_preview); //////////////// SUBMIT ////////////////
|
2023-08-17 16:56:54 +02:00
|
|
|
}
|
2023-12-20 03:54:26 +01:00
|
|
|
//print("========= Submit end =========");
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-23 20:01:09 +02:00
|
|
|
gpu_set_cullmode(cull_noculling);
|
2023-08-14 19:22:04 +02:00
|
|
|
surface_reset_target();
|
2023-08-23 20:01:09 +02:00
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
draw_clear(bg_color);
|
|
|
|
|
2023-08-23 20:01:09 +02:00
|
|
|
switch(d3_preview_channel) {
|
2023-08-28 12:56:00 +02:00
|
|
|
case 0 :
|
2023-08-30 16:40:45 +02:00
|
|
|
if(d3_scene_preview.draw_background)
|
|
|
|
draw_surface_safe(d3_surface_bg);
|
2023-10-05 06:29:20 +02:00
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
draw_surface_safe(d3_surface);
|
|
|
|
|
|
|
|
BLEND_MULTIPLY
|
2023-09-05 20:31:36 +02:00
|
|
|
draw_surface_safe(d3_deferData.ssao);
|
2023-08-28 12:56:00 +02:00
|
|
|
BLEND_NORMAL
|
|
|
|
break;
|
2023-08-23 20:01:09 +02:00
|
|
|
case 1 : draw_surface_safe(d3_surface_normal); break;
|
|
|
|
case 2 : draw_surface_safe(d3_surface_depth); break;
|
|
|
|
}
|
2023-08-16 20:16:31 +02:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region outline
|
2023-09-19 20:43:02 +02:00
|
|
|
var inspect_node = PANEL_INSPECTOR.getInspecting();
|
2023-08-17 16:56:54 +02:00
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
if(inspect_node && inspect_node.is_3D) {
|
2023-08-17 16:56:54 +02:00
|
|
|
var _inspect_obj = inspect_node.getPreviewObjectOutline();
|
|
|
|
|
2023-08-23 20:01:09 +02:00
|
|
|
surface_set_target(d3_surface_outline);
|
2023-08-16 20:16:31 +02:00
|
|
|
draw_clear(c_black);
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-09-05 18:05:18 +02:00
|
|
|
d3_scene_preview.camera.applyCamera();
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
gpu_set_ztestenable(false);
|
2023-08-17 16:56:54 +02:00
|
|
|
for( var i = 0, n = array_length(_inspect_obj); i < n; i++ ) {
|
|
|
|
if(_inspect_obj[i] == noone) continue;
|
2023-08-30 16:40:45 +02:00
|
|
|
_inspect_obj[i].submitSel(d3_scene_preview);
|
2023-08-17 16:56:54 +02:00
|
|
|
}
|
2023-08-16 20:16:31 +02:00
|
|
|
surface_reset_target();
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
shader_set(sh_d3d_outline);
|
2023-08-23 20:01:09 +02:00
|
|
|
shader_set_dim("dimension", d3_surface_outline);
|
2023-08-16 20:16:31 +02:00
|
|
|
shader_set_color("outlineColor", COLORS._main_accent);
|
2023-08-23 20:01:09 +02:00
|
|
|
draw_surface(d3_surface_outline, 0, 0);
|
2023-08-16 20:16:31 +02:00
|
|
|
shader_reset();
|
2023-08-14 19:22:04 +02:00
|
|
|
}
|
|
|
|
#endregion
|
2023-08-22 11:51:45 +02:00
|
|
|
|
2023-09-05 18:05:18 +02:00
|
|
|
d3_scene_preview.camera.resetCamera();
|
2023-08-14 19:22:04 +02:00
|
|
|
} #endregion
|
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function drawPreviewOverlay() { #region
|
2023-03-11 01:40:17 +01:00
|
|
|
right_menu_y = toolbar_height - ui(4);
|
2023-07-23 20:21:35 +02:00
|
|
|
toolbar_draw = false;
|
2023-03-13 10:45:56 +01:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
var _node = getNodePreview();
|
2023-03-13 10:45:56 +01:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
#region status texts (top right)
|
|
|
|
if(PANEL_PREVIEW == self) {
|
|
|
|
draw_set_text(f_p0, fa_right, fa_top, COLORS._main_text_accent);
|
|
|
|
draw_text(w - ui(8), right_menu_y, __txt("Active"));
|
|
|
|
right_menu_y += string_height("l");
|
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
draw_set_text(f_p0, fa_right, fa_top, fps >= PROJECT.animator.framerate? COLORS._main_text_sub : COLORS._main_value_negative);
|
2023-08-29 14:33:44 +02:00
|
|
|
draw_text(w - ui(8), right_menu_y, $"{__txt("fps")} {fps}");
|
2023-08-17 16:56:54 +02:00
|
|
|
right_menu_y += string_height("l");
|
2023-02-14 02:51:14 +01:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
draw_set_text(f_p0, fa_right, fa_top, COLORS._main_text_sub);
|
2023-10-09 16:07:33 +02:00
|
|
|
draw_text(w - ui(8), right_menu_y, $"{__txt("Frame")} {CURRENT_FRAME}/{TOTAL_FRAMES}");
|
2023-07-05 15:09:52 +02:00
|
|
|
|
2023-07-05 15:40:14 +02:00
|
|
|
right_menu_y += string_height("l");
|
2023-08-29 14:33:44 +02:00
|
|
|
draw_text(w - ui(8), right_menu_y, $"x{canvas_s}");
|
2023-07-05 15:09:52 +02:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
if(pHOVER) {
|
|
|
|
right_menu_y += string_height("l");
|
|
|
|
var mpx = floor((mx - canvas_x) / canvas_s);
|
|
|
|
var mpy = floor((my - canvas_y) / canvas_s);
|
2023-08-29 14:33:44 +02:00
|
|
|
draw_text(w - ui(8), right_menu_y, $"[{mpx}, {mpy}]");
|
2023-08-17 16:56:54 +02:00
|
|
|
}
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
if(_node == noone) return;
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
right_menu_y += string_height("l");
|
2023-08-29 14:33:44 +02:00
|
|
|
var txt = $"{canvas_w} x {canvas_h}px";
|
|
|
|
if(canvas_a) txt = $"{canvas_a} x {txt}";
|
2023-08-17 16:56:54 +02:00
|
|
|
draw_text(w - ui(8), right_menu_y, txt);
|
|
|
|
|
|
|
|
right_menu_y += string_height("l");
|
|
|
|
#endregion
|
2022-11-03 11:44:49 +01:00
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
var pseq = getNodePreviewSequence();
|
2023-08-31 18:49:57 +02:00
|
|
|
if(pseq == noone) return;
|
2022-12-16 09:18:09 +01:00
|
|
|
|
|
|
|
if(!array_equals(pseq, _preview_sequence)) {
|
|
|
|
_preview_sequence = pseq;
|
|
|
|
preview_x = 0;
|
|
|
|
preview_x_to = 0;
|
|
|
|
}
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
var prev_size = ui(48);
|
2022-12-10 05:06:01 +01:00
|
|
|
preview_x = lerp_float(preview_x, preview_x_to, 4);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
if(pHOVER && my > h - toolbar_height - prev_size - ui(16) && my > toolbar_height) {
|
2022-12-16 09:18:09 +01:00
|
|
|
canvas_hover = false;
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-04-07 21:25:27 +02:00
|
|
|
if(mouse_wheel_down()) preview_x_to = clamp(preview_x_to - prev_size * SCROLL_SPEED, - preview_x_max, 0);
|
|
|
|
if(mouse_wheel_up()) preview_x_to = clamp(preview_x_to + prev_size * SCROLL_SPEED, - preview_x_max, 0);
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
preview_x_max = 0;
|
2023-08-19 12:42:50 +02:00
|
|
|
var _xx = tool_side_drawing * ui(40);
|
2023-08-17 16:56:54 +02:00
|
|
|
var xx = _xx + preview_x + ui(8);
|
|
|
|
var yy = h - toolbar_height - prev_size - ui(8);
|
2023-10-04 09:49:31 +02:00
|
|
|
if(my > yy - 8) mouse_on_preview = 0;
|
2023-08-17 16:56:54 +02:00
|
|
|
var hoverable = pHOVER && point_in_rectangle(mx, my, _xx, ui(32), w, h - toolbar_height);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
for(var i = 0; i < array_length(pseq); i++) {
|
|
|
|
var prev = pseq[i];
|
2023-08-29 14:33:44 +02:00
|
|
|
if(is_instanceof(prev, __d3dMaterial))
|
|
|
|
prev = prev.surface;
|
2022-12-16 09:18:09 +01:00
|
|
|
if(!is_surface(prev)) continue;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var prev_w = surface_get_width_safe(prev);
|
|
|
|
var prev_h = surface_get_height_safe(prev);
|
2022-12-16 09:18:09 +01:00
|
|
|
var ss = prev_size / max(prev_w, prev_h);
|
|
|
|
var prev_sw = prev_w * ss;
|
|
|
|
|
|
|
|
draw_set_color(COLORS.panel_preview_surface_outline);
|
|
|
|
draw_rectangle(xx, yy, xx + prev_w * ss, yy + prev_h * ss, true);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
if(hoverable && point_in_rectangle(mx, my, xx, yy, xx + prev_sw, yy + prev_h * ss)) {
|
2022-12-16 09:18:09 +01:00
|
|
|
if(mouse_press(mb_left, pFOCUS)) {
|
|
|
|
_node.preview_index = i;
|
|
|
|
_node.onValueUpdate(0);
|
|
|
|
if(resetViewOnDoubleClick)
|
|
|
|
do_fullView = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-12-16 09:18:09 +01:00
|
|
|
draw_surface_ext_safe(prev, xx, yy, ss, ss, 0, c_white, 1);
|
|
|
|
} else {
|
|
|
|
draw_surface_ext_safe(prev, xx, yy, ss, ss, 0, c_white, 0.5);
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
if(i == _node.preview_index) {
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
draw_rectangle(xx, yy, xx + prev_sw, yy + prev_h * ss, true);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
xx += prev_sw + ui(8);
|
|
|
|
preview_x_max += prev_sw + ui(8);
|
|
|
|
}
|
|
|
|
preview_x_max = max(preview_x_max - ui(100), 0);
|
2023-08-17 16:56:54 +02:00
|
|
|
|
|
|
|
#region ++++ sequence control ++++
|
|
|
|
//var by = h - toolbar_height - prev_size - ui(56);
|
|
|
|
//var bx = ui(10);
|
|
|
|
|
|
|
|
//var b = buttonInstant(THEME.button_hide, bx, by, ui(40), ui(40), [mx, my], pFOCUS, pHOVER);
|
|
|
|
|
|
|
|
//if(_node.preview_speed == 0) {
|
|
|
|
// if(b) {
|
|
|
|
// draw_sprite_ui_uniform(THEME.sequence_control, 1, bx + ui(20), by + ui(20), 1, COLORS._main_icon, 1);
|
|
|
|
// if(b == 2) _node.preview_speed = preview_rate / game_get_speed(gamespeed_fps);
|
|
|
|
// }
|
|
|
|
// draw_sprite_ui_uniform(THEME.sequence_control, 1, bx + ui(20), by + ui(20), 1, COLORS._main_icon, 0.5);
|
|
|
|
//} else {
|
|
|
|
// if(b) {
|
|
|
|
// draw_sprite_ui_uniform(THEME.sequence_control, 0, bx + ui(20), by + ui(20), 1, COLORS._main_accent, 1);
|
|
|
|
// if(b == 2) _node.preview_speed = 0;
|
|
|
|
// }
|
|
|
|
// draw_sprite_ui_uniform(THEME.sequence_control, 0, bx + ui(20), by + ui(20), 1, COLORS._main_accent, .75);
|
|
|
|
//}
|
|
|
|
#endregion
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function drawNodeTools(active, _node) { #region
|
2022-09-21 06:09:40 +02:00
|
|
|
var _mx = mx;
|
|
|
|
var _my = my;
|
2023-10-04 07:21:45 +02:00
|
|
|
var isHover = pHOVER && mouse_on_preview == 1;
|
2023-07-14 20:34:35 +02:00
|
|
|
var tool_width = ui(40);
|
|
|
|
var tool_size = ui(32);
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
var cx = canvas_x + _node.preview_x * canvas_s;
|
|
|
|
var cy = canvas_y + _node.preview_y * canvas_s;
|
|
|
|
var _snx = 0, _sny = 0;
|
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
tool_side_drawing = _node.tools != -1;
|
|
|
|
|
|
|
|
if(_node.tools != -1 && point_in_rectangle(_mx, _my, 0, 0, tool_width, h)) {
|
|
|
|
isHover = false;
|
2023-10-04 07:21:45 +02:00
|
|
|
mouse_on_preview = 0;
|
2023-07-14 20:34:35 +02:00
|
|
|
}
|
|
|
|
|
2023-10-18 14:58:55 +02:00
|
|
|
var overlayHover = tool_hovering == noone && !overlay_hovering;
|
2023-07-14 20:34:35 +02:00
|
|
|
overlayHover &= active && isHover;
|
|
|
|
overlayHover &= point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height);
|
|
|
|
overlayHover &= !key_mod_press(CTRL);
|
2023-11-14 14:29:11 +01:00
|
|
|
var params = { w, h, toolbar_height };
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
if(_node.is_3D) {
|
|
|
|
if(key_mod_press(CTRL) || d3_tool_snap) {
|
|
|
|
_snx = d3_tool_snap_position;
|
|
|
|
_sny = d3_tool_snap_rotation;
|
|
|
|
}
|
|
|
|
|
2023-11-14 14:29:11 +01:00
|
|
|
_node.drawOverlay3D(overlayHover, d3_scene, _mx, _my, _snx, _sny, params);
|
2023-08-22 11:51:45 +02:00
|
|
|
} else {
|
|
|
|
if(key_mod_press(CTRL)) {
|
2023-09-27 14:55:21 +02:00
|
|
|
_snx = PROJECT.previewGrid.show? PROJECT.previewGrid.size[0] : 1;
|
|
|
|
_sny = PROJECT.previewGrid.show? PROJECT.previewGrid.size[1] : 1;
|
2023-08-22 11:51:45 +02:00
|
|
|
} else if(PROJECT.previewGrid.snap) {
|
2023-09-27 14:55:21 +02:00
|
|
|
_snx = PROJECT.previewGrid.size[0];
|
|
|
|
_sny = PROJECT.previewGrid.size[1];
|
2023-08-22 11:51:45 +02:00
|
|
|
}
|
|
|
|
|
2023-11-14 14:29:11 +01:00
|
|
|
_node.drawOverlay(overlayHover, cx, cy, canvas_s, _mx, _my, _snx, _sny, params);
|
2023-08-22 11:51:45 +02:00
|
|
|
}
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-10-18 14:58:55 +02:00
|
|
|
#region node overlay
|
|
|
|
overlay_hovering = false;
|
|
|
|
|
|
|
|
if(_node.drawPreviewToolOverlay(pHOVER && pFOCUS, _mx, _my, { x, y, w, h, toolbar_height,
|
|
|
|
x0: _node.tools == -1? 0 : ui(40),
|
|
|
|
x1: w,
|
|
|
|
y0: toolbar_height - ui(8),
|
|
|
|
y1: h - toolbar_height
|
|
|
|
})) {
|
|
|
|
canvas_hover = false;
|
|
|
|
overlay_hovering = true;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
var _tool = tool_hovering;
|
|
|
|
tool_hovering = noone;
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(_node.tools == -1) {
|
|
|
|
tool_current = noone;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
var aa = d3_active? 0.8 : 1;
|
2023-08-19 12:42:50 +02:00
|
|
|
draw_sprite_stretched_ext(THEME.tool_side, 1, 0, ui(32), tool_width, h - toolbar_height - ui(32), c_white, aa);
|
2023-07-15 20:01:29 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
var xx = ui(1) + tool_width / 2;
|
|
|
|
var yy = ui(34) + tool_size / 2;
|
|
|
|
var pd = 2;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
for(var i = 0; i < array_length(_node.tools); i++) { #region iterate each tools
|
|
|
|
var tool = _node.tools[i];
|
|
|
|
var _x0 = xx - tool_size / 2;
|
|
|
|
var _y0 = yy - tool_size / 2;
|
|
|
|
var _x1 = xx + tool_size / 2;
|
|
|
|
var _y1 = yy + tool_size / 2;
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x1, _y1 - 1)) {
|
|
|
|
tool_hovering = tool;
|
|
|
|
}
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(tool.subtools > 0 && _tool == tool) { #region subtools
|
|
|
|
var s_ww = tool_size * tool.subtools;
|
|
|
|
var s_hh = tool_size;
|
|
|
|
draw_sprite_stretched(THEME.menu_bg, 0, _x0 - pd, _y0 - pd, s_ww + pd * 2, s_hh + pd * 2);
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
var stool = tool.spr;
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
for( var j = 0; j < array_length(stool); j++ ) {
|
|
|
|
var _sxx = xx + j * tool_size;
|
|
|
|
var _syy = yy;
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
var _sx0 = _sxx - tool_size / 2;
|
|
|
|
var _sy0 = _syy - tool_size / 2;
|
|
|
|
var _sx1 = _sxx + tool_size / 2;
|
|
|
|
var _sy1 = _syy + tool_size / 2;
|
2023-03-11 01:40:17 +01:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(point_in_rectangle(_mx, _my, _sx0, _sy0 + 1, _sx1, _sy1 - 1)) {
|
2023-10-04 07:21:45 +02:00
|
|
|
TOOLTIP = tool.getDisplayName(j);
|
2023-08-19 12:42:50 +02:00
|
|
|
draw_sprite_stretched(THEME.button_hide, 1, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2);
|
2023-10-04 05:52:20 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(mouse_press(mb_left, pFOCUS))
|
|
|
|
tool.toggle(j);
|
|
|
|
}
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(tool_current == tool && tool.selecting == j) {
|
|
|
|
draw_sprite_stretched_ext(THEME.button_hide, 2, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1);
|
|
|
|
draw_sprite_stretched_ext(THEME.button_hide, 3, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1);
|
2023-07-14 20:34:35 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
draw_sprite_colored(stool[j], 0, _sxx, _syy);
|
|
|
|
}
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x0 + s_ww, _y1 - 1))
|
|
|
|
tool_hovering = tool;
|
|
|
|
#endregion
|
|
|
|
} else { #region single tools
|
|
|
|
if(tool_hovering == tool) {
|
|
|
|
draw_sprite_stretched(THEME.button_hide, 1, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2);
|
2023-10-04 07:21:45 +02:00
|
|
|
TOOLTIP = tool.getDisplayName();
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(mouse_press(mb_left, pFOCUS))
|
2023-07-14 20:34:35 +02:00
|
|
|
tool.toggle();
|
2023-08-19 12:42:50 +02:00
|
|
|
}
|
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
if(pFOCUS && WIDGET_CURRENT == noone) {
|
|
|
|
var _key = tool.checkHotkey();
|
|
|
|
|
|
|
|
if(keyboard_check_pressed(ord(string(i + 1))) || (_key != "" && keyboard_check_pressed(ord(_key))))
|
|
|
|
tool.toggleKeyboard();
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(tool_current == tool) {
|
|
|
|
draw_sprite_stretched_ext(THEME.button_hide, 2, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1);
|
|
|
|
draw_sprite_stretched_ext(THEME.button_hide, 3, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1);
|
2023-04-08 20:06:27 +02:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(tool.subtools > 0) draw_sprite_colored(tool.spr[tool.selecting], 0, xx, yy);
|
|
|
|
else draw_sprite_colored(tool.spr, 0, xx, yy);
|
|
|
|
#endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-08-19 12:42:50 +02:00
|
|
|
|
|
|
|
yy += tool_size;
|
|
|
|
} #endregion
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function drawToolBar(_node) { #region
|
2022-11-03 11:44:49 +01:00
|
|
|
toolbar_height = ui(40);
|
2022-08-30 07:36:37 +02:00
|
|
|
var ty = h - toolbar_height;
|
2022-11-18 03:20:31 +01:00
|
|
|
//draw_sprite_stretched_ext(THEME.toolbar_shadow, 0, 0, ty - 12 + 4, w, 12, c_white, 0.5);
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
var aa = d3_active? 0.8 : 1;
|
|
|
|
draw_sprite_stretched_ext(THEME.toolbar, 1, 0, 0, w, topbar_height, c_white, aa);
|
2023-08-14 19:22:04 +02:00
|
|
|
draw_sprite_stretched_ext(THEME.toolbar, 0, 0, ty, w, toolbar_height, c_white, aa);
|
2023-07-23 20:21:35 +02:00
|
|
|
|
|
|
|
if(!_node) return;
|
2023-03-11 01:40:17 +01:00
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
if(tool_current != noone) { #region tool settings
|
2023-11-08 13:05:24 +01:00
|
|
|
var settings = array_merge(_node.getToolSettings(), tool_current.settings);
|
2023-03-11 01:40:17 +01:00
|
|
|
|
|
|
|
tool_x = lerp_float(tool_x, tool_x_to, 5);
|
|
|
|
var tolx = tool_x + ui(16);
|
|
|
|
var toly = ui(8);
|
2023-03-19 09:17:39 +01:00
|
|
|
var tolw = ui(48);
|
2023-03-11 01:40:17 +01:00
|
|
|
var tolh = toolbar_height - ui(20);
|
|
|
|
var tol_max_w = ui(32);
|
|
|
|
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(settings); i < n; i++ ) {
|
2023-03-11 01:40:17 +01:00
|
|
|
var sett = settings[i];
|
|
|
|
var nme = sett[0];
|
|
|
|
var wdg = sett[1];
|
|
|
|
var key = sett[2];
|
|
|
|
var atr = sett[3];
|
|
|
|
|
|
|
|
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text_sub);
|
|
|
|
draw_text(tolx, toolbar_height / 2 - ui(2), nme);
|
|
|
|
tolx += string_width(nme) + ui(8);
|
|
|
|
tol_max_w += string_width(nme) + ui(8);
|
|
|
|
|
2023-06-21 20:36:53 +02:00
|
|
|
wdg.setFocusHover(pFOCUS, pHOVER);
|
2023-08-19 12:42:50 +02:00
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
switch(instanceof(wdg)) {
|
2023-08-19 12:42:50 +02:00
|
|
|
case "checkBoxGroup" : tolw = tolh * wdg.size; break;
|
|
|
|
case "checkBox" : tolw = tolh; break;
|
|
|
|
case "scrollBox" : tolw = ui(96); break;
|
2023-03-11 01:40:17 +01:00
|
|
|
}
|
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
var params = new widgetParam(tolx, toly, tolw, tolh, atr[$ key],, [ mx, my ])
|
2023-08-31 16:58:13 +02:00
|
|
|
params.s = tolh;
|
|
|
|
|
2023-08-19 12:42:50 +02:00
|
|
|
wdg.drawParam(params);
|
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
tolx += tolw + ui(16);
|
|
|
|
tol_max_w += tolw + ui(16);
|
|
|
|
}
|
|
|
|
|
|
|
|
tol_max_w = max(0, tol_max_w - w);
|
|
|
|
if(point_in_rectangle(mx, my, 0, 0, w, toolbar_height)) {
|
2023-04-07 21:25:27 +02:00
|
|
|
if(mouse_wheel_up()) tool_x_to = clamp(tool_x_to + ui(64) * SCROLL_SPEED, -tol_max_w, 0);
|
|
|
|
if(mouse_wheel_down()) tool_x_to = clamp(tool_x_to - ui(64) * SCROLL_SPEED, -tol_max_w, 0);
|
2023-03-11 01:40:17 +01:00
|
|
|
}
|
2023-08-19 12:42:50 +02:00
|
|
|
#endregion
|
|
|
|
} else { #region color sampler
|
2023-03-11 01:40:17 +01:00
|
|
|
var cx = ui(10);
|
|
|
|
var cy = ui(10);
|
|
|
|
var cw = ui(32);
|
2023-08-22 11:51:45 +02:00
|
|
|
var ch = topbar_height - ui(16);
|
2023-03-31 06:59:08 +02:00
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
if(sample_color != noone) {
|
|
|
|
draw_set_color(sample_color);
|
|
|
|
draw_rectangle(cx, cy, cx + cw, cy + ch, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
draw_set_color(COLORS.panel_toolbar_outline);
|
|
|
|
draw_rectangle(cx, cy, cx + cw, cy + ch, true);
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
if(sample_color != noone) {
|
|
|
|
var tx = cx + cw + ui(16);
|
|
|
|
var hx = color_get_hex(sample_color);
|
|
|
|
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
|
|
|
draw_text(tx, cy + ch / 2, hx);
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
tx += string_width(hx) + ui(8);
|
|
|
|
draw_set_color(COLORS._main_text_sub);
|
|
|
|
draw_text(tx, cy + ch / 2, "(" + string(color_get_alpha(sample_color)) + ")");
|
|
|
|
}
|
2023-08-19 12:42:50 +02:00
|
|
|
#endregion
|
2023-03-13 10:45:56 +01:00
|
|
|
}
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
var tbx = toolbar_height / 2;
|
|
|
|
var tby = ty + toolbar_height / 2;
|
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
var _toolbars = d3_active? toolbars_3d : toolbars;
|
|
|
|
|
|
|
|
for( var i = 0, n = array_length(_toolbars); i < n; i++ ) {
|
|
|
|
var tb = _toolbars[i];
|
|
|
|
var tbSpr = tb[0];
|
|
|
|
var tbInd = tb[1]();
|
2022-08-30 07:36:37 +02:00
|
|
|
var tbTooltip = tb[2]();
|
2023-08-22 11:51:45 +02:00
|
|
|
var tbActive = tb[3];
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
var b = buttonInstant(THEME.button_hide, tbx - ui(14), tby - ui(14), ui(28), ui(28), [mx, my], pFOCUS, pHOVER, tbTooltip, tbSpr, tbInd);
|
2023-08-22 11:51:45 +02:00
|
|
|
if(b == 2) tbActive( { x: x + tbx - ui(14), y: y + tby - ui(14) } );
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
tbx += ui(32);
|
2022-08-30 07:36:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
tbx = w - toolbar_height / 2;
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(actions); i < n; i++ ) {
|
2022-08-30 07:36:37 +02:00
|
|
|
var tb = actions[i];
|
|
|
|
var tbSpr = tb[0];
|
|
|
|
var tbTooltip = tb[1];
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
var b = buttonInstant(THEME.button_hide, tbx - ui(14), tby - ui(14), ui(28), ui(28), [mx, my], pFOCUS, pHOVER, tbTooltip, tbSpr, 0);
|
2022-08-30 07:36:37 +02:00
|
|
|
if(b == 2) tb[2]();
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
tbx -= ui(32);
|
2022-08-30 07:36:37 +02:00
|
|
|
}
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS.panel_toolbar_separator);
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_line_width(tbx + ui(12), tby - toolbar_height / 2 + ui(8), tbx + ui(12), tby + toolbar_height / 2 - ui(8), 2);
|
2023-08-23 20:01:09 +02:00
|
|
|
|
|
|
|
if(d3_active) drawNodeChannel3D(tbx, tby);
|
|
|
|
else drawNodeChannel(tbx, tby);
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function drawSplitView() { #region
|
2022-08-30 07:36:37 +02:00
|
|
|
if(splitView == 0) return;
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS.panel_preview_split_line);
|
2022-08-30 07:36:37 +02:00
|
|
|
|
|
|
|
if(splitViewDragging) {
|
|
|
|
if(splitView == 1) {
|
|
|
|
var cx = splitViewStart + (mx - splitViewMouse);
|
|
|
|
splitPosition = clamp(cx / w, .1, .9);
|
|
|
|
} else if(splitView == 2) {
|
|
|
|
var cy = splitViewStart + (my - splitViewMouse);
|
|
|
|
splitPosition = clamp(cy / h, .1, .9);
|
|
|
|
}
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_release(mb_left))
|
2022-08-30 07:36:37 +02:00
|
|
|
splitViewDragging = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(splitView == 1) {
|
|
|
|
var sx = w * splitPosition;
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
if(mouse_on_preview && point_in_rectangle(mx, my, sx - ui(4), 0, sx + ui(4), h)) {
|
2022-08-30 07:36:37 +02:00
|
|
|
draw_line_width(sx, 0, sx, h, 2);
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_press(mb_left, pFOCUS)) {
|
2022-08-30 07:36:37 +02:00
|
|
|
splitViewDragging = true;
|
|
|
|
splitViewStart = sx;
|
|
|
|
splitViewMouse = mx;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
draw_line_width(sx, 0, sx, h, 1);
|
|
|
|
|
2023-03-21 03:01:53 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.icon_active_split, 0, splitSelection? sx + ui(16) : sx - ui(16), toolbar_height + ui(16),, COLORS._main_accent);
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_on_preview && mouse_press(mb_left, pFOCUS)) {
|
2022-08-30 07:36:37 +02:00
|
|
|
if(point_in_rectangle(mx, my, 0, 0, sx, h))
|
|
|
|
splitSelection = 0;
|
|
|
|
else if(point_in_rectangle(mx, my, sx, 0, w, h))
|
|
|
|
splitSelection = 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var sy = h * splitPosition;
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
if(mouse_on_preview && point_in_rectangle(mx, my, 0, sy - ui(4), w, sy + ui(4))) {
|
2022-08-30 07:36:37 +02:00
|
|
|
draw_line_width(0, sy, w, sy, 2);
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_press(mb_left, pFOCUS)) {
|
2022-08-30 07:36:37 +02:00
|
|
|
splitViewDragging = true;
|
|
|
|
splitViewStart = sy;
|
|
|
|
splitViewMouse = my;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
draw_line_width(0, sy, w, sy, 1);
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.icon_active_split, 0, ui(16), splitSelection? sy + ui(16) : sy - ui(16),, COLORS._main_accent);
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_on_preview && mouse_press(mb_left, pFOCUS)) {
|
2022-08-30 07:36:37 +02:00
|
|
|
if(point_in_rectangle(mx, my, 0, 0, w, sy))
|
|
|
|
splitSelection = 0;
|
|
|
|
else if(point_in_rectangle(mx, my, 0, sy, w, h))
|
|
|
|
splitSelection = 1;
|
|
|
|
}
|
|
|
|
}
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function drawContent(panel) { #region >>>>>>>>>>>>>>>>>>>> MAIN DRAW <<<<<<<<<<<<<<<<<<<<
|
2023-03-11 01:40:17 +01:00
|
|
|
mouse_on_preview = pHOVER && point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height);
|
2023-10-04 07:21:45 +02:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
var _prev_node = getNodePreview();
|
2023-08-17 16:56:54 +02:00
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
d3_active = _prev_node != noone && _prev_node.is_3D;
|
2022-01-16 05:17:35 +01:00
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
draw_clear(bg_color);
|
2023-03-13 10:45:56 +01:00
|
|
|
if(canvas_bg == -1 && canvas_s >= 0.1)
|
2023-06-10 13:59:45 +02:00
|
|
|
draw_sprite_tiled_ext(s_transparent, 0, canvas_x, canvas_y, canvas_s, canvas_s, COLORS.panel_preview_transparent, 1);
|
2023-03-11 06:40:34 +01:00
|
|
|
else
|
2022-01-13 05:24:03 +01:00
|
|
|
draw_clear(canvas_bg);
|
2023-08-17 16:56:54 +02:00
|
|
|
draw_set_color(COLORS._main_icon_dark);
|
|
|
|
draw_line_width(canvas_x, 0, canvas_x, h, 1);
|
|
|
|
draw_line_width(0, canvas_y, w, canvas_y, 1);
|
|
|
|
|
|
|
|
bg_color = lerp_color(bg_color, d3_active? COLORS.panel_3d_bg : COLORS.panel_bg_clear, 0.3);
|
|
|
|
title = __txt("Preview");
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-28 12:56:00 +02:00
|
|
|
getPreviewData();
|
|
|
|
|
2023-08-29 14:33:44 +02:00
|
|
|
if(_prev_node) {
|
|
|
|
if(d3_active) {
|
|
|
|
dragCanvas3D();
|
|
|
|
draw3D();
|
|
|
|
} else {
|
|
|
|
dragCanvas();
|
|
|
|
drawNodePreview();
|
|
|
|
}
|
2023-11-03 14:43:28 +01:00
|
|
|
} else dragCanvas();
|
2023-03-21 03:01:53 +01:00
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
drawPreviewOverlay();
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-09-19 20:43:02 +02:00
|
|
|
var inspect_node = PANEL_INSPECTOR.getInspecting();
|
2023-03-21 03:01:53 +01:00
|
|
|
|
2023-07-17 19:58:33 +02:00
|
|
|
var tool = noone;
|
|
|
|
if(inspect_node) {
|
|
|
|
tool = inspect_node.getTool();
|
2023-10-04 09:49:31 +02:00
|
|
|
if(tool) drawNodeTools(pFOCUS, tool);
|
2023-08-17 16:56:54 +02:00
|
|
|
} else
|
2023-03-11 01:40:17 +01:00
|
|
|
tool_current = noone;
|
2022-08-30 07:36:37 +02:00
|
|
|
|
|
|
|
if(do_fullView) {
|
|
|
|
do_fullView = false;
|
|
|
|
fullView();
|
|
|
|
}
|
|
|
|
|
2023-10-04 09:49:31 +02:00
|
|
|
if(mouse_on_preview && mouse_press(mb_right, pFOCUS) && !key_mod_press(SHIFT)) {
|
2023-05-03 21:42:17 +02:00
|
|
|
menuCall("preview_context_menu",,, [
|
2023-06-13 14:42:06 +02:00
|
|
|
menuItem(__txtx("panel_graph_preview_window", "Send to preview window"), function() { create_preview_window(getNodePreview()); }, noone, ["Preview", "Preview window"]),
|
2023-02-28 09:43:01 +01:00
|
|
|
-1,
|
2023-06-04 18:28:29 +02:00
|
|
|
menuItem(__txtx("panel_preview_save", "Save current preview as") + "...", function() { saveCurrentFrame(); }),
|
|
|
|
menuItem(__txtx("panel_preview_save_all", "Save all current previews as") + "...", function() { saveAllCurrentFrames(); }),
|
2023-02-28 09:43:01 +01:00
|
|
|
-1,
|
2023-06-05 18:27:53 +02:00
|
|
|
menuItem(__txtx("panel_preview_copy_image", "Copy image"), function() { copyCurrentFrame(); }, THEME.copy),
|
|
|
|
menuItem(__txtx("panel_preview_copy_color", "Copy color") + " [" + string(sample_color) + "]", function() { clipboard_set_text(sample_color); }),
|
|
|
|
menuItem(__txtx("panel_preview_copy_hex", "Copy hex") + " [" + string(color_get_hex(sample_color)) + "]", function() { clipboard_set_text(color_get_hex(sample_color)); }),
|
2023-05-04 20:00:56 +02:00
|
|
|
],, getNodePreview());
|
2022-08-30 07:36:37 +02:00
|
|
|
}
|
|
|
|
|
2023-08-14 19:22:04 +02:00
|
|
|
if(!d3_active) drawSplitView();
|
2023-07-23 20:21:35 +02:00
|
|
|
drawToolBar(tool);
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
static onFullScreen = function() { run_in(1, fullView); }
|
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function copyCurrentFrame() { #region
|
2023-05-03 21:42:17 +02:00
|
|
|
var prevS = getNodePreviewSurface();
|
|
|
|
if(!is_surface(prevS)) return;
|
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var buff = buffer_create(surface_get_width_safe(prevS) * surface_get_height_safe(prevS) * 4, buffer_fixed, 1);
|
|
|
|
var s = surface_create(surface_get_width_safe(prevS), surface_get_height_safe(prevS));
|
2023-05-03 21:42:17 +02:00
|
|
|
|
|
|
|
surface_set_target(s);
|
|
|
|
shader_set(sh_BGR);
|
|
|
|
draw_surface(prevS, 0, 0);
|
|
|
|
shader_reset();
|
|
|
|
surface_reset_target();
|
|
|
|
|
|
|
|
buffer_get_surface(buff, s, 0);
|
|
|
|
surface_free(s);
|
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
clipboard_set_bitmap(buffer_get_address(buff), surface_get_width_safe(prevS), surface_get_height_safe(prevS));
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2023-05-03 21:42:17 +02:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function saveCurrentFrame() { #region
|
2022-08-30 07:36:37 +02:00
|
|
|
var prevS = getNodePreviewSurface();
|
|
|
|
if(!is_surface(prevS)) return;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-07 15:08:09 +01:00
|
|
|
var path = get_save_filename("image|*.png;*.jpg", "export");
|
2023-02-28 09:43:01 +01:00
|
|
|
key_release();
|
2022-01-13 05:24:03 +01:00
|
|
|
if(path == "") return;
|
2022-09-21 06:09:40 +02:00
|
|
|
if(filename_ext(path) != ".png") path += ".png";
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
surface_save_safe(prevS, path);
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-13 13:10:20 +02:00
|
|
|
function saveAllCurrentFrames() { #region
|
2023-12-07 15:08:09 +01:00
|
|
|
var path = get_save_filename("image|*.png;*.jpg", "export");
|
2023-02-28 09:43:01 +01:00
|
|
|
key_release();
|
2022-01-13 05:24:03 +01:00
|
|
|
if(path == "") return;
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
var ext = ".png";
|
2022-01-13 05:24:03 +01:00
|
|
|
var name = string_replace_all(path, ext, "");
|
|
|
|
var ind = 0;
|
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
var pseq = getNodePreviewSequence();
|
|
|
|
for(var i = 0; i < array_length(pseq); i++) {
|
|
|
|
var prev = pseq[i];
|
2022-01-13 05:24:03 +01:00
|
|
|
if(!is_surface(prev)) continue;
|
|
|
|
var _name = name + string(ind) + ext;
|
2023-03-19 09:17:39 +01:00
|
|
|
surface_save_safe(prev, _name);
|
2022-01-13 05:24:03 +01:00
|
|
|
ind++;
|
|
|
|
}
|
2023-08-13 13:10:20 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|