mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
preview, graph view controller
This commit is contained in:
parent
10d09f8ffc
commit
05eb31ad8e
20 changed files with 472 additions and 88 deletions
|
@ -1130,6 +1130,7 @@
|
|||
{"name":"panel_preview_histogram","order":8,"path":"scripts/panel_preview_histogram/panel_preview_histogram.yy",},
|
||||
{"name":"panel_preview_onion_setting","order":5,"path":"scripts/panel_preview_onion_setting/panel_preview_onion_setting.yy",},
|
||||
{"name":"panel_preview_snap_setting","order":3,"path":"scripts/panel_preview_snap_setting/panel_preview_snap_setting.yy",},
|
||||
{"name":"panel_preview_view_settings","order":9,"path":"scripts/panel_preview_view_settings/panel_preview_view_settings.yy",},
|
||||
{"name":"panel_preview_window","order":1,"path":"scripts/panel_preview_window/panel_preview_window.yy",},
|
||||
{"name":"panel_test","order":8,"path":"scripts/panel_test/panel_test.yy",},
|
||||
{"name":"panel_text_editor","order":9,"path":"scripts/panel_text_editor/panel_text_editor.yy",},
|
||||
|
|
|
@ -1599,6 +1599,7 @@
|
|||
{"id":{"name":"panel_preview_histogram","path":"scripts/panel_preview_histogram/panel_preview_histogram.yy",},},
|
||||
{"id":{"name":"panel_preview_onion_setting","path":"scripts/panel_preview_onion_setting/panel_preview_onion_setting.yy",},},
|
||||
{"id":{"name":"panel_preview_snap_setting","path":"scripts/panel_preview_snap_setting/panel_preview_snap_setting.yy",},},
|
||||
{"id":{"name":"panel_preview_view_settings","path":"scripts/panel_preview_view_settings/panel_preview_view_settings.yy",},},
|
||||
{"id":{"name":"panel_preview_window","path":"scripts/panel_preview_window/panel_preview_window.yy",},},
|
||||
{"id":{"name":"panel_preview","path":"scripts/panel_preview/panel_preview.yy",},},
|
||||
{"id":{"name":"panel_test","path":"scripts/panel_test/panel_test.yy",},},
|
||||
|
|
Binary file not shown.
|
@ -110,11 +110,11 @@ function draw_arc_width(_x, _y, _r, _th, _angSt, _angEd) { #region
|
|||
var diff = _angEd >= _angSt? _angEd - _angSt : _angEd + 360 - _angSt;
|
||||
|
||||
for(var i = 0; i <= abs(diff); i += 4) {
|
||||
var as = _angSt + i * sign(diff);
|
||||
var nxI = _x + lengthdir_x(_r - _th / 2, as);
|
||||
var nyI = _y + lengthdir_y(_r - _th / 2, as);
|
||||
var nxO = _x + lengthdir_x(_r + _th / 2, as);
|
||||
var nyO = _y + lengthdir_y(_r + _th / 2, as);
|
||||
var _as = _angSt + i * sign(diff);
|
||||
var nxI = _x + lengthdir_x(_r - _th / 2, _as);
|
||||
var nyI = _y + lengthdir_y(_r - _th / 2, _as);
|
||||
var nxO = _x + lengthdir_x(_r + _th / 2, _as);
|
||||
var nyO = _y + lengthdir_y(_r + _th / 2, _as);
|
||||
|
||||
if(i) {
|
||||
draw_vertex(oxI, oyI);
|
||||
|
@ -144,11 +144,11 @@ function draw_arc_forward(_x, _y, _r, _th, _angSt, _angEd) { #region
|
|||
var diff = _aEd - _aSt;
|
||||
|
||||
for(var i = 0; i <= abs(diff); i += 4) {
|
||||
var as = _aSt + i * sign(diff);
|
||||
var nxI = _x + lengthdir_x(_r - _th / 2, as);
|
||||
var nyI = _y + lengthdir_y(_r - _th / 2, as);
|
||||
var nxO = _x + lengthdir_x(_r + _th / 2, as);
|
||||
var nyO = _y + lengthdir_y(_r + _th / 2, as);
|
||||
var _as = _aSt + i * sign(diff);
|
||||
var nxI = _x + lengthdir_x(_r - _th / 2, _as);
|
||||
var nyI = _y + lengthdir_y(_r - _th / 2, _as);
|
||||
var nxO = _x + lengthdir_x(_r + _th / 2, _as);
|
||||
var nyO = _y + lengthdir_y(_r + _th / 2, _as);
|
||||
|
||||
if(i) {
|
||||
draw_vertex(oxI, oyI);
|
||||
|
@ -168,3 +168,16 @@ function draw_arc_forward(_x, _y, _r, _th, _angSt, _angEd) { #region
|
|||
|
||||
draw_primitive_end();
|
||||
} #endregion
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function draw_circle_ui(_x, _y, _r, _o, _c = c_white, _a = 1) {
|
||||
shader_set(sh_node_circle);
|
||||
shader_set_color("color", _c, _a);
|
||||
shader_set_f("thickness", _o);
|
||||
shader_set_f("antialias", 1 / _r);
|
||||
shader_set_i("fill", _o == 0);
|
||||
|
||||
draw_sprite_stretched(s_fx_pixel, 0, _x - _r, _y - _r, _r * 2, _r * 2);
|
||||
shader_reset();
|
||||
}
|
|
@ -54,7 +54,7 @@ function Node_Byte_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
|
|||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
if(attributes.file_checker && path_current != "") {
|
||||
if(attributes.file_checker && file_exists_empty(path_current)) {
|
||||
if(file_get_modify_s(path_current) > edit_time) {
|
||||
updatePaths();
|
||||
triggerRender();
|
||||
|
|
|
@ -105,7 +105,7 @@ function Node_CSV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
if(attributes.file_checker && path_current != "") {
|
||||
if(attributes.file_checker && file_exists_empty(path_current)) {
|
||||
if(file_get_modify_s(path_current) > edit_time) {
|
||||
updatePaths();
|
||||
triggerRender();
|
||||
|
|
|
@ -143,7 +143,7 @@ function Node_Image_gif(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
|||
gc_collect();
|
||||
}
|
||||
|
||||
if(attributes.file_checker && path_current != "") {
|
||||
if(attributes.file_checker && file_exists_empty(path_current)) {
|
||||
if(file_get_modify_s(path_current) > edit_time) {
|
||||
updatePaths();
|
||||
triggerRender();
|
||||
|
|
|
@ -86,7 +86,7 @@ function Node_Json_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
|
|||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
if(attributes.file_checker && path_current != "") {
|
||||
if(attributes.file_checker && file_exists_empty(path_current)) {
|
||||
if(file_get_modify_s(path_current) > edit_time) {
|
||||
updatePaths();
|
||||
triggerRender();
|
||||
|
|
|
@ -188,7 +188,6 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
|||
inputs[| i + 2].setDisplay(VALUE_DISPLAY._default);
|
||||
}
|
||||
|
||||
doCompile();
|
||||
} #endregion
|
||||
|
||||
static onDestroy = function() {
|
||||
|
|
|
@ -188,7 +188,6 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
|||
inputs[| i + 2].setDisplay(VALUE_DISPLAY._default);
|
||||
}
|
||||
|
||||
doCompile();
|
||||
} #endregion
|
||||
|
||||
static onDestroy = function() {
|
||||
|
|
|
@ -64,7 +64,7 @@ function Node_Text_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
|
|||
triggerRender();
|
||||
} #endregion
|
||||
|
||||
function updatePaths(path) { #region
|
||||
function updatePaths(path = path_current) { #region
|
||||
if(path == -1) return false;
|
||||
|
||||
var ext = string_lower(filename_ext(path));
|
||||
|
@ -83,10 +83,16 @@ function Node_Text_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
|
|||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
if(attributes.file_checker && path_current != "") {
|
||||
if(file_get_modify_s(path_current) > edit_time) {
|
||||
updatePaths();
|
||||
triggerRender();
|
||||
if(attributes.file_checker && file_exists_empty(path_current)) {
|
||||
var _modi = file_get_modify_s(path_current);
|
||||
|
||||
if(_modi > edit_time) {
|
||||
edit_time = _modi;
|
||||
|
||||
run_in(2, function() {
|
||||
updatePaths();
|
||||
triggerRender();
|
||||
});
|
||||
}
|
||||
}
|
||||
} #endregion
|
||||
|
|
|
@ -193,7 +193,7 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
preview_id = audio_play_sound(preview_audio, 1, false, attributes.preview_gain, dur);
|
||||
}
|
||||
|
||||
if(attributes.file_checker && path_current != "") {
|
||||
if(attributes.file_checker && file_exists_empty(path_current)) {
|
||||
if(file_get_modify_s(path_current) > edit_time) {
|
||||
updatePaths();
|
||||
triggerRender();
|
||||
|
|
|
@ -178,6 +178,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
connection_param = new connectionParameter();
|
||||
|
||||
bg_color = c_black;
|
||||
show_view_control = true;
|
||||
#endregion
|
||||
|
||||
#region ---- position ----
|
||||
|
@ -206,6 +207,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
graph_zoom_m = 0;
|
||||
graph_zoom_s = 0;
|
||||
|
||||
view_hovering = false;
|
||||
view_pan_tool = false;
|
||||
view_zoom_tool = false;
|
||||
|
||||
drag_key = PREFERENCES.pan_mouse_key;
|
||||
drag_locking = false;
|
||||
#endregion
|
||||
|
@ -416,7 +421,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
function() { return 0; },
|
||||
function() { return __txtx("graph_visibility_title", "Visibility settings"); },
|
||||
function(param) {
|
||||
dialogPanelCall(new Panel_Graph_View_Setting(display_parameter), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
|
||||
dialogPanelCall(new Panel_Graph_View_Setting(self, display_parameter), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
|
||||
}
|
||||
],
|
||||
];
|
||||
|
@ -729,8 +734,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
graph_drag_my = my;
|
||||
setMouseWrap();
|
||||
|
||||
if(mouse_release(drag_key))
|
||||
if(mouse_release(drag_key)) {
|
||||
graph_dragging = false;
|
||||
view_pan_tool = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(graph_zooming) {
|
||||
|
@ -758,8 +765,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
graph_zoom_m = my;
|
||||
setMouseWrap();
|
||||
|
||||
if(mouse_release(drag_key))
|
||||
graph_zooming = false;
|
||||
if(mouse_release(drag_key)) {
|
||||
graph_zooming = false;
|
||||
view_zoom_tool = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(mouse_on_graph && pFOCUS && graph_draggable) {
|
||||
|
@ -920,6 +929,67 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
draw_set_alpha(1);
|
||||
} #endregion
|
||||
|
||||
function drawViewControl() { #region
|
||||
view_hovering = false;
|
||||
if(!show_view_control) return;
|
||||
|
||||
var _hab = pHOVER && !view_pan_tool && !view_zoom_tool;
|
||||
|
||||
var d3_view_wz = ui(16);
|
||||
|
||||
var _d3x = ui(8) + d3_view_wz;
|
||||
var _d3y = ui(8) + 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)) {
|
||||
drag_key = mb_left;
|
||||
graph_dragging = true;
|
||||
graph_drag_mx = mx;
|
||||
graph_drag_my = my;
|
||||
graph_drag_sx = graph_x;
|
||||
graph_drag_sy = graph_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;
|
||||
_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)) {
|
||||
drag_key = mb_left;
|
||||
graph_zooming = true;
|
||||
graph_zoom_mx = w / 2;
|
||||
graph_zoom_my = h / 2;
|
||||
graph_zoom_m = my;
|
||||
graph_zoom_s = graph_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
|
||||
|
||||
function drawBasePreview() { #region
|
||||
var gr_x = graph_x * graph_s;
|
||||
var gr_y = graph_y * graph_s;
|
||||
|
@ -935,6 +1005,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
|
||||
function drawNodes() { #region
|
||||
if(selection_block-- > 0) return;
|
||||
var _focus = pFOCUS && !view_hovering;
|
||||
|
||||
display_parameter.highlight =
|
||||
!array_empty(nodes_selecting) && (
|
||||
|
@ -979,7 +1050,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
if(node_hovering != noone)
|
||||
_HOVERING_ELEMENT = node_hovering;
|
||||
|
||||
if(node_hovering != noone && pFOCUS && DOUBLE_CLICK && struct_has(node_hovering, "onDoubleClick")) {
|
||||
if(node_hovering != noone && _focus && DOUBLE_CLICK && struct_has(node_hovering, "onDoubleClick")) {
|
||||
|
||||
if(node_hovering.onDoubleClick(self)) {
|
||||
DOUBLE_CLICK = false;
|
||||
|
@ -1000,7 +1071,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
NODE_DROPPER_TARGET.expression += node_hovering.internalName;
|
||||
NODE_DROPPER_TARGET.expressionUpdate();
|
||||
}
|
||||
} else if(mouse_press(mb_left, pFOCUS)) {
|
||||
} else if(mouse_press(mb_left, _focus)) {
|
||||
if(key_mod_press(SHIFT)) {
|
||||
if(node_hovering) {
|
||||
if(array_exists(nodes_selecting, node_hovering))
|
||||
|
@ -1062,7 +1133,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
}
|
||||
#endregion
|
||||
|
||||
if(mouse_press(mb_right, pFOCUS)) { #region
|
||||
if(mouse_press(mb_right, _focus)) { #region
|
||||
node_hover = node_hovering;
|
||||
|
||||
if(value_focus) {
|
||||
|
@ -1345,7 +1416,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
#endregion
|
||||
printIf(log, $"Drag node time : {get_timer() - t}"); t = get_timer();
|
||||
|
||||
if(mouse_on_graph && pFOCUS) { #region
|
||||
if(mouse_on_graph && _focus) { #region
|
||||
var _node = getFocusingNode();
|
||||
if(_node && _node.draggable && value_focus == noone) {
|
||||
if(mouse_press(mb_left) && !key_mod_press(ALT)) {
|
||||
|
@ -1416,7 +1487,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
nodes_junction_d = noone;
|
||||
}
|
||||
|
||||
if(mouse_on_graph && !node_bg_hovering && mouse_press(mb_left, pFOCUS) && !graph_dragging_key && !graph_zooming_key) {
|
||||
if(mouse_on_graph && !node_bg_hovering && mouse_press(mb_left, _focus) && !graph_dragging_key && !graph_zooming_key) {
|
||||
if(is_instanceof(junction_hovering, NodeValue) && junction_hovering.draw_line_shift_hover) {
|
||||
nodes_select_mx = mx;
|
||||
nodes_select_my = my;
|
||||
|
@ -1614,11 +1685,12 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
}
|
||||
|
||||
function drawJunctionConnect() { #region
|
||||
var _focus = pFOCUS && !view_hovering;
|
||||
|
||||
if(value_dragging)
|
||||
draggingValue();
|
||||
|
||||
if(value_dragging == noone && value_focus && mouse_press(mb_left, pFOCUS) && !key_mod_press(ALT)) {
|
||||
if(value_dragging == noone && value_focus && mouse_press(mb_left, _focus) && !key_mod_press(ALT)) {
|
||||
value_dragging = value_focus;
|
||||
value_draggings = [];
|
||||
|
||||
|
@ -1930,6 +2002,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
draw_clear(bg_color);
|
||||
node_bg_hovering = drawBasePreview();
|
||||
drawGrid();
|
||||
drawViewControl();
|
||||
|
||||
draw_set_text(f_p0, fa_right, fa_top, COLORS._main_text_sub);
|
||||
draw_text(w - ui(8), ui(8), $"x{graph_s_to}");
|
||||
|
@ -1942,7 +2015,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
drawToolBar();
|
||||
drawMinimap();
|
||||
|
||||
if(pFOCUS) array_foreach(nodes_selecting, function(node) { node.focusStep(); });
|
||||
if(pFOCUS && !view_hovering)
|
||||
array_foreach(nodes_selecting, function(node) { node.focusStep(); });
|
||||
|
||||
if(UPDATE == RENDER_TYPE.full)
|
||||
draw_text(w - ui(8), ui(28), __txtx("panel_graph_rendering", "Rendering") + "...");
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
function Panel_Graph_View_Setting(display) : Panel_Linear_Setting() constructor {
|
||||
function Panel_Graph_View_Setting(graphPanel, display) : Panel_Linear_Setting() constructor {
|
||||
title = __txtx("graph_view_settings", "View Settings");
|
||||
|
||||
w = ui(380);
|
||||
self.graphPanel = graphPanel;
|
||||
display_parameter = display;
|
||||
|
||||
#region data
|
||||
|
@ -41,6 +42,13 @@ function Panel_Graph_View_Setting(display) : Panel_Linear_Setting() constructor
|
|||
function(val) { display_parameter.preview_scale = val; },
|
||||
100,
|
||||
),
|
||||
new __Panel_Linear_Setting_Item(
|
||||
__txt("View Control"),
|
||||
new checkBox(function() { graphPanel.show_view_control = !graphPanel.show_view_control; }),
|
||||
function() { return graphPanel.show_view_control },
|
||||
function(val) { graphPanel.show_view_control = val; },
|
||||
true,
|
||||
),
|
||||
];
|
||||
|
||||
setHeight();
|
||||
|
|
|
@ -70,6 +70,9 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
canvas_zoom_m = 0;
|
||||
canvas_zoom_s = 0;
|
||||
|
||||
view_pan_tool = false;
|
||||
view_zoom_tool = false;
|
||||
|
||||
sample_color = noone;
|
||||
sample_x = noone;
|
||||
sample_y = noone;
|
||||
|
@ -110,6 +113,9 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
bg_color = COLORS.panel_bg_clear;
|
||||
|
||||
mouse_pos_string = "";
|
||||
|
||||
show_info = true;
|
||||
show_view_control = true;
|
||||
#endregion
|
||||
|
||||
#region ---- tool ----
|
||||
|
@ -130,10 +136,11 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
toolbar_width = ui(40);
|
||||
toolbar_height = ui(40);
|
||||
|
||||
tool_hovering = false;
|
||||
tool_hovering = noone;
|
||||
tool_side_draw_l = false;
|
||||
tool_side_draw_r = false;
|
||||
overlay_hovering = false;
|
||||
view_hovering = false;
|
||||
|
||||
sbChannel = new scrollBox([], function(index) { #region
|
||||
var node = getNodePreview();
|
||||
|
@ -343,6 +350,14 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
function() { fullView(); },
|
||||
function() { return 0; },
|
||||
],
|
||||
[
|
||||
THEME.icon_visibility,
|
||||
function() { return __txtx("graph_visibility_title", "Visibility settings"); },
|
||||
function(param) {
|
||||
dialogPanelCall(new Panel_Preview_View_Setting(self), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
|
||||
},
|
||||
function() { return 0; },
|
||||
],
|
||||
];
|
||||
|
||||
static d3_view_action_front = function() { d3_camLerp = 1; d3_camLerp_x = 0; d3_camLerp_y = 0; }
|
||||
|
@ -438,8 +453,10 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
canvas_drag_my = my;
|
||||
setMouseWrap();
|
||||
|
||||
if(mouse_release(canvas_drag_key))
|
||||
if(mouse_release(canvas_drag_key)) {
|
||||
canvas_dragging = false;
|
||||
view_pan_tool = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(canvas_zooming) {
|
||||
|
@ -460,8 +477,10 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
canvas_zoom_m = my;
|
||||
setMouseWrap();
|
||||
|
||||
if(mouse_release(canvas_drag_key))
|
||||
if(mouse_release(canvas_drag_key)) {
|
||||
canvas_zooming = false;
|
||||
view_zoom_tool = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(pHOVER && canvas_hover) {
|
||||
|
@ -550,8 +569,10 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
d3_camPan_my = my;
|
||||
setMouseWrap();
|
||||
|
||||
if(mouse_release(canvas_drag_key))
|
||||
if(mouse_release(canvas_drag_key)) {
|
||||
d3_camPanning = false;
|
||||
view_pan_tool = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(canvas_zooming) {
|
||||
|
@ -563,8 +584,10 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
canvas_zoom_m = my;
|
||||
setMouseWrap();
|
||||
|
||||
if(mouse_release(canvas_drag_key))
|
||||
if(mouse_release(canvas_drag_key)) {
|
||||
canvas_zooming = false;
|
||||
view_zoom_tool = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(pHOVER && canvas_hover) {
|
||||
|
@ -1112,6 +1135,135 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
} #endregion
|
||||
|
||||
function drawPreviewOverlay() { #region
|
||||
|
||||
#region view controller
|
||||
if(show_view_control) {
|
||||
var _view_x = tool_side_draw_l * 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;
|
||||
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);
|
||||
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;
|
||||
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;
|
||||
_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);
|
||||
toolbar_draw = false;
|
||||
|
||||
|
@ -1122,50 +1274,53 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
|
||||
if(right_menu_x == 0) right_menu_x = w - ui(8);
|
||||
|
||||
if(PANEL_PREVIEW == self) {
|
||||
draw_set_text(f_p0, fa_right, fa_top, COLORS._main_text_accent);
|
||||
draw_text(right_menu_x, right_menu_y, __txt("Active"));
|
||||
right_menu_y += _lh;
|
||||
}
|
||||
|
||||
var txt = $"{__txt("fps")} {fps}";
|
||||
if(PREFERENCES.panel_preview_show_real_fps)
|
||||
txt += $" / {FPS_REAL}";
|
||||
|
||||
draw_set_text(f_p0, fa_right, fa_top, fps >= PROJECT.animator.framerate? COLORS._main_text_sub : COLORS._main_value_negative);
|
||||
draw_text(right_menu_x, right_menu_y, txt);
|
||||
right_menu_y += _lh;
|
||||
|
||||
draw_set_text(f_p0, fa_right, fa_top, COLORS._main_text_sub);
|
||||
draw_text(right_menu_x, right_menu_y, $"{__txt("Frame")} {CURRENT_FRAME + 1}/{TOTAL_FRAMES}");
|
||||
|
||||
right_menu_y += _lh;
|
||||
draw_text(right_menu_x, right_menu_y, $"x{canvas_s}");
|
||||
|
||||
if(pHOVER) {
|
||||
right_menu_y += _lh;
|
||||
var mpx = floor((mx - canvas_x) / canvas_s);
|
||||
var mpy = floor((my - canvas_y) / canvas_s);
|
||||
draw_text(right_menu_x, right_menu_y, $"[{mpx}, {mpy}]");
|
||||
|
||||
if(mouse_pos_string != "") {
|
||||
if(show_info) {
|
||||
if(PANEL_PREVIEW == self) {
|
||||
draw_set_text(f_p0, fa_right, fa_top, COLORS._main_text_accent);
|
||||
draw_text(right_menu_x, right_menu_y, __txt("Active"));
|
||||
right_menu_y += _lh;
|
||||
draw_text(right_menu_x, right_menu_y, $"{mouse_pos_string}");
|
||||
}
|
||||
}
|
||||
|
||||
if(_node != noone && !d3_active) {
|
||||
right_menu_y += _lh;
|
||||
var txt = $"{canvas_w} x {canvas_h}px";
|
||||
if(canvas_a) txt = $"{canvas_a} x {txt}";
|
||||
var txt = $"{__txt("fps")} {fps}";
|
||||
if(PREFERENCES.panel_preview_show_real_fps)
|
||||
txt += $" / {FPS_REAL}";
|
||||
|
||||
draw_set_text(f_p0, fa_right, fa_top, fps >= PROJECT.animator.framerate? COLORS._main_text_sub : COLORS._main_value_negative);
|
||||
draw_text(right_menu_x, right_menu_y, txt);
|
||||
|
||||
right_menu_x = w - ui(8);
|
||||
right_menu_y += _lh;
|
||||
|
||||
draw_set_text(f_p0, fa_right, fa_top, COLORS._main_text_sub);
|
||||
draw_text(right_menu_x, right_menu_y, $"{__txt("Frame")} {CURRENT_FRAME + 1}/{TOTAL_FRAMES}");
|
||||
|
||||
right_menu_y += _lh;
|
||||
draw_text(right_menu_x, right_menu_y, $"x{canvas_s}");
|
||||
|
||||
if(pHOVER) {
|
||||
right_menu_y += _lh;
|
||||
var mpx = floor((mx - canvas_x) / canvas_s);
|
||||
var mpy = floor((my - canvas_y) / canvas_s);
|
||||
draw_text(right_menu_x, right_menu_y, $"[{mpx}, {mpy}]");
|
||||
|
||||
if(mouse_pos_string != "") {
|
||||
right_menu_y += _lh;
|
||||
draw_text(right_menu_x, right_menu_y, $"{mouse_pos_string}");
|
||||
}
|
||||
}
|
||||
|
||||
if(_node != noone && !d3_active) {
|
||||
right_menu_y += _lh;
|
||||
var txt = $"{canvas_w} x {canvas_h}px";
|
||||
if(canvas_a) txt = $"{canvas_a} x {txt}";
|
||||
|
||||
draw_text(right_menu_x, right_menu_y, txt);
|
||||
|
||||
right_menu_x = w - ui(8);
|
||||
right_menu_y += _lh;
|
||||
}
|
||||
|
||||
mouse_pos_string = "";
|
||||
}
|
||||
|
||||
mouse_pos_string = "";
|
||||
right_menu_x = w - ui(8);
|
||||
|
||||
#endregion
|
||||
|
@ -1264,6 +1419,7 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
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 params = { w, h, toolbar_height };
|
||||
var mouse_free = false;
|
||||
|
@ -1522,8 +1678,6 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
|
||||
function drawToolBar(_tool) { #region
|
||||
var ty = h - toolbar_height;
|
||||
//draw_sprite_stretched_ext(THEME.toolbar_shadow, 0, 0, ty - 12 + 4, w, 12, c_white, 0.5);
|
||||
|
||||
var aa = d3_active? 0.8 : 1;
|
||||
draw_sprite_stretched_ext(THEME.toolbar, 1, 0, 0, w, topbar_height, c_white, aa);
|
||||
draw_sprite_stretched_ext(THEME.toolbar, 0, 0, ty, w, toolbar_height, c_white, aa);
|
||||
|
@ -1655,7 +1809,7 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
var tbIndex = tb[3]();
|
||||
|
||||
var b = buttonInstant(THEME.button_hide, tbx - ui(14), tby - ui(14), ui(28), ui(28), [mx, my], pFOCUS, pHOVER, tbTooltip, tbSpr, tbIndex);
|
||||
if(b == 2) tb[2]();
|
||||
if(b == 2) tb[2]( { x: x + tbx - ui(14), y: y + tby - ui(14) } );
|
||||
|
||||
tbx -= ui(32);
|
||||
}
|
||||
|
@ -1767,6 +1921,9 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
|
||||
var inspect_node = PANEL_INSPECTOR.getInspecting();
|
||||
|
||||
tool_side_draw_l = false;
|
||||
tool_side_draw_r = false;
|
||||
|
||||
var tool = noone;
|
||||
if(inspect_node) {
|
||||
tool = inspect_node.getTool();
|
||||
|
|
73
scripts/panel_preview_view_settings/panel_console.gml
Normal file
73
scripts/panel_preview_view_settings/panel_console.gml
Normal file
|
@ -0,0 +1,73 @@
|
|||
function Panel_Console() : PanelContent() constructor {
|
||||
title = "Console";
|
||||
w = ui(640);
|
||||
h = ui(320);
|
||||
|
||||
command = "";
|
||||
history = [];
|
||||
cmd_history = [];
|
||||
|
||||
cmd_index = 0;
|
||||
|
||||
keyboard_string = "";
|
||||
|
||||
static submit_command = function() {
|
||||
if(command == "") return;
|
||||
array_push(history, { txt: command, color: COLORS._main_text_sub });
|
||||
array_push(cmd_history, command);
|
||||
|
||||
var cmd = string_splice(command, " ");
|
||||
|
||||
switch(cmd[0]) {
|
||||
case "flag":
|
||||
if(array_length(cmd) < 2) break;
|
||||
var flg = array_safe_get(cmd, 1, "");
|
||||
global.FLAG[$ flg] = !global.FLAG[$ flg];
|
||||
|
||||
array_push(history, { txt: $"Toggled debug flag: {flg} = {global.FLAG[$ flg]? "True" : "False"}", color: COLORS._main_value_positive });
|
||||
break;
|
||||
}
|
||||
|
||||
keyboard_string = "";
|
||||
command = "";
|
||||
}
|
||||
|
||||
function drawContent(panel) {
|
||||
HOTKEY_BLOCK = true;
|
||||
command = keyboard_string;
|
||||
|
||||
draw_clear_alpha(CDEF.main_dkblack, 1);
|
||||
|
||||
draw_set_color(c_black);
|
||||
draw_set_alpha(0.75);
|
||||
draw_rectangle(0, h - ui(28), w, h, false);
|
||||
draw_set_alpha(1);
|
||||
|
||||
draw_set_text(f_code, fa_left, fa_bottom, COLORS._main_text);
|
||||
draw_text(ui(8), h - ui(4), command);
|
||||
draw_set_color(COLORS._main_text_sub);
|
||||
draw_text(ui(8) + string_width(command), h - ui(4), "_");
|
||||
|
||||
var hy = h - ui(32);
|
||||
for( var i = 0; i < array_length(history); i++ ) {
|
||||
var his = history[array_length(history) - i - 1];
|
||||
var txt = his.txt;
|
||||
|
||||
draw_set_color(his.color);
|
||||
draw_text_ext(ui(8), hy, txt, -1, w - ui(16));
|
||||
hy -= string_height_ext(txt, -1, w - ui(16));
|
||||
|
||||
if(hy <= 0) break;
|
||||
}
|
||||
|
||||
if(keyboard_check_pressed(vk_enter))
|
||||
submit_command();
|
||||
|
||||
if(keyboard_check_pressed(vk_up)) {
|
||||
cmd_index = max(0, cmd_index - 1);
|
||||
keyboard_string = array_safe_get(cmd_history, cmd_index, "");
|
||||
command = keyboard_string;
|
||||
} else if(keyboard_check_pressed(vk_anykey))
|
||||
cmd_index = array_length(cmd_history);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
function Panel_Preview_View_Setting(previewPanel) : Panel_Linear_Setting() constructor {
|
||||
title = __txtx("preview_view_settings", "View Settings");
|
||||
|
||||
w = ui(380);
|
||||
self.previewPanel = previewPanel;
|
||||
|
||||
#region data
|
||||
properties = [
|
||||
new __Panel_Linear_Setting_Item(
|
||||
__txt("Info"),
|
||||
new checkBox(function() { previewPanel.show_info = !previewPanel.show_info; }),
|
||||
function() { return previewPanel.show_info },
|
||||
function(val) { previewPanel.show_info = val; },
|
||||
true,
|
||||
),
|
||||
new __Panel_Linear_Setting_Item(
|
||||
__txt("View Control"),
|
||||
new checkBox(function() { previewPanel.show_view_control = !previewPanel.show_view_control; }),
|
||||
function() { return previewPanel.show_view_control },
|
||||
function(val) { previewPanel.show_view_control = val; },
|
||||
true,
|
||||
),
|
||||
];
|
||||
|
||||
setHeight();
|
||||
#endregion
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$GMScript":"",
|
||||
"%Name":"panel_preview_view_settings",
|
||||
"isCompatibility":false,
|
||||
"isDnD":false,
|
||||
"name":"panel_preview_view_settings",
|
||||
"parent":{
|
||||
"name":"preview",
|
||||
"path":"folders/panels/preview.yy",
|
||||
},
|
||||
"resourceType":"GMScript",
|
||||
"resourceVersion":"2.0",
|
||||
}
|
|
@ -2,6 +2,8 @@ function file_read_all(path) { #region
|
|||
INLINE
|
||||
|
||||
var f = file_text_open_read(path);
|
||||
if(!f) return "";
|
||||
|
||||
var s = "";
|
||||
while(!file_text_eof(f))
|
||||
s += string(file_text_readln(f));
|
||||
|
@ -13,6 +15,8 @@ function file_text_read_all_lines(path) { #region
|
|||
INLINE
|
||||
|
||||
var f = file_text_open_read(path);
|
||||
if(!f) return "";
|
||||
|
||||
var s = [];
|
||||
while(!file_text_eof(f))
|
||||
array_push(s, file_text_readln(f));
|
||||
|
@ -26,6 +30,8 @@ function file_text_write_all(path, str) { #region
|
|||
if(file_exists_empty(path)) file_delete(path);
|
||||
|
||||
var f = file_text_open_write(path);
|
||||
if(!f) return "";
|
||||
|
||||
file_text_write_string(f, str);
|
||||
file_text_close(f);
|
||||
} #endregion
|
|
@ -2,19 +2,26 @@ varying vec2 v_vTexcoord;
|
|||
varying vec4 v_vColour;
|
||||
|
||||
uniform vec4 color;
|
||||
uniform int fill;
|
||||
uniform float thickness;
|
||||
uniform float antialias;
|
||||
|
||||
void main() {
|
||||
float dist = abs(length(v_vTexcoord - .5) * 2. - 0.9);
|
||||
|
||||
float a;
|
||||
vec4 c = vec4(0.);
|
||||
float th = thickness == 0.? 0.05 : thickness;
|
||||
float aa = antialias == 0.? 0.05 : antialias;
|
||||
|
||||
a = smoothstep(th + antialias, th, dist);
|
||||
c = mix(c, color, a);
|
||||
float dist = length(v_vTexcoord - .5) * 2. - (1. - th - aa);
|
||||
float a;
|
||||
|
||||
if(fill == 0) {
|
||||
dist = abs(dist);
|
||||
a = smoothstep(th + aa, th, dist);
|
||||
|
||||
} else if(fill == 1) {
|
||||
a = smoothstep(aa, 0., dist);
|
||||
}
|
||||
|
||||
vec4 c = mix(vec4(0.), color, a);
|
||||
|
||||
gl_FragColor = c;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue