#3385 - Fixed broken 3Dconnexion settings imgui dialog layout

This commit is contained in:
enricoturri1966 2021-11-23 09:43:03 +01:00
parent a996f33579
commit 3cb6305d3e
2 changed files with 26 additions and 13 deletions

View file

@ -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;
}