Merge branch 'lm_sla_dialog_scaling'

This commit is contained in:
bubnikv 2019-05-14 11:19:08 +02:00
commit cd13b90457
2 changed files with 32 additions and 15 deletions

View File

@ -825,7 +825,7 @@ RENDER_AGAIN:
m_imgui->set_next_window_bg_alpha(0.5f); m_imgui->set_next_window_bg_alpha(0.5f);
m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse); m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
ImGui::PushItemWidth(m_imgui->scaled(5.55f)); //ImGui::PushItemWidth(m_imgui->scaled(5.55f));
bool force_refresh = false; bool force_refresh = false;
bool remove_selected = false; bool remove_selected = false;
@ -837,9 +837,12 @@ RENDER_AGAIN:
if (m_new_point_head_diameter > diameter_upper_cap) if (m_new_point_head_diameter > diameter_upper_cap)
m_new_point_head_diameter = diameter_upper_cap; m_new_point_head_diameter = diameter_upper_cap;
m_imgui->text(_(L("Head diameter")) + ": "); wxString text = _(L("Head diameter")) + ": ";
ImGui::SameLine(m_imgui->scaled(6.66f)); m_imgui->text(text);
ImGui::PushItemWidth(m_imgui->scaled(8.33f)); float slider_left = m_imgui->calc_text_size(text).x + m_imgui->scaled(1.f);
ImGui::SameLine(/*m_imgui->scaled(6.66f)*/slider_left);
ImGui::PushItemWidth(/*m_imgui->scaled(8.33f)*/m_imgui->scaled(15.f) - slider_left);
if (ImGui::SliderFloat("", &m_new_point_head_diameter, 0.1f, diameter_upper_cap, "%.1f")) { if (ImGui::SliderFloat("", &m_new_point_head_diameter, 0.1f, diameter_upper_cap, "%.1f")) {
// value was changed // value was changed
for (auto& cache_entry : m_editing_mode_cache) for (auto& cache_entry : m_editing_mode_cache)
@ -875,9 +878,12 @@ RENDER_AGAIN:
} }
} }
else { // not in editing mode: else { // not in editing mode:
ImGui::PushItemWidth(m_imgui->scaled(5.55f)); wxString text1 = _(L("Minimal points distance")) + ": ";
m_imgui->text(_(L("Minimal points distance")) + ": "); wxString text2 = _(L("Support points density")) + ": ";
ImGui::SameLine(m_imgui->scaled(9.44f)); float sliders_left = std::max(m_imgui->calc_text_size(text1).x, m_imgui->calc_text_size(text2).x) + m_imgui->scaled(1.f);
m_imgui->text(text1);
ImGui::SameLine(/*m_imgui->scaled(9.44f)*/sliders_left);
ImGui::PushItemWidth(/*m_imgui->scaled(5.55f)*/m_imgui->scaled(15.f)-sliders_left);
std::vector<const ConfigOption*> opts = get_config_options({"support_points_density_relative", "support_points_minimal_distance"}); std::vector<const ConfigOption*> opts = get_config_options({"support_points_density_relative", "support_points_minimal_distance"});
float density = static_cast<const ConfigOptionInt*>(opts[0])->value; float density = static_cast<const ConfigOptionInt*>(opts[0])->value;
@ -887,8 +893,9 @@ RENDER_AGAIN:
if (value_changed) if (value_changed)
m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance; m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance;
m_imgui->text(_(L("Support points density")) + ": "); m_imgui->text(text2);
ImGui::SameLine(m_imgui->scaled(9.44f)); ImGui::SameLine(/*m_imgui->scaled(9.44f)*/sliders_left);
if (ImGui::SliderFloat(" ", &density, 0.f, 200.f, "%.f %%")) { if (ImGui::SliderFloat(" ", &density, 0.f, 200.f, "%.f %%")) {
value_changed = true; value_changed = true;
m_model_object->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density; m_model_object->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density;
@ -924,18 +931,21 @@ RENDER_AGAIN:
// Following is rendered in both editing and non-editing mode: // Following is rendered in both editing and non-editing mode:
m_imgui->text(""); m_imgui->text("");
wxString text1 = _(L("Clipping of view"))+ ": ";
wxString text2 = _(L("Reset direction"));
float slider_left = std::max(m_imgui->calc_text_size(text1).x, m_imgui->calc_text_size(text2).x) + m_imgui->scaled(1.5f);
if (m_clipping_plane_distance == 0.f) if (m_clipping_plane_distance == 0.f)
m_imgui->text(_(L("Clipping of view"))+ ": "); m_imgui->text(text1);
else { else {
if (m_imgui->button(_(L("Reset direction")))) { if (m_imgui->button(text2)) {
wxGetApp().CallAfter([this](){ wxGetApp().CallAfter([this](){
reset_clipping_plane_normal(); reset_clipping_plane_normal();
}); });
} }
} }
ImGui::SameLine(m_imgui->scaled(6.66f)); ImGui::SameLine(/*m_imgui->scaled(6.66f)*/slider_left);
ImGui::PushItemWidth(m_imgui->scaled(8.33f)); ImGui::PushItemWidth(/*m_imgui->scaled(8.33f)*/m_imgui->scaled(15.f) - slider_left);
ImGui::SliderFloat(" ", &m_clipping_plane_distance, 0.f, 1.f, "%.2f"); ImGui::SliderFloat(" ", &m_clipping_plane_distance, 0.f, 1.f, "%.2f");

View File

@ -186,7 +186,14 @@ void ImGuiWrapper::render()
ImVec2 ImGuiWrapper::calc_text_size(const wxString &text) ImVec2 ImGuiWrapper::calc_text_size(const wxString &text)
{ {
auto text_utf8 = into_u8(text); auto text_utf8 = into_u8(text);
return ImGui::CalcTextSize(text_utf8.c_str()); ImVec2 size = ImGui::CalcTextSize(text_utf8.c_str());
#ifndef __APPLE__
size.x *= m_style_scaling;
size.y *= m_style_scaling;
#endif
return size;
} }
void ImGuiWrapper::set_next_window_pos(float x, float y, int flag) void ImGuiWrapper::set_next_window_pos(float x, float y, int flag)