ENH:colour arrangement ui text width limit

jira: nojira
Change-Id: I6a8f4341e671aa88704346bfeb1d8be3725619a1
This commit is contained in:
Mack 2024-10-16 17:21:44 +08:00 committed by lane.wei
parent 12912f6772
commit 3cb36b5111
1 changed files with 12 additions and 3 deletions

View File

@ -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<int>(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);
}
}
}