From 83645dbeae0c76681bc3443c392ee888ddfe7428 Mon Sep 17 00:00:00 2001 From: Cidwel Highwind Date: Sat, 4 Apr 2026 12:42:34 +0200 Subject: [PATCH] Add scroll/pan support for Sta preview mode - Right-click drag to pan the canvas in static mode - Scroll position (X/Y) persisted across sessions - Uses independent zoom and scroll settings from One/All modes --- aniphallow.lua | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/aniphallow.lua b/aniphallow.lua index 954087c..8c44f13 100644 --- a/aniphallow.lua +++ b/aniphallow.lua @@ -118,6 +118,12 @@ local S = { previewLayoutValue = 2, -- number for fixed cols/rows previewMode = "all", -- "all", "single", or "static" previewSingleIdx = 1, -- which animation to show in single mode + -- Static preview scroll/pan + previewStaScrollX = 0, + previewStaScrollY = 0, + previewStaDragging = false, + previewStaDragLastX = 0, + previewStaDragLastY = 0, -- Current preset currentPreset = "Default", } @@ -414,6 +420,8 @@ local function saveMaster() f:write("previewZoomAll=" .. S.previewZoomAll .. "\n") f:write("previewZoomOne=" .. S.previewZoomOne .. "\n") f:write("previewZoomSta=" .. S.previewZoomSta .. "\n") + f:write("previewStaScrollX=" .. S.previewStaScrollX .. "\n") + f:write("previewStaScrollY=" .. S.previewStaScrollY .. "\n") f:write("previewSingleIdx=" .. S.previewSingleIdx .. "\n") -- File associations for filepath, preset in pairs(filePresetMap) do @@ -442,6 +450,8 @@ local function loadMaster() if k == "previewZoomAll" then S.previewZoomAll = tonumber(v) or DEFAULT_PREVIEW_ZOOM end if k == "previewZoomOne" then S.previewZoomOne = tonumber(v) or DEFAULT_PREVIEW_ZOOM end if k == "previewZoomSta" then S.previewZoomSta = tonumber(v) or DEFAULT_PREVIEW_ZOOM end + if k == "previewStaScrollX" then S.previewStaScrollX = tonumber(v) or 0 end + if k == "previewStaScrollY" then S.previewStaScrollY = tonumber(v) or 0 end if k == "previewSingleIdx" then S.previewSingleIdx = tonumber(v) or 1 end if k == "presetNames" and v ~= "" then knownPresetNames = {} @@ -1407,21 +1417,23 @@ openPreviewWindow = function() onpaint = function(ev) local gc = ev.context - -- Static mode: render full sprite canvas + -- Static mode: render full sprite canvas with scroll offset if S.previewMode == "static" then if S.sourceImage then local z = pvZoom() + local sx = S.previewStaScrollX + local sy = S.previewStaScrollY local sw = S.sourceImage.width * z local sh = S.sourceImage.height * z if S.useBgColor then gc.color = S.bgColor - gc:fillRect(Rectangle(0, 0, sw, sh)) + gc:fillRect(Rectangle(sx, sy, sw, sh)) else - drawCheckerboard(gc, sw, sh, z, 0, 0) + drawCheckerboard(gc, sw, sh, z, sx, sy) end gc:drawImage(S.sourceImage, Rectangle(0, 0, S.sourceImage.width, S.sourceImage.height), - Rectangle(0, 0, sw, sh)) + Rectangle(sx, sy, sw, sh)) end return end @@ -1492,7 +1504,15 @@ openPreviewWindow = function() end end, onmousedown = function(ev) - if S.previewMode == "static" then return end + -- Static mode: right-click drag to scroll + if S.previewMode == "static" then + if ev.button == MouseButton.RIGHT then + S.previewStaDragging = true + S.previewStaDragLastX = ev.x + S.previewStaDragLastY = ev.y + end + return + end -- In single mode: L-click=prev anim, R-click=next anim if S.previewMode == "single" then if ev.button == MouseButton.LEFT then @@ -1518,6 +1538,22 @@ openPreviewWindow = function() end end end, + onmousemove = function(ev) + if S.previewMode == "static" and S.previewStaDragging then + local dx = ev.x - S.previewStaDragLastX + local dy = ev.y - S.previewStaDragLastY + S.previewStaScrollX = S.previewStaScrollX + dx + S.previewStaScrollY = S.previewStaScrollY + dy + S.previewStaDragLastX = ev.x + S.previewStaDragLastY = ev.y + previewDlg:repaint() + end + end, + onmouseup = function(ev) + if S.previewMode == "static" then + S.previewStaDragging = false + end + end, onwheel = function(ev) local dz = ev.deltaY < 0 and 1 or -1 if S.previewMode == "single" then