Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/JPEGView/Config/JPEGView.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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


; *****************************************************************************
Expand Down
17 changes: 17 additions & 0 deletions src/JPEGView/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> 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;
}
Expand Down
31 changes: 30 additions & 1 deletion src/JPEGView/SettingsProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "NLS.h"
#include <float.h>
#include <shlobj.h>
#include <algorithm>
#include <sstream>

static const TCHAR* DEFAULT_INI_FILE_NAME = _T("JPEGView.ini");
static const TCHAR* SECTION_NAME = _T("JPEGView");
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -218,6 +219,9 @@ 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));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -502,6 +507,7 @@ void CSettingsProvider::SaveSettings(const CImageProcessingParams& procParams,

WriteString(_T("SlideShowTransitionEffect"), Helpers::ConvertTransitionEffectToString(eSlideShowTransitionEffect));


m_bUserINIExists = true;
ReadWriteableINISettings();
}
Expand Down Expand Up @@ -698,6 +704,28 @@ LPCTSTR CSettingsProvider::ReadIniString(LPCTSTR key, LPCTSTR fileName, IniHashM
}
}

std::vector<double> CSettingsProvider::ParseCustomZoomSteps(LPCTSTR data) {
std::vector<double> 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;

Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/JPEGView/SettingsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> ParseCustomZoomSteps(LPCTSTR data);
bool UseZoomSteps() { return m_bUseZoomSteps; }
std::vector<double> 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
Expand Down Expand Up @@ -296,6 +301,8 @@ class CSettingsProvider
bool m_bFlashWindowAlert;
bool m_bBeepSoundAlert;
int m_zoomPauseFactor;
bool m_bUseZoomSteps;
std::vector<double> m_sCustomZoomSteps;

std::list<CUserCommand*> m_userCommands;
std::list<CUserCommand*> m_openWithCommands;
Expand Down