From 3cb36b51119ef4468febeab9246e103226c42a07 Mon Sep 17 00:00:00 2001 From: Mack Date: Wed, 16 Oct 2024 17:21:44 +0800 Subject: [PATCH] ENH:colour arrangement ui text width limit jira: nojira Change-Id: I6a8f4341e671aa88704346bfeb1d8be3725619a1 --- src/slic3r/GUI/GCodeViewer.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 5c32d2c95..0edc3fdf9 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -4735,12 +4735,21 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) ImGui::Dummy({window_padding, window_padding}); bool is_optimal_group = true; + float parent_width = ImGui::GetContentRegionAvail().x; + auto number_format = [](float num) { + if (num > 1000) { + std::string number_str = std::to_string(num); + std::string first_three_digits = number_str.substr(0, 3); + return std::stoi(first_three_digits); + } + return static_cast(num); + }; if (filament_map_mode == fmmAuto) { float saved_flush_weight = stats_by_extruder.stats_by_single_extruder.filament_flush_weight - stats_by_extruder.stats_by_multi_extruder_auto.filament_flush_weight; int saved_filament_changed_time = stats_by_extruder.stats_by_single_extruder.filament_change_count - stats_by_extruder.stats_by_multi_extruder_auto.filament_change_count; if (saved_flush_weight > EPSILON || saved_filament_changed_time > 0) { imgui.text(_u8L("This arrangement would be optimal.")); - imgui.text(from_u8((boost::format(_u8L("Save %1%g filament and %2% changes than one-extruder printer.")) % saved_flush_weight % saved_filament_changed_time).str())); + imgui.text_wrapped(from_u8((boost::format(_u8L("Save %1%g filament and %2% changes than one-extruder printer.")) % number_format(saved_flush_weight) % saved_filament_changed_time).str()), parent_width); } } else if (filament_map_mode == fmmManual) { float more_cost = stats_by_extruder.stats_by_multi_extruder_manual.filament_flush_weight - stats_by_extruder.stats_by_multi_extruder_auto.filament_flush_weight; @@ -4751,14 +4760,14 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) ImVec4 orangeColor = ImVec4(1.0f, 0.5f, 0.0f, 1.0f); ImGui::PushStyleColor(ImGuiCol_Text, orangeColor); imgui.text(_u8L("This arrangement is not optimal.")); - imgui.text(from_u8((boost::format(_u8L("Cost %1%g filament and %2% changes more than optimal arrangement.")) %more_cost % more_time).str())); + imgui.text_wrapped(from_u8((boost::format(_u8L("Cost %1%g filament and %2% changes more than optimal arrangement.")) % number_format(more_cost) % more_time).str()), parent_width); ImGui::PopStyleColor(1); } else { float saved_flush_weight = stats_by_extruder.stats_by_single_extruder.filament_flush_weight - stats_by_extruder.stats_by_multi_extruder_auto.filament_flush_weight; int saved_filament_changed_time = stats_by_extruder.stats_by_single_extruder.filament_change_count - stats_by_extruder.stats_by_multi_extruder_auto.filament_change_count; if (saved_flush_weight > EPSILON || saved_filament_changed_time > 0) { imgui.text(_u8L("This arrangement would be optimal.")); - imgui.text(from_u8((boost::format(_u8L("Save %1%g filament and %2% changes than one-extruder printer.")) % saved_flush_weight % saved_filament_changed_time).str())); + imgui.text_wrapped(from_u8((boost::format(_u8L("Save %1%g filament and %2% changes than one-extruder printer.")) % number_format(saved_flush_weight) % saved_filament_changed_time).str()), parent_width); } } }