diff --git a/src/JPEGView/Config/JPEGView.ini b/src/JPEGView/Config/JPEGView.ini index 4250c717..33d818c2 100644 --- a/src/JPEGView/Config/JPEGView.ini +++ b/src/JPEGView/Config/JPEGView.ini @@ -173,6 +173,11 @@ BlendFactorNavPanel=0.5 ; Scaling factor for the navigation panel. Increase if the buttons on the panel are too small, e.g. on a touchscreen. ScaleFactorNavPanel=1.0 +; Enables/Disables the 'Zoom Steps' feature. +UseZoomSteps=false + +; User defined percentages for the 'Zoom Steps' feature. +CustomZoomSteps=3, 5, 10, 14, 16, 20, 25, 33, 50, 75, 100, 125, 150, 175, 200, 250, 300, 400, 600, 800, 1000, 1200, 1600, 2400, 3200, 6400 ; ***************************************************************************** diff --git a/src/JPEGView/MainDlg.cpp b/src/JPEGView/MainDlg.cpp index f6603121..06b6781a 100644 --- a/src/JPEGView/MainDlg.cpp +++ b/src/JPEGView/MainDlg.cpp @@ -2603,8 +2603,25 @@ bool CMainDlg::PerformZoom(double dValue, bool bExponent, bool bZoomToMouse, boo double dOldZoom = m_dZoom; m_bUserZoom = true; m_isUserFitToScreen = false; + if (bExponent) { m_dZoom = m_dZoom * pow(m_dZoomMult, dValue); + + bool useZoomSteps = CSettingsProvider::This().UseZoomSteps(); + + if (useZoomSteps) { + std::vector zoomLevels = CSettingsProvider::This().CustomZoomSteps(); + + if (dOldZoom > zoomLevels[0] && dOldZoom < zoomLevels.back()) { + if (dValue > 0) { + m_dZoom = zoomLevels[distance(zoomLevels.begin(), std::lower_bound(zoomLevels.begin(), zoomLevels.end(), dOldZoom + 0.01))]; + } + else { + m_dZoom = zoomLevels[distance(zoomLevels.begin(), std::lower_bound(zoomLevels.begin(), zoomLevels.end(), dOldZoom)) - 1]; + } + } + } + } else { m_dZoom = dValue; } diff --git a/src/JPEGView/SettingsProvider.cpp b/src/JPEGView/SettingsProvider.cpp index ca5f7ed4..fdee91e0 100644 --- a/src/JPEGView/SettingsProvider.cpp +++ b/src/JPEGView/SettingsProvider.cpp @@ -3,7 +3,7 @@ #include "NLS.h" #include #include -#include +#include static const TCHAR* DEFAULT_INI_FILE_NAME = _T("JPEGView.ini"); static const TCHAR* SECTION_NAME = _T("JPEGView"); @@ -120,7 +120,6 @@ CSettingsProvider::CSettingsProvider(void) { m_bShowZoomNavigator = GetBool(_T("ShowZoomNavigator"), true); m_fBlendFactorNavPanel = (float)GetDouble(_T("BlendFactorNavPanel"), 0.5, 0.0, 1.0); m_fScaleFactorNavPanel = (float)GetDouble(_T("ScaleFactorNavPanel"), 1.0, 0.8, 2.5); - CString sCPU = GetString(_T("CPUType"), _T("AutoDetect")); if (sCPU.CompareNoCase(_T("Generic")) == 0) { m_eCPUAlgorithm = Helpers::CPU_Generic; @@ -218,6 +217,8 @@ CSettingsProvider::CSettingsProvider(void) { m_bExplicitWindowRect = true; } + m_bUseZoomSteps = GetBool(_T("UseZoomSteps"), false); + m_sCustomZoomSteps = ParseCustomZoomSteps(GetString(_T("CustomZoomSteps"), _T("3, 5, 10, 14, 16, 20, 25, 33, 50, 75, 100, 125, 150, 175, 200, 250, 300, 400, 600, 800, 1000, 1200, 1600, 2400, 3200, 6400"))); m_colorBackground = GetColor(_T("BackgroundColor"), 0); m_colorGUI = GetColor(_T("GUIColor"), RGB(243, 242, 231)); m_colorHighlight = GetColor(_T("HighlightColor"), RGB(255, 205, 0)); @@ -405,7 +406,7 @@ void CSettingsProvider::ReadWriteableINISettings() { m_dBrightenShadows = GetDouble(_T("LDCBrightenShadows"), 0.5, 0.0, 1.0); m_dDarkenHighlights = GetDouble(_T("LDCDarkenHighlights"), 0.25, 0.0, 1.0); m_dBrightenShadowsSteepness = GetDouble(_T("LDCBrightenShadowsSteepness"), 0.5, 0.0, 1.0); - CString sNavigation = GetString(_T("FolderNavigation"), _T("LoopFolder")); + CString sNavigation = GetString(_T("FolderNavigation"), _T("LoopFolder")); if (sNavigation.CompareNoCase(_T("LoopSameFolderLevel")) == 0) { m_eNavigation = Helpers::NM_LoopSameDirectoryLevel; } @@ -501,7 +502,6 @@ void CSettingsProvider::SaveSettings(const CImageProcessingParams& procParams, WriteBool(_T("ShowFileInfo"), bShowFileInfo); WriteString(_T("SlideShowTransitionEffect"), Helpers::ConvertTransitionEffectToString(eSlideShowTransitionEffect)); - m_bUserINIExists = true; ReadWriteableINISettings(); } @@ -698,6 +698,28 @@ LPCTSTR CSettingsProvider::ReadIniString(LPCTSTR key, LPCTSTR fileName, IniHashM } } +std::vector CSettingsProvider::ParseCustomZoomSteps(LPCTSTR data) { + std::vector numbers; + std::string sData = CT2A(data); + std::string part; + + for (char it : sData) { + if (it == ',') { + numbers.push_back(stod(part) / 100.0); + part = ""; + continue; + } + else if (it == ' ') { + continue; + } + + part += it; + } + + numbers.push_back(stod(part) / 100.0); + return numbers; +} + void CSettingsProvider::ReadIniFile(LPCTSTR fileName, IniHashMap* keyMap, TCHAR*& pBuffer) { int bufferSize = 1024 * 2; @@ -730,6 +752,7 @@ void CSettingsProvider::ReadIniFile(LPCTSTR fileName, IniHashMap* keyMap, TCHAR* } } + CString CSettingsProvider::GetString(LPCTSTR sKey, LPCTSTR sDefault) { if (m_bUserINIExists) { // try first user path diff --git a/src/JPEGView/SettingsProvider.h b/src/JPEGView/SettingsProvider.h index 082978e8..086f6216 100644 --- a/src/JPEGView/SettingsProvider.h +++ b/src/JPEGView/SettingsProvider.h @@ -130,6 +130,8 @@ class CSettingsProvider bool FlashWindowAlert() { return m_bFlashWindowAlert; } bool BeepSoundAlert() { return m_bBeepSoundAlert; } double ZoomPauseFactor() { return m_zoomPauseFactor; } // while internally this is represented in doubles, using a whole number percent simplifies it for the user... configuring doubles is not user friendly at all + bool UseZoomSteps() { return m_bUseZoomSteps; } + std::vector CustomZoomSteps() { return m_sCustomZoomSteps; } // Returns if a user INI file exists bool ExistsUserINI(); @@ -296,7 +298,8 @@ class CSettingsProvider bool m_bFlashWindowAlert; bool m_bBeepSoundAlert; int m_zoomPauseFactor; - + bool m_bUseZoomSteps; + std::vector m_sCustomZoomSteps; std::list m_userCommands; std::list m_openWithCommands; @@ -324,6 +327,7 @@ class CSettingsProvider COLORREF GetColor(LPCTSTR sKey, COLORREF defaultColor); Helpers::EAutoZoomMode GetAutoZoomMode(LPCTSTR sKey, Helpers::EAutoZoomMode defaultZoomMode); LPCTSTR GetAutoZoomModeString(Helpers::EAutoZoomMode autoZoomMode); + std::vector ParseCustomZoomSteps(LPCTSTR data); void WriteString(LPCTSTR sKey, LPCTSTR sString); void WriteDouble(LPCTSTR sKey, double dValue); void WriteBool(LPCTSTR sKey, bool bValue);