diff --git a/aniphallow.lua b/aniphallow.lua index 68fe805..e236ee4 100644 --- a/aniphallow.lua +++ b/aniphallow.lua @@ -1314,15 +1314,14 @@ openPreviewWindow = function() S.previewSingleIdx = 1 end - -- calcPreviewSize helper + -- calcPreviewSize helper (Sta mode excluded — uses last All/One size) local function calcPreviewSize() - local z = pvZoom() + local z if S.previewMode == "static" then - -- Static mode: show full sprite canvas - if app.sprite then - return app.sprite.width * z, app.sprite.height * z - end - return 120, 40 + -- Don't try to auto-size for Sta; fall through to All sizing + z = S.previewZoomAll + else + z = pvZoom() end local ptw = S.tileW * z local pth = S.tileH * z @@ -1384,6 +1383,7 @@ openPreviewWindow = function() end elseif S.previewMode == "single" then S.previewMode = "static" + refreshSource() -- ensure source image is ready else S.previewMode = "all" end @@ -1586,18 +1586,25 @@ openPreviewWindow = function() } previewTimer:start() + local pvStaLastVersion = 0 -- track sprite version to detect edits + local pvStaLastFrame = 0 + pvRefreshTimer = Timer{ interval = 0.5, ontick = function() - local prevImg = S.sourceImage - refreshSource() refreshLockFile() - -- In static mode, only repaint if source image changed if S.previewMode == "static" then - if S.sourceImage ~= prevImg then + -- Only refresh source and repaint when sprite actually changed + local curVer = app.sprite and app.sprite.version or 0 + local curFrame = app.frame and app.frame.frameNumber or 0 + if curVer ~= pvStaLastVersion or curFrame ~= pvStaLastFrame then + pvStaLastVersion = curVer + pvStaLastFrame = curFrame + refreshSource() pcall(function() previewDlg:repaint() end) end else + refreshSource() pcall(function() previewDlg:repaint() end) end