ENH: modify zoom interaction

Change-Id: I7a888a8980b5b10e5d2c515158c9c4cdf8654b7c
This commit is contained in:
liz.li 2023-03-27 14:46:11 +08:00 committed by Lane.Wei
parent 62df53f86e
commit 87df72a67f
3 changed files with 8 additions and 1 deletions

View file

@ -170,6 +170,9 @@ void AppConfig::set_defaults()
set_bool("reverse_mouse_wheel_zoom", false); set_bool("reverse_mouse_wheel_zoom", false);
#endif #endif
if (get("zoom_to_mouse").empty())
set_bool("zoom_to_mouse", false);
//#ifdef SUPPORT_SHOW_HINTS //#ifdef SUPPORT_SHOW_HINTS
if (get("show_hints").empty()) if (get("show_hints").empty())
set_bool("show_hints", true); set_bool("show_hints", true);

View file

@ -3596,7 +3596,8 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
double direction_factor = 1.0; double direction_factor = 1.0;
#endif #endif
auto delta = direction_factor * (double)evt.GetWheelRotation() / (double)evt.GetWheelDelta(); auto delta = direction_factor * (double)evt.GetWheelRotation() / (double)evt.GetWheelDelta();
if (evt.CmdDown()) { bool zoom_to_mouse = wxGetApp().app_config->get("zoom_to_mouse") == "true";
if (!zoom_to_mouse) {// zoom to center
_update_camera_zoom(delta); _update_camera_zoom(delta);
} }
else { else {

View file

@ -914,6 +914,8 @@ wxWindow* PreferencesDialog::create_general_page()
std::vector<wxString> Units = {_L("Metric") + " (mm, g)", _L("Imperial") + " (in, oz)"}; std::vector<wxString> Units = {_L("Metric") + " (mm, g)", _L("Imperial") + " (in, oz)"};
auto item_currency = create_item_combobox(_L("Units"), page, _L("Units"), "use_inches", Units); auto item_currency = create_item_combobox(_L("Units"), page, _L("Units"), "use_inches", Units);
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_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"); 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");
auto title_presets = create_item_title(_L("Presets"), page, _L("Presets")); auto title_presets = create_item_title(_L("Presets"), page, _L("Presets"));
@ -968,6 +970,7 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_language, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_language, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_region, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_region, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_currency, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_currency, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_mouse_zoom_settings, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3));
sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20)); sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20));
sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3));