From 1945b04e69031adcf1b710204a761f1969d64c00 Mon Sep 17 00:00:00 2001 From: Yousef Khadadeh Date: Fri, 3 Oct 2025 09:11:22 +0300 Subject: [PATCH] Added a flip zoom tool direction option --- src/DrawCamera.cpp | 2 +- src/Toolbar.cpp | 3 +++ src/Toolbar.hpp | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/DrawCamera.cpp b/src/DrawCamera.cpp index 92e4b8f..de8e818 100755 --- a/src/DrawCamera.cpp +++ b/src/DrawCamera.cpp @@ -123,7 +123,7 @@ void DrawCamera::update_main(World& w) { } isAccurateZooming = newIsAccurateZooming; if(isAccurateZooming) { - WorldScalar zoomFactor(std::pow(1.0 + w.main.toolbar.dragZoomSpeed, -w.main.input.mouse.move.y())); + WorldScalar zoomFactor(std::pow(1.0 + w.main.toolbar.dragZoomSpeed, w.main.toolbar.flipZoomToolDirection ? w.main.input.mouse.move.y() : -w.main.input.mouse.move.y())); c.scale(zoomFactor); WorldVec mVec = startZoomCameraPos - startZoomMousePos; WorldScalar mX = c.inverseScale / startZoomVal; diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index d370296..d544771 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -226,6 +226,7 @@ nlohmann::json Toolbar::get_config_json() { toRet["velocityAffectsBrushWidth"] = velocityAffectsBrushWidth; toRet["jumpTransitionEasing"] = jumpTransitionEasing; toRet["defaultCanvasBackgroundColor"] = main.defaultCanvasBackgroundColor; + toRet["flipZoomToolDirection"] = flipZoomToolDirection; #ifndef __EMSCRIPTEN__ toRet["checkForUpdates"] = updateCheckerData.checkForUpdates; #endif @@ -278,6 +279,7 @@ void Toolbar::set_config_json(const nlohmann::json& j) { j.at("velocityAffectsBrushWidth").get_to(velocityAffectsBrushWidth); j.at("jumpTransitionEasing").get_to(jumpTransitionEasing); j.at("defaultCanvasBackgroundColor").get_to(main.defaultCanvasBackgroundColor); + j.at("flipZoomToolDirection").get_to(flipZoomToolDirection); #ifndef __EMSCRIPTEN__ j.at("checkForUpdates").get_to(updateCheckerData.checkForUpdates); #endif @@ -1381,6 +1383,7 @@ void Toolbar::options_menu() { #endif gui.slider_scalar_field("drag zoom slider", "Drag zoom speed", &dragZoomSpeed, 0.0, 1.0, 3); gui.slider_scalar_field("scroll zoom slider", "Scroll zoom speed", &scrollZoomSpeed, 0.0, 1.0, 3); + gui.checkbox_field("flip zoom tool direction", "Flip zoom tool direction", &flipZoomToolDirection); gui.input_scalar_field("jump transition time", "Jump transition time", &jumpTransitionTime, 0.01f, 1000.0f, 2); gui.checkbox_field("changebrushwidthwithspeed", "Change brush size with mouse speed", &velocityAffectsBrushWidth); gui.pop_id(); diff --git a/src/Toolbar.hpp b/src/Toolbar.hpp index 493ae4f..9d92e27 100644 --- a/src/Toolbar.hpp +++ b/src/Toolbar.hpp @@ -79,6 +79,8 @@ class Toolbar { Vector4f* colorRight = nullptr; std::optional paintPopupLocation; + bool flipZoomToolDirection = false; + float final_gui_scale(); private: void calculate_final_gui_scale();