From cb4763bb32f0817e1dc34847d0b0d36da7a0b969 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 18 Feb 2019 14:56:19 +0100 Subject: [PATCH] SLA gizmo - combobox items are now rendered immediately on mouse click, not after next mouse move --- src/slic3r/GUI/GLGizmo.cpp | 6 +++++- src/slic3r/GUI/GLGizmo.hpp | 1 + src/slic3r/GUI/ImGuiWrapper.cpp | 4 +++- src/slic3r/GUI/ImGuiWrapper.hpp | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index a1d1d1c91c..73a65aedf8 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -2236,7 +2236,11 @@ RENDER_AGAIN: std::stringstream ss; ss << std::setprecision(1) << m_new_point_head_diameter; wxString str = ss.str(); - m_imgui->combo(_(L("Head diameter")), options, str); + + bool old_combo_state = m_combo_box_open; + m_combo_box_open = m_imgui->combo(_(L("Head diameter")), options, str); + force_refresh |= (old_combo_state != m_combo_box_open); + float current_number = atof(str); if (std::abs(current_number - m_new_point_head_diameter) > 0.001) { force_refresh = true; diff --git a/src/slic3r/GUI/GLGizmo.hpp b/src/slic3r/GUI/GLGizmo.hpp index 2674f03f06..1605700b1a 100644 --- a/src/slic3r/GUI/GLGizmo.hpp +++ b/src/slic3r/GUI/GLGizmo.hpp @@ -498,6 +498,7 @@ private: Vec2d m_selection_rectangle_start_corner; Vec2d m_selection_rectangle_end_corner; bool m_ignore_up_event = false; + bool m_combo_box_open = false; #if SLAGIZMO_IMGUI_MODAL bool m_show_modal = false; #endif diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 3ce187a449..1eac4159ff 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -168,7 +168,7 @@ void ImGuiWrapper::text(const wxString &label) } -void ImGuiWrapper::combo(const wxString& label, const std::vector& options, wxString& selection) +bool ImGuiWrapper::combo(const wxString& label, const std::vector& options, wxString& selection) { std::string selection_u8 = into_u8(selection); @@ -184,7 +184,9 @@ void ImGuiWrapper::combo(const wxString& label, const std::vector& opt selection = option_u8; } ImGui::EndCombo(); + return true; } + return false; } void ImGuiWrapper::disabled_begin(bool disabled) diff --git a/src/slic3r/GUI/ImGuiWrapper.hpp b/src/slic3r/GUI/ImGuiWrapper.hpp index a537181622..f85b70c217 100644 --- a/src/slic3r/GUI/ImGuiWrapper.hpp +++ b/src/slic3r/GUI/ImGuiWrapper.hpp @@ -52,7 +52,7 @@ public: bool input_vec3(const std::string &label, const Vec3d &value, float width, const std::string &format = "%.3f"); bool checkbox(const wxString &label, bool &value); void text(const wxString &label); - void combo(const wxString& label, const std::vector& options, wxString& current_selection); + bool combo(const wxString& label, const std::vector& options, wxString& current_selection); void disabled_begin(bool disabled); void disabled_end();