From 3cd580e4ba73e07c6df6d0322b79abc6d71baf52 Mon Sep 17 00:00:00 2001 From: cs-mt <110451185+cs-mt@users.noreply.github.com> Date: Sun, 5 Mar 2023 15:57:18 +0300 Subject: [PATCH 1/4] Added Fixed Zoom Levels --- src/JPEGView/MainDlg.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/JPEGView/MainDlg.cpp b/src/JPEGView/MainDlg.cpp index e4036abd..d87cdf7e 100644 --- a/src/JPEGView/MainDlg.cpp +++ b/src/JPEGView/MainDlg.cpp @@ -2602,8 +2602,21 @@ void 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); + + std::vector zoomLevels = { 0.03, 0.05, 0.1, 0.14, 0.16, 0.20, 0.25, 0.33, 0.5, 0.67, 0.75, 0.8, 0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 5.0 }; + + 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; } From 2d14a5e6494e244844dc87b37f09a18b2cca0369 Mon Sep 17 00:00:00 2001 From: cs-mt <110451185+cs-mt@users.noreply.github.com> Date: Mon, 6 Mar 2023 00:33:47 +0300 Subject: [PATCH 2/4] Add Zoom Steps Setting --- src/JPEGView/Config/JPEGView.ini | 5 +++++ src/JPEGView/MainDlg.cpp | 18 +++++++++++------- src/JPEGView/SettingsProvider.cpp | 31 ++++++++++++++++++++++++++++++- src/JPEGView/SettingsProvider.h | 7 +++++++ 4 files changed, 53 insertions(+), 8 deletions(-) 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 e03c9816..06b6781a 100644 --- a/src/JPEGView/MainDlg.cpp +++ b/src/JPEGView/MainDlg.cpp @@ -2607,14 +2607,18 @@ bool CMainDlg::PerformZoom(double dValue, bool bExponent, bool bZoomToMouse, boo if (bExponent) { m_dZoom = m_dZoom * pow(m_dZoomMult, dValue); - std::vector zoomLevels = { 0.03, 0.05, 0.1, 0.14, 0.16, 0.20, 0.25, 0.33, 0.5, 0.67, 0.75, 0.8, 0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 5.0 }; + bool useZoomSteps = CSettingsProvider::This().UseZoomSteps(); - 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]; + 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]; + } } } diff --git a/src/JPEGView/SettingsProvider.cpp b/src/JPEGView/SettingsProvider.cpp index ca5f7ed4..51d2c2a4 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,6 +120,7 @@ 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) { @@ -218,6 +219,9 @@ CSettingsProvider::CSettingsProvider(void) { m_bExplicitWindowRect = true; } + m_bUseZoomSteps = GetBool(_T("UseZoomSteps"), false); + m_sCustomZoomSteps = ParseCustomZoomSteps(GetString(_T("CustomZoomSteps"), _T("100,200,300"))); + 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,6 +409,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")); if (sNavigation.CompareNoCase(_T("LoopSameFolderLevel")) == 0) { m_eNavigation = Helpers::NM_LoopSameDirectoryLevel; @@ -502,6 +507,7 @@ void CSettingsProvider::SaveSettings(const CImageProcessingParams& procParams, WriteString(_T("SlideShowTransitionEffect"), Helpers::ConvertTransitionEffectToString(eSlideShowTransitionEffect)); + m_bUserINIExists = true; ReadWriteableINISettings(); } @@ -698,6 +704,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 +758,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..30165d0d 100644 --- a/src/JPEGView/SettingsProvider.h +++ b/src/JPEGView/SettingsProvider.h @@ -131,6 +131,11 @@ class CSettingsProvider 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 + std::vector ParseCustomZoomSteps(LPCTSTR data); + bool UseZoomSteps() { return m_bUseZoomSteps; } + std::vector CustomZoomSteps() { return m_sCustomZoomSteps; } + + // Returns if a user INI file exists bool ExistsUserINI(); // Copies the user INI file (in AppData/Roaming) from the INI file template JPEGView.ini.tpl @@ -296,6 +301,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; From f3207a98833e95e2bb2c51ff9c2e42e21f8464a5 Mon Sep 17 00:00:00 2001 From: cs-mt <110451185+cs-mt@users.noreply.github.com> Date: Mon, 6 Mar 2023 00:35:12 +0300 Subject: [PATCH 3/4] Fix Default Custom Zoom Steps Value --- src/JPEGView/SettingsProvider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JPEGView/SettingsProvider.cpp b/src/JPEGView/SettingsProvider.cpp index 51d2c2a4..08d73ad1 100644 --- a/src/JPEGView/SettingsProvider.cpp +++ b/src/JPEGView/SettingsProvider.cpp @@ -220,7 +220,7 @@ CSettingsProvider::CSettingsProvider(void) { } m_bUseZoomSteps = GetBool(_T("UseZoomSteps"), false); - m_sCustomZoomSteps = ParseCustomZoomSteps(GetString(_T("CustomZoomSteps"), _T("100,200,300"))); + 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)); From 1830400a738bc3d3e4f4b470218958a9c454d2f5 Mon Sep 17 00:00:00 2001 From: cs-mt <110451185+cs-mt@users.noreply.github.com> Date: Mon, 6 Mar 2023 01:04:25 +0300 Subject: [PATCH 4/4] fixes --- src/JPEGView/SettingsProvider.cpp | 8 +------- src/JPEGView/SettingsProvider.h | 7 ++----- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/JPEGView/SettingsProvider.cpp b/src/JPEGView/SettingsProvider.cpp index 08d73ad1..fdee91e0 100644 --- a/src/JPEGView/SettingsProvider.cpp +++ b/src/JPEGView/SettingsProvider.cpp @@ -120,8 +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; @@ -221,7 +219,6 @@ CSettingsProvider::CSettingsProvider(void) { 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)); @@ -409,8 +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; } @@ -506,8 +502,6 @@ void CSettingsProvider::SaveSettings(const CImageProcessingParams& procParams, WriteBool(_T("ShowFileInfo"), bShowFileInfo); WriteString(_T("SlideShowTransitionEffect"), Helpers::ConvertTransitionEffectToString(eSlideShowTransitionEffect)); - - m_bUserINIExists = true; ReadWriteableINISettings(); } diff --git a/src/JPEGView/SettingsProvider.h b/src/JPEGView/SettingsProvider.h index 30165d0d..086f6216 100644 --- a/src/JPEGView/SettingsProvider.h +++ b/src/JPEGView/SettingsProvider.h @@ -130,11 +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 - - std::vector ParseCustomZoomSteps(LPCTSTR data); - bool UseZoomSteps() { return m_bUseZoomSteps; } + bool UseZoomSteps() { return m_bUseZoomSteps; } std::vector CustomZoomSteps() { return m_sCustomZoomSteps; } - // Returns if a user INI file exists bool ExistsUserINI(); @@ -303,7 +300,6 @@ class CSettingsProvider int m_zoomPauseFactor; bool m_bUseZoomSteps; std::vector m_sCustomZoomSteps; - std::list m_userCommands; std::list m_openWithCommands; @@ -331,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);