diff --git a/src/slic3r/GUI/ImGuiDoubleSlider.cpp b/src/slic3r/GUI/ImGuiDoubleSlider.cpp index 39cbc78844..37ffcca378 100644 --- a/src/slic3r/GUI/ImGuiDoubleSlider.cpp +++ b/src/slic3r/GUI/ImGuiDoubleSlider.cpp @@ -360,11 +360,12 @@ void ImGuiControl::draw_thumb(const ImVec2& center, bool mark/* = false*/) const float line_width = 1.5f * m_draw_opts.scale; const float radius = m_draw_opts.thumb_radius(); const float line_offset = 0.5f * radius; + const float rounding = 1.5f * m_draw_opts.rounding(); const float hexagon_angle = is_horizontal() ? 0.f : IM_PI * 0.5f; - ImGuiPureWrap::draw_hexagon(center, radius, border_clr, hexagon_angle); - ImGuiPureWrap::draw_hexagon(center, radius - line_width, thumb_bg_clr, hexagon_angle); + ImGuiPureWrap::draw_hexagon(center, radius, border_clr, hexagon_angle, rounding); + ImGuiPureWrap::draw_hexagon(center, radius - line_width, thumb_bg_clr, hexagon_angle, rounding); if (mark) { ImGuiWindow* window = ImGui::GetCurrentWindow(); diff --git a/src/slic3r/GUI/ImGuiPureWrap.cpp b/src/slic3r/GUI/ImGuiPureWrap.cpp index 4b3111acd8..41ce243b1f 100644 --- a/src/slic3r/GUI/ImGuiPureWrap.cpp +++ b/src/slic3r/GUI/ImGuiPureWrap.cpp @@ -296,7 +296,7 @@ bool combo(const std::string& label, const std::vector& options, in return res; } -void draw_hexagon(const ImVec2& center, float radius, ImU32 col, float start_angle) +void draw_hexagon(const ImVec2& center, float radius, ImU32 col, float start_angle, float rounding) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -306,7 +306,21 @@ void draw_hexagon(const ImVec2& center, float radius, ImU32 col, float start_ang float a_min = start_angle; float a_max = start_angle + 2.f * IM_PI; - window->DrawList->PathArcTo(center, radius, a_min, a_max, 6); + if (rounding <= 0) { + window->DrawList->PathArcTo(center, radius, a_min, a_max, 6); + } + else { + const float a_delta = IM_PI / 4.f; + radius -= rounding; + + for (int i = 0; i <= 6; i++) { + float a = a_min + ((float)i / (float)6) * (a_max - a_min); + if (a >= 2.f * IM_PI) + a -= 2.f * IM_PI; + ImVec2 pos = ImVec2(center.x + ImCos(a) * radius, center.y + ImSin(a) * radius); + window->DrawList->PathArcTo(pos, rounding, a - a_delta, a + a_delta, 5); + } + } window->DrawList->PathFillConvex(col); } diff --git a/src/slic3r/GUI/ImGuiPureWrap.hpp b/src/slic3r/GUI/ImGuiPureWrap.hpp index ab4eccab1b..ef1f04c8a5 100644 --- a/src/slic3r/GUI/ImGuiPureWrap.hpp +++ b/src/slic3r/GUI/ImGuiPureWrap.hpp @@ -53,7 +53,7 @@ namespace ImGuiPureWrap // Use selection = -1 to not mark any option as selected bool combo(const std::string& label, const std::vector& options, int& selection, ImGuiComboFlags flags = 0, float label_width = 0.0f, float item_width = 0.0f); - void draw_hexagon(const ImVec2& center, float radius, ImU32 col, float start_angle = 0.f); + void draw_hexagon(const ImVec2& center, float radius, ImU32 col, float start_angle = 0.f, float rounding = 0.f); void text(const char* label); void text(const std::string& label);