ImguiDoubleSlider: Improvements and bug fixes

* Discard all custom changes button - click area is out of icon
* Properties info table expand button doesn't work - when pointer moves by mouse
* When some custom g-code/ pause is added then icons aren't visible well
This commit is contained in:
YuSanka 2024-04-22 21:07:08 +02:00 committed by Lukas Matena
parent 8a78ab1ce8
commit f90ea2e8be
11 changed files with 30 additions and 29 deletions

View File

@ -4,7 +4,7 @@
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve"> viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="edit_x5F_Gcode"> <g id="edit_x5F_Gcode">
<g> <g>
<path fill="#808080" d="M8,1.85l5.29,3.53V7v3.62L8,14.15l-5.29-3.53V7V5.38L8,1.85 M8,1L2,5v2v4l6,4l6-4V7V5L8,1L8,1z"/> <path fill="#646464" stroke="#808080" d="M 8 1.85 M 8 1 L 2 5 v 2 v 4 l 6 4 l 6 -4 V 7 V 5 L 8 1 L 8 1 z"/>
</g> </g>
<g> <g>
<path fill="#ED6B21" d="M7.97,7.47h2.65v2.05c0,1.73-0.82,2.48-2.69,2.48S5.3,11.25,5.3,9.55V6.39c0-1.61,0.73-2.36,2.63-2.36 <path fill="#ED6B21" d="M7.97,7.47h2.65v2.05c0,1.73-0.82,2.48-2.69,2.48S5.3,11.25,5.3,9.55V6.39c0-1.61,0.73-2.36,2.63-2.36

Before

Width:  |  Height:  |  Size: 808 B

After

Width:  |  Height:  |  Size: 797 B

View File

@ -4,7 +4,7 @@
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve"> viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="edit_x5F_Gcode"> <g id="edit_x5F_Gcode">
<g> <g>
<path fill="#ED6B21" d="M8,1.85l5.29,3.53V7v3.62L8,14.15l-5.29-3.53V7V5.38L8,1.85 M8,1L2,5v2v4l6,4l6-4V7V5L8,1L8,1z"/> <path fill="#646464" stroke="#ED6B21" d="M 8 1.85 M 8 1 L 2 5 v 2 v 4 l 6 4 l 6 -4 V 7 V 5 L 8 1 L 8 1 z"/>
</g> </g>
<g> <g>
<path fill="#ED6B21" d="M7.97,7.47h2.65v2.05c0,1.73-0.82,2.48-2.69,2.48S5.3,11.25,5.3,9.55V6.39c0-1.61,0.73-2.36,2.63-2.36 <path fill="#ED6B21" d="M7.97,7.47h2.65v2.05c0,1.73-0.82,2.48-2.69,2.48S5.3,11.25,5.3,9.55V6.39c0-1.61,0.73-2.36,2.63-2.36

Before

Width:  |  Height:  |  Size: 808 B

After

Width:  |  Height:  |  Size: 797 B

View File

@ -3,7 +3,7 @@
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve"> viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="error_tick"> <g id="error_tick">
<path fill="#808080" d="M8,1.85l5.29,3.53V7v3.62L8,14.15l-5.29-3.53V7V5.38L8,1.85 M8,1L2,5v2v4l6,4l6-4V7V5L8,1L8,1z"/> <path fill="#646464" stroke="#808080" d="M 8 1.85 M 8 1 L 2 5 v 2 v 4 l 6 4 l 6 -4 V 7 V 5 L 8 1 L 8 1 z"/>
<path fill="none" stroke="#ED6B21" stroke-linecap="round" stroke-width="2" d="M8 4 L8 9" /> <path fill="none" stroke="#ED6B21" stroke-linecap="round" stroke-width="2" d="M8 4 L8 9" />

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 629 B

View File

@ -3,7 +3,7 @@
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve"> viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="error_tick"> <g id="error_tick">
<path fill="#ED6B21" d="M8,1.85l5.29,3.53V7v3.62L8,14.15l-5.29-3.53V7V5.38L8,1.85 M8,1L2,5v2v4l6,4l6-4V7V5L8,1L8,1z"/> <path fill="#646464" stroke="#ED6B21" d="M 8 1.85 M 8 1 L 2 5 v 2 v 4 l 6 4 l 6 -4 V 7 V 5 L 8 1 L 8 1 z"/>
<path fill="none" stroke="#ED6B21" stroke-linecap="round" stroke-width="2" d="M8 4 L8 9" /> <path fill="none" stroke="#ED6B21" stroke-linecap="round" stroke-width="2" d="M8 4 L8 9" />

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 629 B

View File

@ -4,7 +4,7 @@
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve"> viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="pause_x5F_print"> <g id="pause_x5F_print">
<g> <g>
<path fill="#808080" d="M8,1.85l5.29,3.53V7v3.62L8,14.15l-5.29-3.53V7V5.38L8,1.85 M8,1L2,5v2v4l6,4l6-4V7V5L8,1L8,1z"/> <path fill="#646464" stroke="#808080" d="M 8 1.85 M 8 1 L 2 5 v 2 v 4 l 6 4 l 6 -4 V 7 V 5 L 8 1 L 8 1 z"/>
</g> </g>
<g> <g>
<path fill="#ED6B21" d="M6,11.71c-0.39,0-0.71-0.32-0.71-0.71V5c0-0.39,0.32-0.71,0.71-0.71S6.71,4.61,6.71,5v6 <path fill="#ED6B21" d="M6,11.71c-0.39,0-0.71-0.32-0.71-0.71V5c0-0.39,0.32-0.71,0.71-0.71S6.71,4.61,6.71,5v6

Before

Width:  |  Height:  |  Size: 833 B

After

Width:  |  Height:  |  Size: 822 B

View File

@ -4,7 +4,7 @@
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve"> viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="pause_x5F_print"> <g id="pause_x5F_print">
<g> <g>
<path fill="#ED6B21" d="M8,1.85l5.29,3.53V7v3.62L8,14.15l-5.29-3.53V7V5.38L8,1.85 M8,1L2,5v2v4l6,4l6-4V7V5L8,1L8,1z"/> <path fill="#646464" stroke="#ED6B21" d="M 8 1.85 M 8 1 L 2 5 v 2 v 4 l 6 4 l 6 -4 V 7 V 5 L 8 1 L 8 1 z"/>
</g> </g>
<g> <g>
<path fill="#ED6B21" d="M6,11.71c-0.39,0-0.71-0.32-0.71-0.71V5c0-0.39,0.32-0.71,0.71-0.71S6.71,4.61,6.71,5v6 <path fill="#ED6B21" d="M6,11.71c-0.39,0-0.71-0.32-0.71-0.71V5c0-0.39,0.32-0.71,0.71-0.71S6.71,4.61,6.71,5v6

Before

Width:  |  Height:  |  Size: 833 B

After

Width:  |  Height:  |  Size: 822 B

View File

@ -8,7 +8,7 @@
namespace DoubleSlider { namespace DoubleSlider {
static const float LEFT_MARGIN = 13.0f + 100.0f; // avoid thumbnail toolbar static const float LEFT_MARGIN = 13.0f + 100.0f; // avoid thumbnail toolbar
static const float HORIZONTAL_SLIDER_HEIGHT = 90.0f; static const float HORIZONTAL_SLIDER_HEIGHT = 45.0f;
void DSForGcode::Render(const int canvas_width, const int canvas_height, float extra_scale/* = 0.1f*/) void DSForGcode::Render(const int canvas_width, const int canvas_height, float extra_scale/* = 0.1f*/)
{ {
@ -16,7 +16,7 @@ void DSForGcode::Render(const int canvas_width, const int canvas_height, float e
return; return;
m_scale = extra_scale * 0.1f * m_em; m_scale = extra_scale * 0.1f * m_em;
ImVec2 pos = ImVec2{std::max(LEFT_MARGIN, 0.2f * canvas_width), canvas_height - HORIZONTAL_SLIDER_HEIGHT * m_scale}; ImVec2 pos = ImVec2{std::max(LEFT_MARGIN, 0.2f * canvas_width), canvas_height - 1.5f * HORIZONTAL_SLIDER_HEIGHT * m_scale};
ImVec2 size = ImVec2(canvas_width - 2 * pos.x, HORIZONTAL_SLIDER_HEIGHT * m_scale); ImVec2 size = ImVec2(canvas_width - 2 * pos.x, HORIZONTAL_SLIDER_HEIGHT * m_scale);
m_ctrl.Init(pos, size, m_scale); m_ctrl.Init(pos, size, m_scale);

View File

@ -218,7 +218,7 @@ void DSForLayers::draw_ticks(const ImRect& slideable_region)
ImGui::RenderFrame(tick_left.Min, tick_left.Max, tick_clr, false); ImGui::RenderFrame(tick_left.Min, tick_left.Max, tick_clr, false);
ImGui::RenderFrame(tick_right.Min, tick_right.Max, tick_clr, false); ImGui::RenderFrame(tick_right.Min, tick_right.Max, tick_clr, false);
ImVec2 icon_pos = ImVec2(tick_right.Max.x + icon_offset, tick_pos - icon_offset); ImVec2 icon_pos = ImVec2(tick_right.Max.x + 0.5f * icon_offset, tick_pos - icon_offset);
std::string btn_label = "tick " + std::to_string(tick_it->tick); std::string btn_label = "tick " + std::to_string(tick_it->tick);
//draw tick icon-buttons //draw tick icon-buttons
@ -286,7 +286,7 @@ void DSForLayers::draw_colored_band(const ImRect& groove, const ImRect& slideabl
if (m_ticks.empty() || m_draw_mode == dmSequentialFffPrint) if (m_ticks.empty() || m_draw_mode == dmSequentialFffPrint)
return; return;
ImVec2 blank_padding = ImVec2(5.0f, 2.0f) * m_scale; ImVec2 blank_padding = ImVec2(0.5f * m_ctrl.GetGrooveRect().GetWidth(), 2.0f * m_scale);
float blank_width = 1.0f * m_scale; float blank_width = 1.0f * m_scale;
ImRect blank_rect = ImRect(groove.GetCenter().x - blank_width, groove.Min.y, groove.GetCenter().x + blank_width, groove.Max.y); ImRect blank_rect = ImRect(groove.GetCenter().x - blank_width, groove.Min.y, groove.GetCenter().x + blank_width, groove.Max.y);
@ -627,7 +627,7 @@ void DSForLayers::Render(const int canvas_width, const int canvas_height, float
ImVec2 pos; ImVec2 pos;
pos.x = canvas_width - VERTICAL_SLIDER_WIDTH * m_scale - tick_icon_side; pos.x = canvas_width - VERTICAL_SLIDER_WIDTH * m_scale - tick_icon_side;
pos.y = 1.f * action_btn_sz; pos.y = 1.5f * action_btn_sz;
if (m_allow_editing) if (m_allow_editing)
pos.y += 2.f; pos.y += 2.f;
@ -648,13 +648,13 @@ void DSForLayers::Render(const int canvas_width, const int canvas_height, float
const float groove_center_x = m_ctrl.GetGrooveRect().GetCenter().x; const float groove_center_x = m_ctrl.GetGrooveRect().GetCenter().x;
ImVec2 btn_pos = ImVec2(groove_center_x - 0.5f * action_btn_sz, pos.y - 0.25f * action_btn_sz); ImVec2 btn_pos = ImVec2(groove_center_x - 0.5f * action_btn_sz, pos.y - 0.75f * action_btn_sz);
if (!m_ticks.empty() && m_allow_editing && if (!m_ticks.empty() && m_allow_editing &&
render_button(ImGui::DSRevert, ImGui::DSRevertHovered, "revert", btn_pos, fiRevertIcon)) render_button(ImGui::DSRevert, ImGui::DSRevertHovered, "revert", btn_pos, fiRevertIcon))
discard_all_thicks(); discard_all_thicks();
btn_pos.y += 0.1f * action_btn_sz + size.y; btn_pos.y += 0.5f * action_btn_sz + size.y;
const bool is_one_layer = m_ctrl.IsCombineThumbs(); const bool is_one_layer = m_ctrl.IsCombineThumbs();
if (render_button(is_one_layer ? ImGui::Lock : ImGui::Unlock, is_one_layer ? ImGui::LockHovered : ImGui::UnlockHovered, "one_layer", btn_pos, fiOneLayerIcon)) if (render_button(is_one_layer ? ImGui::Lock : ImGui::Unlock, is_one_layer ? ImGui::LockHovered : ImGui::UnlockHovered, "one_layer", btn_pos, fiOneLayerIcon))
ChangeOneLayerLock(); ChangeOneLayerLock();

View File

@ -285,7 +285,7 @@ void ImGuiControl::draw_background(const ImRect& slideable_region)
void ImGuiControl::draw_label(std::string label, const ImRect& thumb) void ImGuiControl::draw_label(std::string label, const ImRect& thumb)
{ {
if (label.empty()) if (label.empty() || label == "ErrVal")
return; return;
const ImVec2 thumb_center = thumb.GetCenter(); const ImVec2 thumb_center = thumb.GetCenter();
@ -313,9 +313,9 @@ void ImGuiControl::draw_label(std::string label, const ImRect& thumb)
void ImGuiControl::draw_thumb(const ImVec2& center, bool mark/* = false*/) void ImGuiControl::draw_thumb(const ImVec2& center, bool mark/* = false*/)
{ {
const float line_width = 2.0f * m_draw_opts.scale; const float line_width = 1.5f * m_draw_opts.scale;
const float line_offset = 9.0f * m_draw_opts.scale;
const float radius = m_draw_opts.thumb_radius(); const float radius = m_draw_opts.thumb_radius();
const float line_offset = 0.5f * radius;
const float hexagon_angle = is_horizontal() ? 0.f : IM_PI * 0.5f; const float hexagon_angle = is_horizontal() ? 0.f : IM_PI * 0.5f;

View File

@ -98,14 +98,14 @@ private:
struct DrawOptions { struct DrawOptions {
float scale { 1.f }; // used for Retina on osx float scale { 1.f }; // used for Retina on osx
ImVec2 dummy_sz() const { return ImVec2(24.0f, 44.0f) * scale; } ImVec2 dummy_sz() const { return ImVec2(24.0f, 22.0f) * scale; }
ImVec2 thumb_dummy_sz() const { return ImVec2(17.0f, 17.0f) * scale; } ImVec2 thumb_dummy_sz() const { return ImVec2(17.0f, 17.0f) * scale; }
ImVec2 groove_sz() const { return ImVec2(10.0f, 8.0f) * scale; } ImVec2 groove_sz() const { return ImVec2(4.0f, 4.0f) * scale; }
ImVec2 draggable_region_sz()const { return ImVec2(40.0f, 19.0f) * scale; } ImVec2 draggable_region_sz()const { return ImVec2(20.0f, 19.0f) * scale; }
ImVec2 text_dummy_sz() const { return ImVec2(50.0f, 34.0f) * scale; } ImVec2 text_dummy_sz() const { return ImVec2(50.0f, 34.0f) * scale; }
ImVec2 text_padding() const { return ImVec2( 5.0f, 2.0f) * scale; } ImVec2 text_padding() const { return ImVec2( 5.0f, 2.0f) * scale; }
float thumb_radius() const { return 14.0f * scale; } float thumb_radius() const { return 10.0f * scale; }
float thumb_border() const { return 2.0f * scale; } float thumb_border() const { return 2.0f * scale; }
float rounding() const { return 2.0f * scale; } float rounding() const { return 2.0f * scale; }
@ -235,6 +235,7 @@ public:
void Show(bool show = true) { m_ctrl.Show(show); } void Show(bool show = true) { m_ctrl.Show(show); }
void Hide() { m_ctrl.Show(false); } void Hide() { m_ctrl.Show(false); }
bool IsShown() { return m_ctrl.IsShown(); }
void SetEmUnit(int em_unit) { m_em = em_unit; } void SetEmUnit(int em_unit) { m_em = em_unit; }
void ShowLowerThumb(bool show) { m_ctrl.ShowLowerThumb(show); } void ShowLowerThumb(bool show) { m_ctrl.ShowLowerThumb(show); }

View File

@ -75,15 +75,6 @@ static const std::map<const wchar_t, std::string> font_icons = {
{ImGui::SnapMarker , "snap" }, {ImGui::SnapMarker , "snap" },
{ImGui::HorizontalHide , "horizontal_hide" }, {ImGui::HorizontalHide , "horizontal_hide" },
{ImGui::HorizontalShow , "horizontal_show" }, {ImGui::HorizontalShow , "horizontal_show" },
{ImGui::ErrorTick , "error_tick" },
{ImGui::ErrorTickHovered , "error_tick_f" },
{ImGui::PausePrint , "pause_print" },
{ImGui::PausePrintHovered , "pause_print_f" },
{ImGui::EditGCode , "edit_gcode" },
{ImGui::EditGCodeHovered , "edit_gcode_f" },
{ImGui::RemoveTick , "colorchange_del" },
{ImGui::RemoveTickHovered , "colorchange_del_f" },
}; };
static const std::map<const wchar_t, std::string> font_icons_large = { static const std::map<const wchar_t, std::string> font_icons_large = {
@ -134,6 +125,15 @@ static const std::map<const wchar_t, std::string> font_icons_medium = {
{ImGui::DSRevertHovered , "undo_f" }, {ImGui::DSRevertHovered , "undo_f" },
{ImGui::DSSettings , "cog" }, {ImGui::DSSettings , "cog" },
{ImGui::DSSettingsHovered , "cog_f" }, {ImGui::DSSettingsHovered , "cog_f" },
{ImGui::ErrorTick , "error_tick" },
{ImGui::ErrorTickHovered , "error_tick_f" },
{ImGui::PausePrint , "pause_print" },
{ImGui::PausePrintHovered , "pause_print_f" },
{ImGui::EditGCode , "edit_gcode" },
{ImGui::EditGCodeHovered , "edit_gcode_f" },
{ImGui::RemoveTick , "colorchange_del" },
{ImGui::RemoveTickHovered , "colorchange_del_f" },
}; };
static const std::map<const wchar_t, std::string> font_icons_extra_large = { static const std::map<const wchar_t, std::string> font_icons_extra_large = {