diff --git a/resources/icons/legend_colorchanges.svg b/resources/icons/legend_colorchanges.svg
new file mode 100644
index 000000000..cb95ef467
--- /dev/null
+++ b/resources/icons/legend_colorchanges.svg
@@ -0,0 +1,157 @@
+
+
+
+
diff --git a/resources/icons/legend_customgcodes.svg b/resources/icons/legend_customgcodes.svg
new file mode 100644
index 000000000..f363b39fd
--- /dev/null
+++ b/resources/icons/legend_customgcodes.svg
@@ -0,0 +1,71 @@
+
+
diff --git a/resources/icons/legend_deretract.svg b/resources/icons/legend_deretract.svg
new file mode 100644
index 000000000..4b636df9d
--- /dev/null
+++ b/resources/icons/legend_deretract.svg
@@ -0,0 +1,107 @@
+
+
+
+
diff --git a/resources/icons/legend_pauseprints.svg b/resources/icons/legend_pauseprints.svg
new file mode 100644
index 000000000..954bc00e9
--- /dev/null
+++ b/resources/icons/legend_pauseprints.svg
@@ -0,0 +1,76 @@
+
+
diff --git a/resources/icons/legend_retract.svg b/resources/icons/legend_retract.svg
new file mode 100644
index 000000000..494e2f728
--- /dev/null
+++ b/resources/icons/legend_retract.svg
@@ -0,0 +1,110 @@
+
+
+
+
diff --git a/resources/icons/legend_seams.svg b/resources/icons/legend_seams.svg
new file mode 100644
index 000000000..724414119
--- /dev/null
+++ b/resources/icons/legend_seams.svg
@@ -0,0 +1,45 @@
+
+
diff --git a/resources/icons/legend_shells.svg b/resources/icons/legend_shells.svg
new file mode 100644
index 000000000..b0a93effb
--- /dev/null
+++ b/resources/icons/legend_shells.svg
@@ -0,0 +1,77 @@
+
+
diff --git a/resources/icons/legend_toolchanges.svg b/resources/icons/legend_toolchanges.svg
new file mode 100644
index 000000000..e6c195b11
--- /dev/null
+++ b/resources/icons/legend_toolchanges.svg
@@ -0,0 +1,102 @@
+
+
diff --git a/resources/icons/legend_toolmarker.svg b/resources/icons/legend_toolmarker.svg
new file mode 100644
index 000000000..be0c80bbb
--- /dev/null
+++ b/resources/icons/legend_toolmarker.svg
@@ -0,0 +1,76 @@
+
+
diff --git a/resources/icons/legend_travel.svg b/resources/icons/legend_travel.svg
new file mode 100644
index 000000000..553e90a74
--- /dev/null
+++ b/resources/icons/legend_travel.svg
@@ -0,0 +1,163 @@
+
+
+
+
diff --git a/resources/icons/legend_wipe.svg b/resources/icons/legend_wipe.svg
new file mode 100644
index 000000000..9dbc9a655
--- /dev/null
+++ b/resources/icons/legend_wipe.svg
@@ -0,0 +1,48 @@
+
+
+
+
diff --git a/src/imgui/imconfig.h b/src/imgui/imconfig.h
index e95ae3adf..4f82a1f4c 100644
--- a/src/imgui/imconfig.h
+++ b/src/imgui/imconfig.h
@@ -155,6 +155,17 @@ namespace ImGui
const wchar_t ClippyMarker = 0x2602;
const wchar_t InfoMarker = 0x2603;
const wchar_t SliderFloatEditBtnIcon = 0x2604;
+ const wchar_t LegendTravel = 0x2605;
+ const wchar_t LegendWipe = 0x2606;
+ const wchar_t LegendRetract = 0x2607;
+ const wchar_t LegendDeretract = 0x2608;
+ const wchar_t LegendSeams = 0x2609;
+ const wchar_t LegendToolChanges = 0x2610;
+ const wchar_t LegendColorChanges = 0x2611;
+ const wchar_t LegendPausePrints = 0x2612;
+ const wchar_t LegendCustomGCodes = 0x2613;
+ const wchar_t LegendShells = 0x2614;
+ const wchar_t LegendToolMarker = 0x2615;
// void MyFunction(const char* name, const MyMatrix44& v);
}
diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp
index c628ae964..dfaba9c71 100644
--- a/src/libslic3r/Technologies.hpp
+++ b/src/libslic3r/Technologies.hpp
@@ -96,6 +96,8 @@
#define ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT (1 && ENABLE_2_4_0_BETA2)
// Enable changes in preview layout
#define ENABLE_PREVIEW_LAYOUT (1 && ENABLE_2_4_0_BETA2)
+// Enable drawing the items in legend toolbar using icons
+#define ENABLE_LEGEND_TOOLBAR_ICONS (1 && ENABLE_PREVIEW_LAYOUT)
// Enable coloring of toolpaths in preview by layer time
#define ENABLE_PREVIEW_LAYER_TIME (1 && ENABLE_2_4_0_BETA2)
// Enable showing time estimate for travel moves in legend
diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp
index 0170191af..0bbc7e8a0 100644
--- a/src/slic3r/GUI/GCodeViewer.cpp
+++ b/src/slic3r/GUI/GCodeViewer.cpp
@@ -4407,47 +4407,108 @@ void GCodeViewer::render_legend(float& legend_height)
const float margin = 3.0f;
window.DrawList->AddLine({ pos.x + margin, pos.y + size - margin }, { pos.x + size - margin, pos.y + margin }, ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }), 3.0f);
};
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ auto image_icon = [&imgui](ImGuiWindow& window, const ImVec2& pos, float size, const wchar_t& icon_id) {
+ ImGuiIO& io = ImGui::GetIO();
+ const ImTextureID tex_id = io.Fonts->TexID;
+ const float tex_w = static_cast(io.Fonts->TexWidth);
+ const float tex_h = static_cast(io.Fonts->TexHeight);
+ const ImFontAtlas::CustomRect* const rect = imgui.GetTextureCustomRect(icon_id);
+ const ImVec2 uv0 = { static_cast(rect->X) / tex_w, static_cast(rect->Y) / tex_h };
+ const ImVec2 uv1 = { static_cast(rect->X + rect->Width) / tex_w, static_cast(rect->Y + rect->Height) / tex_h };
+ window.DrawList->AddImage(tex_id, pos, { pos.x + size, pos.y + size }, uv0, uv1, ImGui::GetColorU32({ 1.0f, 1.0f, 1.0f, 1.0f }));
+ };
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
ImGui::Spacing();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::Travel, _u8L("Travel"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendTravel);
+#else
toggle_button(Preview::OptionType::Travel, _u8L("Travel"), [line_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
line_icon(window, pos, size, Travel_Colors[0]);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
ImGui::SameLine();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::Wipe, _u8L("Wipe"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendWipe);
+#else
toggle_button(Preview::OptionType::Wipe, _u8L("Wipe"), [line_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
line_icon(window, pos, size, Wipe_Color);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
ImGui::SameLine();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::Retractions, _u8L("Retractions"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendRetract);
+#else
toggle_button(Preview::OptionType::Retractions, _u8L("Retractions"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
- circle_icon(window, pos, size, Options_Colors[static_cast(EOptionsColors::Retractions)]);
+ circle_icon(window, pos, size, Options_Colors[static_cast(EOptionsColors::Retractions)]);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
ImGui::SameLine();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::Unretractions, _u8L("Deretractions"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendDeretract);
+#else
toggle_button(Preview::OptionType::Unretractions, _u8L("Deretractions"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast(EOptionsColors::Unretractions)]);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
ImGui::SameLine();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::Seams, _u8L("Seams"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendSeams);
+#else
toggle_button(Preview::OptionType::Seams, _u8L("Seams"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast(EOptionsColors::Seams)]);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
ImGui::SameLine();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::ToolChanges, _u8L("Tool changes"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendToolChanges);
+#else
toggle_button(Preview::OptionType::ToolChanges, _u8L("Tool changes"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast(EOptionsColors::ToolChanges)]);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
ImGui::SameLine();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::ColorChanges, _u8L("Color changes"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendColorChanges);
+#else
toggle_button(Preview::OptionType::ColorChanges, _u8L("Color changes"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast(EOptionsColors::ColorChanges)]);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
ImGui::SameLine();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::PausePrints, _u8L("Print pauses"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendPausePrints);
+#else
toggle_button(Preview::OptionType::PausePrints, _u8L("Print pauses"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast(EOptionsColors::PausePrints)]);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
ImGui::SameLine();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::CustomGCodes, _u8L("Custom G-codes"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendCustomGCodes);
+#else
toggle_button(Preview::OptionType::CustomGCodes, _u8L("Custom G-codes"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast(EOptionsColors::CustomGCodes)]);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
ImGui::SameLine();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::Shells, _u8L("Shells"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendShells);
+#else
toggle_button(Preview::OptionType::Shells, _u8L("Shells"), [](ImGuiWindow& window, const ImVec2& pos, float size) {
const ImU32 color = ImGui::GetColorU32({ 1.0f, 1.0f, 1.0f, 1.0f });
const float margin = 3.0f;
@@ -4458,8 +4519,13 @@ void GCodeViewer::render_legend(float& legend_height)
window.DrawList->AddLine({ pos.x + size - margin - proj, pos.y + size - margin }, { pos.x + size - margin, pos.y + size - margin - proj }, color);
window.DrawList->AddLine({ pos.x + margin + proj, pos.y + margin }, { pos.x + size - margin, pos.y + margin }, color);
window.DrawList->AddLine({ pos.x + size - margin, pos.y + margin }, { pos.x + size - margin, pos.y + size - margin - proj }, color);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
ImGui::SameLine();
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ toggle_button(Preview::OptionType::ToolMarker, _u8L("Tool marker"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
+ image_icon(window, pos, size, ImGui::LegendToolMarker);
+#else
toggle_button(Preview::OptionType::ToolMarker, _u8L("Tool marker"), [](ImGuiWindow& window, const ImVec2& pos, float size) {
const ImU32 color = ImGui::GetColorU32({ 1.0f, 1.0f, 1.0f, 0.8f });
const float margin = 3.0f;
@@ -4469,6 +4535,7 @@ void GCodeViewer::render_legend(float& legend_height)
window.DrawList->AddTriangleFilled(p1, p2, p3, color);
const float mid_x = 0.5f * (pos.x + pos.x + size);
window.DrawList->AddRectFilled({ mid_x - 0.09375f * size, p1.y - 0.25f * size }, { mid_x + 0.09375f * size, pos.y + margin }, color);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
});
bool size_dirty = !ImGui::GetCurrentWindow()->ScrollbarY && ImGui::CalcWindowNextAutoFitSize(ImGui::GetCurrentWindow()).x != ImGui::GetWindowWidth();
diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp
index 92401f0ac..058d8ef20 100644
--- a/src/slic3r/GUI/ImGuiWrapper.cpp
+++ b/src/slic3r/GUI/ImGuiWrapper.cpp
@@ -53,8 +53,21 @@ static const std::map font_icons = {
{ImGui::PreferencesButton , "notification_preferences" },
{ImGui::PreferencesHoverButton , "notification_preferences_hover"},
#if ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
- {ImGui::SliderFloatEditBtnIcon, "edit_button" },
+ {ImGui::SliderFloatEditBtnIcon , "edit_button" },
#endif // ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ {ImGui::LegendTravel , "legend_travel" },
+ {ImGui::LegendWipe , "legend_wipe" },
+ {ImGui::LegendRetract , "legend_retract" },
+ {ImGui::LegendDeretract , "legend_deretract" },
+ {ImGui::LegendSeams , "legend_seams" },
+ {ImGui::LegendToolChanges , "legend_toolchanges" },
+ {ImGui::LegendColorChanges , "legend_colorchanges" },
+ {ImGui::LegendPausePrints , "legend_pauseprints" },
+ {ImGui::LegendCustomGCodes , "legend_customgcodes" },
+ {ImGui::LegendShells , "legend_shells" },
+ {ImGui::LegendToolMarker , "legend_toolmarker" },
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
};
static const std::map font_icons_large = {
{ImGui::CloseNotifButton , "notification_close" },
@@ -1052,6 +1065,14 @@ bool ImGuiWrapper::want_any_input() const
return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput;
}
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ImFontAtlasCustomRect* ImGuiWrapper::GetTextureCustomRect(const wchar_t& tex_id)
+{
+ auto item = m_custom_glyph_rects_ids.find(tex_id);
+ return (item != m_custom_glyph_rects_ids.end()) ? ImGui::GetIO().Fonts->GetCustomRectByIndex(m_custom_glyph_rects_ids[tex_id]) : nullptr;
+}
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
+
#ifdef __APPLE__
static const ImWchar ranges_keyboard_shortcuts[] =
{
@@ -1140,12 +1161,27 @@ void ImGuiWrapper::init_font(bool compress)
int rect_id = io.Fonts->CustomRects.Size; // id of the rectangle added next
// add rectangles for the icons to the font atlas
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ for (auto& icon : font_icons) {
+ m_custom_glyph_rects_ids[icon.first] =
+ io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz, icon_sz, 3.0 * font_scale + icon_sz);
+ }
+ for (auto& icon : font_icons_large) {
+ m_custom_glyph_rects_ids[icon.first] =
+ io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz * 2, icon_sz * 2, 3.0 * font_scale + icon_sz * 2);
+ }
+ for (auto& icon : font_icons_extra_large) {
+ m_custom_glyph_rects_ids[icon.first] =
+ io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz * 4, icon_sz * 4, 3.0 * font_scale + icon_sz * 4);
+}
+#else
for (auto& icon : font_icons)
io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz, icon_sz, 3.0 * font_scale + icon_sz);
for (auto& icon : font_icons_large)
io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz * 2, icon_sz * 2, 3.0 * font_scale + icon_sz * 2);
for (auto& icon : font_icons_extra_large)
io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz * 4, icon_sz * 4, 3.0 * font_scale + icon_sz * 4);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
// Build texture atlas
unsigned char* pixels;
diff --git a/src/slic3r/GUI/ImGuiWrapper.hpp b/src/slic3r/GUI/ImGuiWrapper.hpp
index 8c17ca183..102a1537f 100644
--- a/src/slic3r/GUI/ImGuiWrapper.hpp
+++ b/src/slic3r/GUI/ImGuiWrapper.hpp
@@ -39,6 +39,9 @@ class ImGuiWrapper
#if ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
bool m_requires_extra_frame{ false };
#endif // ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ std::map m_custom_glyph_rects_ids;
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
std::string m_clipboard_text;
public:
@@ -132,6 +135,10 @@ public:
void reset_requires_extra_frame() { m_requires_extra_frame = false; }
#endif // ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
+#if ENABLE_LEGEND_TOOLBAR_ICONS
+ ImFontAtlasCustomRect* GetTextureCustomRect(const wchar_t& tex_id);
+#endif // ENABLE_LEGEND_TOOLBAR_ICONS
+
static const ImVec4 COL_GREY_DARK;
static const ImVec4 COL_GREY_LIGHT;
static const ImVec4 COL_ORANGE_DARK;