diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index cac2740b0..325067aea 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -493,14 +493,14 @@ bool ImGuiWrapper::slider_float(const char* label, float* v, float v_min, float { const float max_tooltip_width = ImGui::GetFontSize() * 20.0f; - std::string str_label; - if (boost::algorithm::istarts_with(label, "##")) - str_label = std::string(label); - else { - str_label = std::string("##") + std::string(label); - this->text(label); - ImGui::SameLine(); - } + // let the label string start with "##" to hide the automatic label from ImGui::SliderFloat() + bool label_visible = !boost::algorithm::istarts_with(label, "##"); + std::string str_label = label_visible ? std::string("##") + std::string(label) : std::string(label); + + // removes 2nd evenience of "##", if present + std::string::size_type pos = str_label.find("##", 2); + if (pos != std::string::npos) + str_label = str_label.substr(0, pos) + str_label.substr(pos + 2); bool ret = ImGui::SliderFloat(str_label.c_str(), v, v_min, v_max, format, power); if (!tooltip.empty() && ImGui::IsItemHovered()) @@ -509,8 +509,8 @@ bool ImGuiWrapper::slider_float(const char* label, float* v, float v_min, float if (clamp) *v = std::clamp(*v, v_min, v_max); + const ImGuiStyle& style = ImGui::GetStyle(); if (show_edit_btn) { - const ImGuiStyle& style = ImGui::GetStyle(); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 1, style.ItemSpacing.y }); ImGui::SameLine(); std::wstring btn_name = ImGui::SliderFloatEditBtnIcon + boost::nowide::widen(str_label); @@ -528,6 +528,19 @@ bool ImGuiWrapper::slider_float(const char* label, float* v, float v_min, float ImGui::PopStyleVar(); } + if (label_visible) { + // if the label is visible, hide the part of it that should be hidden + std::string out_label = std::string(label); + std::string::size_type pos = out_label.find("##"); + if (pos != std::string::npos) + out_label = out_label.substr(0, pos); + + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 1, style.ItemSpacing.y }); + ImGui::SameLine(); + this->text(out_label.c_str()); + ImGui::PopStyleVar(); + } + return ret; } diff --git a/src/slic3r/GUI/Mouse3DController.cpp b/src/slic3r/GUI/Mouse3DController.cpp index ff2fa1397..3ff0fdea3 100644 --- a/src/slic3r/GUI/Mouse3DController.cpp +++ b/src/slic3r/GUI/Mouse3DController.cpp @@ -469,8 +469,8 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const imgui.text_colored(color, _L("Speed:")); float translation_scale = (float)params_copy.translation.scale / Params::DefaultTranslationScale; - if (imgui.slider_float(_L("Translation") + "##1", &translation_scale, Params::MinTranslationScale, Params::MaxTranslationScale, "%.1f")) { - params_copy.translation.scale = Params::DefaultTranslationScale * (double)translation_scale; + if (imgui.slider_float(_L("Translation"), &translation_scale, Params::MinTranslationScale, Params::MaxTranslationScale, "%.1f")) { + params_copy.translation.scale = Params::DefaultTranslationScale * (double)translation_scale; params_changed = true; } @@ -517,13 +517,13 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const imgui.text_colored(color, "Vectors:"); Vec3f translation = m_state.get_first_vector_of_type(State::QueueItem::TranslationType).cast(); Vec3f rotation = m_state.get_first_vector_of_type(State::QueueItem::RotationType).cast(); - ImGui::InputFloat3("Translation##3", translation.data(), "%.3f", ImGuiInputTextFlags_ReadOnly); + ImGui::InputFloat3("Translation##2", translation.data(), "%.3f", ImGuiInputTextFlags_ReadOnly); ImGui::InputFloat3("Rotation##3", rotation.data(), "%.3f", ImGuiInputTextFlags_ReadOnly); imgui.text_colored(color, "Queue size:"); int input_queue_size_current[2] = { int(m_state.input_queue_size_current()), int(m_state.input_queue_max_size_achieved) }; - ImGui::InputInt2("Current##4", input_queue_size_current, ImGuiInputTextFlags_ReadOnly); + ImGui::InputInt2("Current", input_queue_size_current, ImGuiInputTextFlags_ReadOnly); int input_queue_size_param = int(params_copy.input_queue_max_size); if (ImGui::InputInt("Max size", &input_queue_size_param, 1, 1, ImGuiInputTextFlags_ReadOnly)) {