Gcode Statistics Panel Fixes (#8172)

* Gcode Statistics Panel - Persist open/close state

Bug: On slicing a model, the Statistics Panel would be reset to being open (regardless of if the user had shut it earlier)

Fix: Now on app open the Statistics Panel will be open, but if the user closes it, its state will persist (regardless of slicing again)

https://github.com/SoftFever/OrcaSlicer/discussions/6021

* Gcode Statistics Panel - fold/unfold button width fix

Issue: The fold/unfold button width is too wide (It seems CalcTextSize is making the button wider than necessary)

Fix: Set the width to a correct fixed value
This commit is contained in:
andrewleek 2025-01-26 01:58:38 +01:00 committed by GitHub
parent 1ebbb3958c
commit 118e14d788
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1056,8 +1056,6 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
set_view_type(EViewType::ColorPrint);
}
m_fold = false;
bool only_gcode_3mf = false;
PartPlate* current_plate = wxGetApp().plater()->get_partplate_list().get_curr_plate();
bool current_has_print_instances = current_plate->has_printable_instances();
@ -4644,15 +4642,15 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImGui::SameLine();
std::wstring btn_name;
if (m_fold)
btn_name = ImGui::UnfoldButtonIcon + boost::nowide::widen(std::string(""));
btn_name = ImGui::UnfoldButtonIcon;
else
btn_name = ImGui::FoldButtonIcon + boost::nowide::widen(std::string(""));
btn_name = ImGui::FoldButtonIcon;
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.0f, 0.59f, 0.53f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.0f, 0.59f, 0.53f, 0.78f));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f));
//ImGui::PushItemWidth(
float button_width = ImGui::CalcTextSize(into_u8(btn_name).c_str()).x;
float button_width = 34.0f;
if (ImGui::Button(into_u8(btn_name).c_str(), ImVec2(button_width, 0))) {
m_fold = !m_fold;
}