Skip to content

Commit

Permalink
Reverse Slideshow
Browse files Browse the repository at this point in the history
* Slideshow can now be reversed.
  * Hotkey: SHIFT+R
  • Loading branch information
sdneon committed Nov 8, 2023
1 parent 73ed43f commit 4041b14
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/JPEGView/Config/KeyMap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Alt+Z 7030 //SORT_RANDOM: sorting order random
//no_hotkey 7040 //SORT_SIZE: sorting order file size in bytes
//no_hotkey 7100 //SORT_UPCOUNTING: sort upcounting
//no_hotkey 7110 //SORT_DOWNCOUNTING: sort downcounting
Shift+R 7398 //SLIDESHOW: toggle direction
Alt+R 7399 //SLIDESHOW_RESUME: resume slide show (after stop)
Shift+Space 7401 //SLIDESHOW_1: start slide show @ 1fps
Alt+Shift+R 7421 //SLIDESHOW_CUSTOM: start slide show @ custom fps, specified via INI SlildeShowCustomInterval
Expand Down
48 changes: 42 additions & 6 deletions src/JPEGView/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ CMainDlg::CMainDlg(bool bForceFullScreen):
m_bSelectMode(false),
m_bSingleZoom(false),
m_nTransparencyMode(Helpers::TP_BLEND),
m_bSlideShowForward(true),
m_hToastFont(0),
m_strToast(""),
m_nImageRetryCnt(0)
Expand Down Expand Up @@ -881,7 +882,6 @@ LRESULT CMainDlg::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, B
m_pPanelMgr->OnPostPaint(dc);

SetCursorForMoveSection();

return 0;
}

Expand Down Expand Up @@ -1992,6 +1992,10 @@ void CMainDlg::ExecuteCommand(int nCommand) {
SetToast(_T("Play"));
StartMovieMode(m_dSlideShowCustomFps);
break;
case IDM_SLIDESHOW_TOGGLE_DIR:
m_bSlideShowForward = !m_bSlideShowForward;
SetToast(m_bSlideShowForward? _T("Forward"): _T("Reverse"));
break;
case IDM_TOGGLE_MIN_FILESIZE:
{
bool bWasInMovieMode = m_bMovieMode;
Expand Down Expand Up @@ -2761,6 +2765,7 @@ bool CMainDlg::SaveImage(bool bFullSize) {
if (sExtension.IsEmpty()) {
sExtension = CSettingsProvider::This().DefaultSaveFormat();
}
// NOTE: this list is used in the "Edit with" registry entry in JPEGView.Setup, update that when this updates
CFileDialog fileDlg(FALSE, sExtension, sCurrentFile,
OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT,
Helpers::CReplacePipe(CString(_T("JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|BMP (*.bmp)|*.bmp|PNG (*.png)|*.png|TIFF (*.tiff;*.tif)|*.tiff;*.tif|WEBP (*.webp)|*.webp|WEBP lossless (*.webp)|*.webp|AVIF (*.avif)|*.avif|AVIF lossless (*.avif)|*.avif|QOI (*.qoi)|*.qoi|")) +
Expand Down Expand Up @@ -3080,11 +3085,20 @@ void CMainDlg::GotoImage(EImagePosition ePos, int nFlags) {
{
bool bGotoNextImage;
nFrameIndex = Helpers::GetFrameIndex(m_pCurrentImage, true, ePos == POS_NextAnimation, bGotoNextImage);
if (bGotoNextImage) m_pFileList = m_pFileList->Next();
if (bGotoNextImage)
{
if (m_bSlideShowForward)
m_pFileList = m_pFileList->Next();
else
m_pFileList = m_pFileList->Prev();
}
break;
}
case POS_NextSlideShow:
m_pFileList = m_pFileList->Next();
if (m_bSlideShowForward)
m_pFileList = m_pFileList->Next();
else
m_pFileList = m_pFileList->Prev();
break;
case POS_Previous:
{
Expand Down Expand Up @@ -3119,7 +3133,7 @@ void CMainDlg::GotoImage(EImagePosition ePos, int nFlags) {
}
case POS_Next_Folder:
{
m_pFileList = m_pFileList->NextFolder();
m_pFileList = m_pFileList->NextFolder();
break;
}
case POS_Previous_Folder:
Expand Down Expand Up @@ -3302,6 +3316,27 @@ void CMainDlg::PerformZoom(double dValue, bool bExponent, bool bZoomToMouse, boo
nNewYSize = (int)(m_pCurrentImage->OrigHeight() * m_dZoom + 0.5);
}

// because we've increased/decreased to the maximum zoom allowed,
// only actually perform the zoom if the old and new dimensions differ
// the float arithmetic doesn't always come up with the same answer, but the new sizes can be directly compared
if (nNewXSize == nOldXSize && nNewYSize == nOldYSize) {
// because there's rounding errors, it is possible to get stuck zooming out from fractional zoom,
// due to the new/old size being the same, but the zoom factor still changing
// hence, only reset the zoom value IF when zooming out (aka, it is getting smaller)
//
// when zooming in, do not set the old zoom value so that it can "escape" the initial few steps where
// the zoom ratio has changed, but the size is still the same, due to rounding errors
if (bExponent && dValue < 0) {
// zooming out
// NOTE: this gets triggered on pauseAtZoom
m_dZoom = dOldZoom; // restore previous zoom value
}
// zooming in does not require restoring the previous zoom value
// because the code which checks the 65535 will re-scale the zoom factor to ensure it never exceeds 65535

return; // then do nothing
}

if (bZoomToMouse) {
// zoom to mouse
int nCenterX = m_bZoomMode ? m_nCapturedX : m_nMouseX;
Expand Down Expand Up @@ -3437,7 +3472,8 @@ void CMainDlg::ResetZoomToFitScreen(bool bFillWithCrop, bool bAllowEnlarge, bool

void CMainDlg::ResetZoomTo100Percents(bool bZoomToMouse) {
if (m_pCurrentImage != NULL && fabs(m_dZoom - 1) > 0.01) {
PerformZoom(1.0, false, bZoomToMouse, true);
// the current design (unless changed) cursor always shows in windowed mode, so always zoom to cursor when not fullscreen
PerformZoom(1.0, false, bZoomToMouse || !m_bFullScreenMode, true);
}
}

Expand Down Expand Up @@ -3596,7 +3632,7 @@ void CMainDlg::AdjustMovieSpeed(double dIncrement)
/*
//Available steps (interval, s): 1,2,3,4,5,7,10,20
// ~> (fps): 1, 0.5, 0.33, 0.25, 0.2, 0.143, 0.1, 0.05
//AVailable movie mode fps: 5, 10, 25, 30, 50, 100
//Available movie mode fps: 3, 5, 10, 25, 30, 50, 100
We'll change to stepping thru' above choices instead
*/
if (dIncrement < 0.0)
Expand Down
1 change: 1 addition & 0 deletions src/JPEGView/MainDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ class CMainDlg : public CDialogImpl<CMainDlg>
bool m_bSelectMode, m_bSingleZoom,
m_bMinFilesize, m_bHideHidden;
Helpers::ETransparencyMode m_nTransparencyMode; //for transparent background
bool m_bSlideShowForward; //direction of slideshow
bool m_bWindowBorderless;
bool m_bAlwaysOnTop;
//Toast stuff
Expand Down
1 change: 1 addition & 0 deletions src/JPEGView/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
#define IDM_SORT_SIZE 7040
#define IDM_SORT_UPCOUNTING 7100
#define IDM_SORT_DOWNCOUNTING 7110
#define IDM_SLIDESHOW_TOGGLE_DIR 7398
#define IDM_SLIDESHOW_RESUME 7399
#define IDM_SLIDESHOW_START 7400
#define IDM_SLIDESHOW_1 7401
Expand Down

0 comments on commit 4041b14

Please sign in to comment.