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
This commit is contained in:
parent
00511eb8c1
commit
83645dbeae
|
|
@ -118,6 +118,12 @@ local S = {
|
||||||
previewLayoutValue = 2, -- number for fixed cols/rows
|
previewLayoutValue = 2, -- number for fixed cols/rows
|
||||||
previewMode = "all", -- "all", "single", or "static"
|
previewMode = "all", -- "all", "single", or "static"
|
||||||
previewSingleIdx = 1, -- which animation to show in single mode
|
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
|
-- Current preset
|
||||||
currentPreset = "Default",
|
currentPreset = "Default",
|
||||||
}
|
}
|
||||||
|
|
@ -414,6 +420,8 @@ local function saveMaster()
|
||||||
f:write("previewZoomAll=" .. S.previewZoomAll .. "\n")
|
f:write("previewZoomAll=" .. S.previewZoomAll .. "\n")
|
||||||
f:write("previewZoomOne=" .. S.previewZoomOne .. "\n")
|
f:write("previewZoomOne=" .. S.previewZoomOne .. "\n")
|
||||||
f:write("previewZoomSta=" .. S.previewZoomSta .. "\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")
|
f:write("previewSingleIdx=" .. S.previewSingleIdx .. "\n")
|
||||||
-- File associations
|
-- File associations
|
||||||
for filepath, preset in pairs(filePresetMap) do
|
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 == "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 == "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 == "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 == "previewSingleIdx" then S.previewSingleIdx = tonumber(v) or 1 end
|
||||||
if k == "presetNames" and v ~= "" then
|
if k == "presetNames" and v ~= "" then
|
||||||
knownPresetNames = {}
|
knownPresetNames = {}
|
||||||
|
|
@ -1407,21 +1417,23 @@ openPreviewWindow = function()
|
||||||
onpaint = function(ev)
|
onpaint = function(ev)
|
||||||
local gc = ev.context
|
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.previewMode == "static" then
|
||||||
if S.sourceImage then
|
if S.sourceImage then
|
||||||
local z = pvZoom()
|
local z = pvZoom()
|
||||||
|
local sx = S.previewStaScrollX
|
||||||
|
local sy = S.previewStaScrollY
|
||||||
local sw = S.sourceImage.width * z
|
local sw = S.sourceImage.width * z
|
||||||
local sh = S.sourceImage.height * z
|
local sh = S.sourceImage.height * z
|
||||||
if S.useBgColor then
|
if S.useBgColor then
|
||||||
gc.color = S.bgColor
|
gc.color = S.bgColor
|
||||||
gc:fillRect(Rectangle(0, 0, sw, sh))
|
gc:fillRect(Rectangle(sx, sy, sw, sh))
|
||||||
else
|
else
|
||||||
drawCheckerboard(gc, sw, sh, z, 0, 0)
|
drawCheckerboard(gc, sw, sh, z, sx, sy)
|
||||||
end
|
end
|
||||||
gc:drawImage(S.sourceImage,
|
gc:drawImage(S.sourceImage,
|
||||||
Rectangle(0, 0, S.sourceImage.width, S.sourceImage.height),
|
Rectangle(0, 0, S.sourceImage.width, S.sourceImage.height),
|
||||||
Rectangle(0, 0, sw, sh))
|
Rectangle(sx, sy, sw, sh))
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -1492,7 +1504,15 @@ openPreviewWindow = function()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
onmousedown = function(ev)
|
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
|
-- In single mode: L-click=prev anim, R-click=next anim
|
||||||
if S.previewMode == "single" then
|
if S.previewMode == "single" then
|
||||||
if ev.button == MouseButton.LEFT then
|
if ev.button == MouseButton.LEFT then
|
||||||
|
|
@ -1518,6 +1538,22 @@ openPreviewWindow = function()
|
||||||
end
|
end
|
||||||
end
|
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)
|
onwheel = function(ev)
|
||||||
local dz = ev.deltaY < 0 and 1 or -1
|
local dz = ev.deltaY < 0 and 1 or -1
|
||||||
if S.previewMode == "single" then
|
if S.previewMode == "single" then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue