gui: reverse mouse zoom option (#4668) (#4677)

* gui: reverse mouse zoom option (#4668)

Add configuration entry for reverse mouse zoom option
Define SUPPORT_REVERSE_MOUSE_ZOOM macro to enable feature code.

* remove SUPPORT_REVERSE_MOUSE_ZOOM macro

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Dima Buzdyk 2024-04-04 18:52:07 +05:00 committed by GitHub
parent ff7faca943
commit 14fc48ffbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 7 deletions

View file

@ -176,10 +176,8 @@ void AppConfig::set_defaults()
if (get("camera_navigation_style").empty())
set("camera_navigation_style", "0");
#ifdef SUPPORT_REVERSE_MOUSE_ZOOM
if (get("reverse_mouse_wheel_zoom").empty())
set_bool("reverse_mouse_wheel_zoom", false);
#endif
if (get("zoom_to_mouse").empty())
set_bool("zoom_to_mouse", false);

View file

@ -3685,11 +3685,7 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
return;
}
// Calculate the zoom delta and apply it to the current zoom factor
#ifdef SUPPORT_REVERSE_MOUSE_ZOOM
double direction_factor = (wxGetApp().app_config->get("reverse_mouse_wheel_zoom") == "1") ? -1.0 : 1.0;
#else
double direction_factor = 1.0;
#endif
double direction_factor = wxGetApp().app_config->get_bool("reverse_mouse_wheel_zoom") ? -1.0 : 1.0;
auto delta = direction_factor * (double)evt.GetWheelRotation() / (double)evt.GetWheelDelta();
bool zoom_to_mouse = wxGetApp().app_config->get("zoom_to_mouse") == "true";
if (!zoom_to_mouse) {// zoom to center

View file

@ -1024,6 +1024,7 @@ wxWindow* PreferencesDialog::create_general_page()
auto item_mouse_zoom_settings = create_item_checkbox(_L("Zoom to mouse position"), page, _L("Zoom in towards the mouse pointer's position in the 3D view, rather than the 2D window center."), 50, "zoom_to_mouse");
auto item_use_free_camera_settings = create_item_checkbox(_L("Use free camera"), page, _L("If enabled, use free camera. If not enabled, use constrained camera."), 50, "use_free_camera");
auto reverse_mouse_zoom = create_item_checkbox(_L("Reverse mouse zoom"), page, _L("If enabled, reverses the direction of zoom with mouse wheel."), 50, "reverse_mouse_wheel_zoom");
auto item_show_splash_screen = create_item_checkbox(_L("Show splash screen"), page, _L("Show the splash screen during startup."), 50, "show_splash_screen");
auto item_hints = create_item_checkbox(_L("Show \"Tip of the day\" notification after start"), page, _L("If enabled, useful hints are displayed at startup."), 50, "show_hints");
@ -1089,6 +1090,7 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_camera_navigation_style, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_mouse_zoom_settings, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_use_free_camera_settings, 0, wxTOP, FromDIP(3));
sizer_page->Add(reverse_mouse_zoom, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_show_splash_screen, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3));
sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20));