Tech ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT - Modified ImGuiWrapper::slider_float() to create a compound widget where an additional button can be used to set the keyboard focus into the slider to allow the user to type in the desired value

This commit is contained in:
enricoturri1966 2021-11-05 14:46:44 +01:00
parent c8ff0de27e
commit f7662682c8
11 changed files with 183 additions and 37 deletions

View file

@ -441,9 +441,13 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
m_imgui->text(m_desc.at("cursor_size"));
ImGui::SameLine(sliders_width);
ImGui::PushItemWidth(window_width - sliders_width);
#if ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
m_imgui->slider_float("##cursor_radius", &m_cursor_radius, CursorRadiusMin, CursorRadiusMax, "%.2f", 1.0f, true, _L("Alt + Mouse wheel"));
#else
m_imgui->slider_float("##cursor_radius", &m_cursor_radius, CursorRadiusMin, CursorRadiusMax, "%.2f");
if (ImGui::IsItemHovered())
m_imgui->tooltip(_L("Alt + Mouse wheel"), max_tooltip_width);
#endif // ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
m_imgui->checkbox(m_desc["split_triangles"], m_triangle_splitting_enabled);
@ -460,14 +464,20 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
"placed after the number with no whitespace in between.");
ImGui::SameLine(sliders_width);
ImGui::PushItemWidth(window_width - sliders_width);
#if ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
if (m_imgui->slider_float("##smart_fill_angle", &m_smart_fill_angle, SmartFillAngleMin, SmartFillAngleMax, format_str.data(), 1.0f, true, _L("Alt + Mouse wheel")))
#else
if(m_imgui->slider_float("##smart_fill_angle", &m_smart_fill_angle, SmartFillAngleMin, SmartFillAngleMax, format_str.data()))
#endif // ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
for (auto &triangle_selector : m_triangle_selectors) {
triangle_selector->seed_fill_unselect_all_triangles();
triangle_selector->request_update_render_data();
}
#if !ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
if (ImGui::IsItemHovered())
m_imgui->tooltip(_L("Alt + Mouse wheel"), max_tooltip_width);
#endif // !ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
ImGui::Separator();
}
@ -484,11 +494,16 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
ImGui::SameLine(sliders_width);
ImGui::PushItemWidth(window_width - sliders_width);
auto clp_dist = float(m_c->object_clipper()->get_position());
#if ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
if (m_imgui->slider_float("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f", 1.0f, true, _L("Ctrl + Mouse wheel")))
m_c->object_clipper()->set_position(clp_dist, true);
#else
if (m_imgui->slider_float("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f"))
m_c->object_clipper()->set_position(clp_dist, true);
if (ImGui::IsItemHovered())
m_imgui->tooltip(_L("Ctrl + Mouse wheel"), max_tooltip_width);
#endif // ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
ImGui::Separator();
if (m_imgui->button(m_desc.at("remove_all"))) {