Skip to content

Commit

Permalink
Merge branch 'tm_rotgizmo_beautify'
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasmeszaros committed Nov 10, 2021
2 parents 8b51dc6 + c49ba9f commit f44f367
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,21 @@ GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui,
y = std::min(y, alignment.bottom_limit - win_h);
ImGui::SetWindowPos(ImVec2(x, y), ImGuiCond_Always);

ImGui::PushItemWidth(300.f);
float max_text_w = 0.;
auto padding = ImGui::GetStyle().FramePadding;
padding.x *= 2.f;
padding.y *= 2.f;

for (size_t i = 0; i < RotoptimizeJob::get_methods_count(); ++i) {
float w =
ImGui::CalcTextSize(RotoptimizeJob::get_method_name(i).c_str()).x +
padding.x + ImGui::GetFrameHeight();
max_text_w = std::max(w, max_text_w);
}

ImGui::PushItemWidth(max_text_w);

if (ImGui::BeginCombo(_L("Choose goal").c_str(), RotoptimizeJob::get_method_name(state.method_id).c_str())) {
if (ImGui::BeginCombo("", RotoptimizeJob::get_method_name(state.method_id).c_str())) {
for (size_t i = 0; i < RotoptimizeJob::get_methods_count(); ++i) {
if (ImGui::Selectable(RotoptimizeJob::get_method_name(i).c_str())) {
state.method_id = i;
Expand All @@ -530,12 +542,18 @@ GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui,
ImGui::EndCombo();
}

ImVec2 sz = ImGui::GetItemRectSize();

if (ImGui::IsItemHovered())
ImGui::SetTooltip("%s", RotoptimizeJob::get_method_description(state.method_id).c_str());

ImGui::Separator();

if ( imgui->button(_L("Optimize")) ) {
auto btn_txt = _L("Apply");
auto btn_txt_sz = ImGui::CalcTextSize(btn_txt.c_str());
ImVec2 button_sz = {btn_txt_sz.x + padding.x, btn_txt_sz.y + padding.y};
ImGui::SetCursorPosX(padding.x + sz.x - button_sz.x);
if ( imgui->button(btn_txt) ) {
wxGetApp().plater()->optimize_rotation();
}
}
Expand Down

0 comments on commit f44f367

Please sign in to comment.