diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index c045c9a6e..7bb2daf79 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -4620,9 +4620,11 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) ImGui::Dummy({ window_padding, window_padding }); ImGui::SameLine(); imgui.title(_u8L("Color Arrangement Recommendation")); - //BBS AMS containers - int AMS_filament_max_num = std::max(m_left_extruder_filament.size(), m_right_extruder_filament.size()); - float AMS_container_height = (std::ceil(AMS_filament_max_num / 4.0f) * 80.0f + 70.0f ) * m_scale; + // BBS AMS containers + float line_height = ImGui::GetFrameHeight(); + int AMS_filament_max_num = std::max(m_left_extruder_filament.size(), m_right_extruder_filament.size()); + float three_words_width = imgui.calc_text_size("ABC").x; + float AMS_container_height = (std::ceil(AMS_filament_max_num / 4.0f) * (three_words_width * 1.5f + line_height) + (line_height * 4)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(window_padding * 3, 0)); ImGui::BeginChild("#AMS", ImVec2(0, AMS_container_height), false, ImGuiWindowFlags_AlwaysUseWindowPadding); { @@ -4643,8 +4645,8 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(window_padding * 2, window_padding)); ImDrawList *child_begin_draw_list = ImGui::GetWindowDrawList(); ImVec2 cursor_pos = ImGui::GetCursorScreenPos(); - child_begin_draw_list->AddRectFilled(cursor_pos, ImVec2(cursor_pos.x + half_width, cursor_pos.y + 24.0f * m_scale), IM_COL32(0, 0, 0, 64)); - ImGui::BeginChild("#LeftAMS", ImVec2(half_width, available_height - 20 * m_scale), false, ImGuiWindowFlags_AlwaysUseWindowPadding); + child_begin_draw_list->AddRectFilled(cursor_pos, ImVec2(cursor_pos.x + half_width, cursor_pos.y + line_height), IM_COL32(0, 0, 0, 64)); + ImGui::BeginChild("#LeftAMS", ImVec2(half_width, available_height - line_height * .95f), false, ImGuiWindowFlags_AlwaysUseWindowPadding); { imgui.bold_text(_u8L("Left")); ImGui::Dummy({window_padding, window_padding}); @@ -4658,8 +4660,8 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) } ImGui::SameLine(); cursor_pos = ImGui::GetCursorScreenPos(); - child_begin_draw_list->AddRectFilled(cursor_pos, ImVec2(cursor_pos.x + half_width, cursor_pos.y + 24.0f * m_scale), IM_COL32(0, 0, 0, 64)); - ImGui::BeginChild("#RightAMS", ImVec2(half_width, available_height - 20 * m_scale), false, ImGuiWindowFlags_AlwaysUseWindowPadding); + child_begin_draw_list->AddRectFilled(cursor_pos, ImVec2(cursor_pos.x + half_width, cursor_pos.y + line_height), IM_COL32(0, 0, 0, 64)); + ImGui::BeginChild("#RightAMS", ImVec2(half_width, available_height - line_height * .95f), false, ImGuiWindowFlags_AlwaysUseWindowPadding); { imgui.bold_text(_u8L("Right")); ImGui::Dummy({window_padding, window_padding}); @@ -4977,9 +4979,11 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv ImGui::SameLine(); std::string title = _u8L("Slicing Result"); imgui.bold_text(title); - ImVec2 longest_text_size = imgui.calc_text_size(_u8L("Since you set 1 AMS (change) ,this arrangement would be optimal.")); - ImVec2 title_text_size = imgui.calc_text_size(title); - ImGui::SameLine(0, longest_text_size.x - title_text_size.x); + // BBS Set the width of the 8 "ABCD" words minus the "sliced result" to the spacing between the buttons and the title + float single_word_width = imgui.calc_text_size("ABCD").x; + float title_width = imgui.calc_text_size(title).x; + float spacing = 18.0f * m_scale; + ImGui::SameLine(0, (single_word_width + spacing) * 8.0f - title_width); std::wstring btn_name; if (m_fold) btn_name = ImGui::UnfoldButtonIcon + boost::nowide::widen(std::string("")); diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 51d708853..1951127ae 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -2847,9 +2847,11 @@ void ImGuiWrapper::filament_group(const std::string &filament_type, const char * std::string id = std::to_string(static_cast (filament_id + 1)); ImDrawList *draw_list = ImGui::GetWindowDrawList(); static ImTextureID transparent; - ImVec2 img_size = {30.0f, 45.0f}; - ImVec2 text_size = ImGui::CalcTextSize(filament_type.c_str()); - ImVec2 id_text_size = this->calc_text_size(id); + ImVec2 text_size = ImGui::CalcTextSize(filament_type.c_str()); + // BBS image sizing based on text width (DPI scaling) + float img_width = ImGui::CalcTextSize("ABC").x; + ImVec2 img_size = {img_width, img_width * 1.5f}; + ImVec2 id_text_size = this->calc_text_size(id); unsigned char rgb[3]; BitmapCache::load_from_svg_file_change_color(Slic3r::resources_dir() + "/images/filament_green.svg", img_size.x, img_size.y, transparent, hex_color); @@ -2865,7 +2867,7 @@ void ImGuiWrapper::filament_group(const std::string &filament_type, const char * float gray = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]; ImVec4 text_color = gray < 80 ? ImVec4(1.0f, 1.0f, 1.0f, 1.0f) : ImVec4(0, 0, 0, 1.0f); this->text_colored(text_color, id.c_str()); - ImGui::SetCursorPos({current_cursor.x + (img_size.x - text_size.x) * 0.5f, current_cursor.y + 40}); + ImGui::SetCursorPos({current_cursor.x + (img_size.x - text_size.x) * 0.5f, current_cursor.y + img_size.y}); this->text(filament_type); ImGui::EndGroup(); }