imroved spacer

This commit is contained in:
2026-03-16 03:06:14 +03:00
parent d8632dc74c
commit 2e8a74aaaf
4 changed files with 70 additions and 22 deletions

View File

@@ -187,9 +187,7 @@ namespace imgui_desktop::gui
when(m_show_right_labels, when(m_show_right_labels,
Label{{1.f, 0.f, 1.f, 1.f}, m_label_offset, m_outlined, "*LOCKED*"}), Label{{1.f, 0.f, 1.f, 1.f}, m_label_offset, m_outlined, "*LOCKED*"}),
Spacer{10}, SpaceVertical{10},
when(m_show_ring, ProgressRing{m_ring_color, m_ring_bg, m_ring_radius, m_ring_ratio,
m_ring_thickness, m_ring_offset}),
when(m_show_ring, ProgressRing{m_ring_color, m_ring_bg, m_ring_radius, m_ring_ratio, when(m_show_ring, ProgressRing{m_ring_color, m_ring_bg, m_ring_radius, m_ring_ratio,
m_ring_thickness, m_ring_offset}), m_ring_thickness, m_ring_offset}),
}, },

View File

@@ -119,10 +119,14 @@ namespace omath::hud
} }
// ── Spacers ───────────────────────────────────────────────────── // ── Spacers ─────────────────────────────────────────────────────
EntityOverlay& add_right_spacer(float size); EntityOverlay& add_right_space_vertical(float size);
EntityOverlay& add_left_spacer(float size); EntityOverlay& add_right_space_horizontal(float size);
EntityOverlay& add_top_spacer(float size); EntityOverlay& add_left_space_vertical(float size);
EntityOverlay& add_bottom_spacer(float size); EntityOverlay& add_left_space_horizontal(float size);
EntityOverlay& add_top_space_vertical(float size);
EntityOverlay& add_top_space_horizontal(float size);
EntityOverlay& add_bottom_space_vertical(float size);
EntityOverlay& add_bottom_space_horizontal(float size);
// ── Progress rings ────────────────────────────────────────────── // ── Progress rings ──────────────────────────────────────────────
EntityOverlay& add_right_progress_ring(const Color& color, const Color& bg, float radius, float ratio, EntityOverlay& add_right_progress_ring(const Color& color, const Color& bg, float radius, float ratio,

View File

@@ -99,8 +99,14 @@ namespace omath::hud::widget
template<typename W> template<typename W>
Centered(W) -> Centered<W>; Centered(W) -> Centered<W>;
/// Empty gap that advances the side cursor without drawing. /// Empty vertical gap that advances the Y cursor without drawing.
struct Spacer struct SpaceVertical
{
float size;
};
/// Empty horizontal gap that advances the X cursor without drawing.
struct SpaceHorizontal
{ {
float size; float size;
}; };
@@ -120,7 +126,7 @@ namespace omath::hud::widget
struct None struct None
{ {
}; ///< No-op placeholder — used by widget::when for disabled elements. }; ///< No-op placeholder — used by widget::when for disabled elements.
using SideWidget = std::variant<None, Bar, DashedBar, Label, Centered<Label>, Spacer, ProgressRing>; using SideWidget = std::variant<None, Bar, DashedBar, Label, Centered<Label>, SpaceVertical, SpaceHorizontal, ProgressRing>;
// ── Side containers ─────────────────────────────────────────────────────── // ── Side containers ───────────────────────────────────────────────────────
// Storing std::initializer_list<SideWidget> is safe here: the backing array // Storing std::initializer_list<SideWidget> is safe here: the backing array

View File

@@ -458,30 +458,54 @@ namespace omath::hud
{ {
} }
// ── Spacers ───────────────────────────────────────────────────────────────── // ── Spacers ─────────────────────────────────────────────────────────────────
EntityOverlay& EntityOverlay::add_right_spacer(const float size) EntityOverlay& EntityOverlay::add_right_space_vertical(const float size)
{
m_text_cursor_right.y += size;
return *this;
}
EntityOverlay& EntityOverlay::add_right_space_horizontal(const float size)
{ {
m_text_cursor_right.x += size; m_text_cursor_right.x += size;
return *this; return *this;
} }
EntityOverlay& EntityOverlay::add_left_spacer(const float size) EntityOverlay& EntityOverlay::add_left_space_vertical(const float size)
{
m_text_cursor_left.y += size;
return *this;
}
EntityOverlay& EntityOverlay::add_left_space_horizontal(const float size)
{ {
m_text_cursor_left.x -= size; m_text_cursor_left.x -= size;
return *this; return *this;
} }
EntityOverlay& EntityOverlay::add_top_spacer(const float size) EntityOverlay& EntityOverlay::add_top_space_vertical(const float size)
{ {
m_text_cursor_top.y -= size; m_text_cursor_top.y -= size;
return *this; return *this;
} }
EntityOverlay& EntityOverlay::add_bottom_spacer(const float size) EntityOverlay& EntityOverlay::add_top_space_horizontal(const float size)
{
m_text_cursor_top.x += size;
return *this;
}
EntityOverlay& EntityOverlay::add_bottom_space_vertical(const float size)
{ {
m_text_cursor_bottom.y += size; m_text_cursor_bottom.y += size;
return *this; return *this;
} }
EntityOverlay& EntityOverlay::add_bottom_space_horizontal(const float size)
{
m_text_cursor_bottom.x += size;
return *this;
}
// ── Progress rings ────────────────────────────────────────────────────────── // ── Progress rings ──────────────────────────────────────────────────────────
EntityOverlay& EntityOverlay::add_right_progress_ring(const Color& color, const Color& bg, const float radius, EntityOverlay& EntityOverlay::add_right_progress_ring(const Color& color, const Color& bg, const float radius,
const float ratio, const float thickness, const float offset, const float ratio, const float thickness, const float offset,
@@ -594,9 +618,13 @@ namespace omath::hud
{ {
add_right_label(w.child.color, w.child.offset, w.child.outlined, w.child.text); add_right_label(w.child.color, w.child.offset, w.child.outlined, w.child.text);
}, },
[this](const widget::Spacer& w) [this](const widget::SpaceVertical& w)
{ {
add_right_spacer(w.size); add_right_space_vertical(w.size);
},
[this](const widget::SpaceHorizontal& w)
{
add_right_space_horizontal(w.size);
}, },
[this](const widget::ProgressRing& w) [this](const widget::ProgressRing& w)
{ {
@@ -632,9 +660,13 @@ namespace omath::hud
{ {
add_left_label(w.child.color, w.child.offset, w.child.outlined, w.child.text); add_left_label(w.child.color, w.child.offset, w.child.outlined, w.child.text);
}, },
[this](const widget::Spacer& w) [this](const widget::SpaceVertical& w)
{ {
add_left_spacer(w.size); add_left_space_vertical(w.size);
},
[this](const widget::SpaceHorizontal& w)
{
add_left_space_horizontal(w.size);
}, },
[this](const widget::ProgressRing& w) [this](const widget::ProgressRing& w)
{ {
@@ -670,9 +702,13 @@ namespace omath::hud
{ {
add_centered_top_label(w.child.color, w.child.offset, w.child.outlined, w.child.text); add_centered_top_label(w.child.color, w.child.offset, w.child.outlined, w.child.text);
}, },
[this](const widget::Spacer& w) [this](const widget::SpaceVertical& w)
{ {
add_top_spacer(w.size); add_top_space_vertical(w.size);
},
[this](const widget::SpaceHorizontal& w)
{
add_top_space_horizontal(w.size);
}, },
[this](const widget::ProgressRing& w) [this](const widget::ProgressRing& w)
{ {
@@ -708,9 +744,13 @@ namespace omath::hud
add_centered_bottom_label(w.child.color, w.child.offset, w.child.outlined, add_centered_bottom_label(w.child.color, w.child.offset, w.child.outlined,
w.child.text); w.child.text);
}, },
[this](const widget::Spacer& w) [this](const widget::SpaceVertical& w)
{ {
add_bottom_spacer(w.size); add_bottom_space_vertical(w.size);
},
[this](const widget::SpaceHorizontal& w)
{
add_bottom_space_horizontal(w.size);
}, },
[this](const widget::ProgressRing& w) [this](const widget::ProgressRing& w)
{ {