From 8f14b5395ffe6b42129ac782cbb7933610e16433 Mon Sep 17 00:00:00 2001 From: Filip Sykala Date: Mon, 2 May 2022 10:09:26 +0200 Subject: [PATCH] Icons for part type --- src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp | 63 +++++++++++++++++-------- src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp | 9 +++- 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index f8b5f80f9b..844b592213 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -1487,25 +1487,44 @@ void GLGizmoEmboss::draw_model_type() } } } - if (ImGui::RadioButton("modifier", type == modifier) && !is_last_solid_part) - new_type = modifier; - if(is_last_solid_part && ImGui::IsItemHovered()) - ImGui::SetTooltip("%s", _u8L("You can't change a type of the last solid part of the object.").c_str()); + + ImGui::Text("%s :", _u8L("Type").c_str()); + ImGui::SameLine(75); + if (type == part) { + draw_icon(IconType::part, IconState::hovered); + } else { + if (draw_button(IconType::part)) new_type = part; + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("%s", _u8L("Click to change text into object part.").c_str()); + } ImGui::SameLine(); - if (ImGui::RadioButton("negative", type == negative) && !is_last_solid_part) - new_type = negative; - if(is_last_solid_part && ImGui::IsItemHovered()) - ImGui::SetTooltip("%s", _u8L("You can't change a type of the last solid part of the object.").c_str()); + if (type == negative) { + draw_icon(IconType::negative, IconState::hovered); + } else { + if (draw_button(IconType::negative, is_last_solid_part)) + new_type = negative; + if(ImGui::IsItemHovered()){ + if(is_last_solid_part) + ImGui::SetTooltip("%s", _u8L("You can't change a type of the last solid part of the object.").c_str()); + else if (type != negative) + ImGui::SetTooltip("%s", _u8L("Click to change part type into negative volume.").c_str()); + } + } ImGui::SameLine(); - if (ImGui::RadioButton("part", type == part)) - new_type = part; - - ImGui::SameLine(); - m_imgui->disabled_begin(true); - ImGui::RadioButton("baked in", false); - m_imgui->disabled_end(); + if (type == modifier) { + draw_icon(IconType::modifier, IconState::hovered); + } else { + if(draw_button(IconType::modifier, is_last_solid_part)) + new_type = modifier; + if (ImGui::IsItemHovered()) { + if(is_last_solid_part) + ImGui::SetTooltip("%s", _u8L("You can't change a type of the last solid part of the object.").c_str()); + else if (type != modifier) + ImGui::SetTooltip("%s", _u8L("Click to change part type into modifier.").c_str()); + } + } if (m_volume != nullptr && new_type.has_value() && !is_last_solid_part) { GUI_App &app = wxGetApp(); @@ -2540,8 +2559,11 @@ void GLGizmoEmboss::init_icons() "make_bold.svg", "make_unbold.svg", "search.svg", - "open.svg", - "revert_all_.svg" + "open.svg", + "revert_all_.svg", + "add_text_part.svg", + "add_text_negative.svg", + "add_text_modifier.svg" }; assert(filenames.size() == static_cast(IconType::_count)); std::string path = resources_dir() + "/icons/"; @@ -2566,7 +2588,7 @@ void GLGizmoEmboss::init_icons() } } -void GLGizmoEmboss::draw_icon(IconType icon, IconState state) +void GLGizmoEmboss::draw_icon(IconType icon, IconState state, ImVec2 size) { // canot draw count assert(icon != IconType::_count); @@ -2590,8 +2612,11 @@ void GLGizmoEmboss::draw_icon(IconType icon, IconState state) start_y / (float) tex_height); ImVec2 uv1((start_x + icon_width) / (float) tex_width, (start_y + icon_width) / (float) tex_height); + + if (size.x < 1 || size.y < 1) + size = ImVec2(m_gui_cfg->icon_width, m_gui_cfg->icon_width); - ImGui::Image(tex_id, ImVec2(icon_width, icon_width), uv0, uv1); + ImGui::Image(tex_id, size, uv0, uv1); } void GLGizmoEmboss::draw_transparent_icon() diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp index f3b9e7ca6e..27ae788926 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp @@ -264,10 +264,15 @@ private: system_selector, open_file, revert_all, - _count /* automatic calc of icon size */ + // VolumeType icons + part, + negative, + modifier, + // automatic calc of icon's count + _count }; enum class IconState: unsigned { activable = 0, hovered /*1*/, disabled /*2*/}; - void draw_icon(IconType icon, IconState state); + void draw_icon(IconType icon, IconState state, ImVec2 size = ImVec2(0,0)); void draw_transparent_icon(); bool draw_clickable(IconType icon, IconState state, IconType hover_icon, IconState hover_state); bool draw_button(IconType icon, bool disable = false);