From 586fa1fe66ff5414e0532bb1126e9a27d2195cf2 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sat, 11 May 2024 09:56:08 +0700 Subject: [PATCH] canvas, preview panels --- scripts/canvas_tool_curve/canvas_tool_curve.gml | 1 + .../canvas_tool_selection.gml | 14 ++++++++------ scripts/hotkey_data/hotkey_data.gml | 2 +- scripts/node_tool/node_tool.gml | 6 ++---- scripts/panel_preview/panel_preview.gml | 7 +++++-- scripts/tooltip_hotkey/tooltip_hotkey.gml | 4 +++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/scripts/canvas_tool_curve/canvas_tool_curve.gml b/scripts/canvas_tool_curve/canvas_tool_curve.gml index bc74f9c1e..30b42e30f 100644 --- a/scripts/canvas_tool_curve/canvas_tool_curve.gml +++ b/scripts/canvas_tool_curve/canvas_tool_curve.gml @@ -122,6 +122,7 @@ function canvas_tool_curve_bezier(brush) : canvas_tool() constructor { function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { draw_surface_ext_safe(drawing_surface, _x, _y, _s, _s); + canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y); } function drawMask(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { diff --git a/scripts/canvas_tool_selection/canvas_tool_selection.gml b/scripts/canvas_tool_selection/canvas_tool_selection.gml index 3b833d51d..b300325fe 100644 --- a/scripts/canvas_tool_selection/canvas_tool_selection.gml +++ b/scripts/canvas_tool_selection/canvas_tool_selection.gml @@ -198,12 +198,14 @@ function canvas_tool_selection(selector = noone) : canvas_tool() constructor { var sel_h = surface_get_height_safe(selection_surface); if(point_in_rectangle(mouse_cur_x, mouse_cur_y, pos_x, pos_y, pos_x + sel_w, pos_y + sel_h)) { - is_select_drag = true; - selection_sx = pos_x; - selection_sy = pos_y; - selection_mx = mouse_cur_x; - selection_my = mouse_cur_y; - + var _c = surface_getpixel_ext(selection_mask, mouse_cur_x - pos_x, mouse_cur_y - pos_y); + if(_c > 0) { + is_select_drag = true; + selection_sx = pos_x; + selection_sy = pos_y; + selection_mx = mouse_cur_x; + selection_my = mouse_cur_y; + } } } diff --git a/scripts/hotkey_data/hotkey_data.gml b/scripts/hotkey_data/hotkey_data.gml index e240fbdc4..6c6d64ee3 100644 --- a/scripts/hotkey_data/hotkey_data.gml +++ b/scripts/hotkey_data/hotkey_data.gml @@ -8,7 +8,7 @@ "Eraser": new hotkeySimple("E"), "Rectangle": new hotkeySimple("N"), "Ellipse": new hotkeySimple("M"), - "Fill": new hotkeySimple("F"), + "Fill": new hotkeySimple("G"), "Freeform": new hotkeySimple("Q"), }, "Node_Mesh_Warp": { diff --git a/scripts/node_tool/node_tool.gml b/scripts/node_tool/node_tool.gml index c08f3e489..85bf9fd93 100644 --- a/scripts/node_tool/node_tool.gml +++ b/scripts/node_tool/node_tool.gml @@ -26,12 +26,10 @@ function NodeTool(name, spr, context = instanceof(other)) constructor { static getToolObject = function() { return is_array(toolObject)? toolObject[selecting] : toolObject; } static getDisplayName = function(index = 0) { + var _nme = getName(index); var _key = checkHotkey(); - var _nme = getName(index); - if(_key != "") _nme += $" ({_key})"; - - return _nme; + return _key == ""? _nme : new tooltipHotkey(_nme).setKey(_key); } static setSetting = function(sets) { array_push(settings, sets); return self; } diff --git a/scripts/panel_preview/panel_preview.gml b/scripts/panel_preview/panel_preview.gml index 779a9c672..c8c059d3d 100644 --- a/scripts/panel_preview/panel_preview.gml +++ b/scripts/panel_preview/panel_preview.gml @@ -1109,14 +1109,17 @@ function Panel_Preview() : PanelContent() constructor { mouse_pos_string = ""; - right_menu_x = w - ui(8); - if(_node == noone) return; + if(_node == noone) { + right_menu_x = w - ui(8); + return; + } right_menu_y += string_height("l"); 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 += string_height("l"); #endregion diff --git a/scripts/tooltip_hotkey/tooltip_hotkey.gml b/scripts/tooltip_hotkey/tooltip_hotkey.gml index 3aa0c1968..9e0114abf 100644 --- a/scripts/tooltip_hotkey/tooltip_hotkey.gml +++ b/scripts/tooltip_hotkey/tooltip_hotkey.gml @@ -1,9 +1,11 @@ -function tooltipHotkey(text, context, name) constructor { +function tooltipHotkey(text, context = "", name = "") constructor { self.text = text; self.hotkey = find_hotkey(context, name); keyStr = hotkey? key_get_name(hotkey.key, hotkey.modi) : ""; + static setKey = function(key) { keyStr = key; return self; } + static drawTooltip = function() { draw_set_font(f_p0); var _w1 = string_width(text);