Enabled tech ENABLE_CTRL_M_ON_WINDOWS -> Added customizable support for legacy CTRL+M settings dialog on Windows in preference dialog

This commit is contained in:
enricoturri1966 2020-11-26 11:00:24 +01:00
parent 2314a9e8c7
commit 10fb75edf0
7 changed files with 48 additions and 20 deletions

View File

@ -117,6 +117,12 @@ void AppConfig::set_defaults()
if (get("use_inches").empty()) if (get("use_inches").empty())
set("use_inches", "0"); set("use_inches", "0");
if (get("default_action_on_close_application").empty())
set("default_action_on_close_application", "none"); // , "discard" or "save"
if (get("default_action_on_select_preset").empty())
set("default_action_on_select_preset", "none"); // , "transfer", "discard" or "save"
} }
#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN #if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
else { else {
@ -142,11 +148,12 @@ void AppConfig::set_defaults()
if (get("show_splash_screen").empty()) if (get("show_splash_screen").empty())
set("show_splash_screen", "1"); set("show_splash_screen", "1");
if (get("default_action_on_close_application").empty()) #if ENABLE_CTRL_M_ON_WINDOWS
set("default_action_on_close_application", "none"); // , "discard" or "save" #ifdef _WIN32
if (get("use_legacy_3DConnexion").empty())
if (get("default_action_on_select_preset").empty()) set("use_legacy_3DConnexion", "0");
set("default_action_on_select_preset", "none"); // , "transfer", "discard" or "save" #endif // _WIN32
#endif // ENABLE_CTRL_M_ON_WINDOWS
// Remove legacy window positions/sizes // Remove legacy window positions/sizes
erase("", "main_frame_maximized"); erase("", "main_frame_maximized");

View File

@ -61,7 +61,7 @@
//==================== //====================
#define ENABLE_2_3_0_ALPHA3 1 #define ENABLE_2_3_0_ALPHA3 1
#define ENABLE_CTRL_M_ON_WINDOWS (0 && ENABLE_2_3_0_ALPHA3) #define ENABLE_CTRL_M_ON_WINDOWS (1 && ENABLE_2_3_0_ALPHA3)
//==================== //====================

View File

@ -2434,9 +2434,15 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
#if ENABLE_CTRL_M_ON_WINDOWS #if ENABLE_CTRL_M_ON_WINDOWS
case WXK_CONTROL_M: case WXK_CONTROL_M:
{ {
Mouse3DController& controller = wxGetApp().plater()->get_mouse3d_controller(); #ifdef _WIN32
controller.show_settings_dialog(!controller.is_settings_dialog_shown()); if (wxGetApp().app_config->get("use_legacy_3DConnexion") == "1") {
m_dirty = true; #endif //_WIN32
Mouse3DController& controller = wxGetApp().plater()->get_mouse3d_controller();
controller.show_settings_dialog(!controller.is_settings_dialog_shown());
m_dirty = true;
#ifdef _WIN32
}
#endif //_WIN32
break; break;
} }
#else #else
@ -3880,26 +3886,26 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
const float x = pos_x * float(wxGetApp().plater()->get_camera().get_zoom()) + 0.5f * canvas_w; const float x = pos_x * float(wxGetApp().plater()->get_camera().get_zoom()) + 0.5f * canvas_w;
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f); imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
imgui->begin(_(L("Arrange options")), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse); imgui->begin(_L("Arrange options"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
ArrangeSettings settings = m_arrange_settings; ArrangeSettings settings = m_arrange_settings;
auto &appcfg = wxGetApp().app_config; auto &appcfg = wxGetApp().app_config;
bool settings_changed = false; bool settings_changed = false;
if (imgui->slider_float(_(L("Gap size")), &settings.distance, 0.f, 100.f)) { if (imgui->slider_float(_L("Gap size"), &settings.distance, 0.f, 100.f)) {
m_arrange_settings.distance = settings.distance; m_arrange_settings.distance = settings.distance;
settings_changed = true; settings_changed = true;
} }
if (imgui->checkbox(_(L("Enable rotations (slow)")), settings.enable_rotation)) { if (imgui->checkbox(_L("Enable rotations (slow)"), settings.enable_rotation)) {
m_arrange_settings.enable_rotation = settings.enable_rotation; m_arrange_settings.enable_rotation = settings.enable_rotation;
settings_changed = true; settings_changed = true;
} }
ImGui::Separator(); ImGui::Separator();
if (imgui->button(_(L("Reset")))) { if (imgui->button(_L("Reset"))) {
m_arrange_settings = ArrangeSettings{}; m_arrange_settings = ArrangeSettings{};
settings_changed = true; settings_changed = true;
} }
@ -3911,7 +3917,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
ImGui::SameLine(); ImGui::SameLine();
if (imgui->button(_(L("Arrange")))) { if (imgui->button(_L("Arrange"))) {
wxGetApp().plater()->arrange(); wxGetApp().plater()->arrange();
} }

View File

@ -171,7 +171,11 @@ void KBShortcutsDialog::fill_shortcuts()
{ "Tab", L("Switch between Editor/Preview") }, { "Tab", L("Switch between Editor/Preview") },
{ "Shift+Tab", L("Collapse/Expand the sidebar") }, { "Shift+Tab", L("Collapse/Expand the sidebar") },
#if ENABLE_CTRL_M_ON_WINDOWS #if ENABLE_CTRL_M_ON_WINDOWS
#ifdef _WIN32
{ ctrl + "M", L("Show/Hide 3Dconnexion devices settings dialog, if enabled") },
#else
{ ctrl + "M", L("Show/Hide 3Dconnexion devices settings dialog") }, { ctrl + "M", L("Show/Hide 3Dconnexion devices settings dialog") },
#endif // _WIN32
#else #else
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
{ ctrl + "M", L("Show/Hide 3Dconnexion devices settings dialog") }, { ctrl + "M", L("Show/Hide 3Dconnexion devices settings dialog") },

View File

@ -99,7 +99,7 @@ void Mouse3DController::State::append_button(unsigned int id, size_t /* input_qu
#endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
} }
#ifdef WIN32 #ifdef _WIN32
#if ENABLE_CTRL_M_ON_WINDOWS #if ENABLE_CTRL_M_ON_WINDOWS
static std::string format_device_string(int vid, int pid) static std::string format_device_string(int vid, int pid)
{ {
@ -319,7 +319,7 @@ bool Mouse3DController::State::process_mouse_wheel()
m_mouse_wheel_counter = 0; m_mouse_wheel_counter = 0;
return true; return true;
} }
#endif // WIN32 #endif // _WIN32
bool Mouse3DController::State::apply(const Mouse3DController::Params &params, Camera& camera) bool Mouse3DController::State::apply(const Mouse3DController::Params &params, Camera& camera)
{ {
@ -700,10 +700,10 @@ void Mouse3DController::shutdown()
} }
#if ENABLE_CTRL_M_ON_WINDOWS #if ENABLE_CTRL_M_ON_WINDOWS
#ifdef WIN32 #ifdef _WIN32
if (!m_device_str.empty()) if (!m_device_str.empty())
m_params_by_device[m_device_str] = m_params_ui; m_params_by_device[m_device_str] = m_params_ui;
#endif // WIN32 #endif // _WIN32
#endif // ENABLE_CTRL_M_ON_WINDOWS #endif // ENABLE_CTRL_M_ON_WINDOWS
} }

View File

@ -189,7 +189,7 @@ public:
bool handle_input(const DataPacketAxis& packet); bool handle_input(const DataPacketAxis& packet);
#endif // __APPLE__ #endif // __APPLE__
#ifdef WIN32 #ifdef _WIN32
bool handle_raw_input_win32(const unsigned char *data, const int packet_lenght); bool handle_raw_input_win32(const unsigned char *data, const int packet_lenght);
// Called by Win32 HID enumeration callback. // Called by Win32 HID enumeration callback.
@ -202,7 +202,7 @@ public:
// if the application does not register at the driver. This is a workaround to ignore these superfluous // if the application does not register at the driver. This is a workaround to ignore these superfluous
// mouse wheel events. // mouse wheel events.
bool process_mouse_wheel() { return m_state.process_mouse_wheel(); } bool process_mouse_wheel() { return m_state.process_mouse_wheel(); }
#endif // WIN32 #endif // _WIN32
// Apply the received 3DConnexion mouse events to the camera. Called from the UI rendering thread. // Apply the received 3DConnexion mouse events to the camera. Called from the UI rendering thread.
bool apply(Camera& camera); bool apply(Camera& camera);

View File

@ -202,6 +202,17 @@ void PreferencesDialog::build()
option = Option(def, "show_splash_screen"); option = Option(def, "show_splash_screen");
m_optgroup_general->append_single_option_line(option); m_optgroup_general->append_single_option_line(option);
#if ENABLE_CTRL_M_ON_WINDOWS
#ifdef _WIN32
def.label = L("Enable support for legacy 3DConnexion devices");
def.type = coBool;
def.tooltip = L("If enabled, the legacy 3DConnexion devices settings dialog is available by pressing CTRL+M");
def.set_default_value(new ConfigOptionBool{ app_config->get("use_legacy_3DConnexion") == "1" });
option = Option(def, "use_legacy_3DConnexion");
m_optgroup_general->append_single_option_line(option);
#endif // _WIN32
#endif // ENABLE_CTRL_M_ON_WINDOWS
m_optgroup_general->activate(); m_optgroup_general->activate();
m_optgroup_camera = std::make_shared<ConfigOptionsGroup>(this, _L("Camera")); m_optgroup_camera = std::make_shared<ConfigOptionsGroup>(this, _L("Camera"));