From 2e8a74aaaf5ebb4d4f53f7c870069554467939f0 Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 16 Mar 2026 03:06:14 +0300 Subject: [PATCH] imroved spacer --- examples/example_hud/gui/main_window.cpp | 4 +- include/omath/hud/entity_overlay.hpp | 12 ++-- include/omath/hud/entity_overlay_widgets.hpp | 12 +++- source/hud/entity_overlay.cpp | 64 ++++++++++++++++---- 4 files changed, 70 insertions(+), 22 deletions(-) diff --git a/examples/example_hud/gui/main_window.cpp b/examples/example_hud/gui/main_window.cpp index c0da3c3..2f242f6 100644 --- a/examples/example_hud/gui/main_window.cpp +++ b/examples/example_hud/gui/main_window.cpp @@ -187,9 +187,7 @@ namespace imgui_desktop::gui when(m_show_right_labels, Label{{1.f, 0.f, 1.f, 1.f}, m_label_offset, m_outlined, "*LOCKED*"}), - Spacer{10}, - when(m_show_ring, ProgressRing{m_ring_color, m_ring_bg, m_ring_radius, m_ring_ratio, - m_ring_thickness, m_ring_offset}), + 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}), }, diff --git a/include/omath/hud/entity_overlay.hpp b/include/omath/hud/entity_overlay.hpp index ac8acef..1922ca4 100644 --- a/include/omath/hud/entity_overlay.hpp +++ b/include/omath/hud/entity_overlay.hpp @@ -119,10 +119,14 @@ namespace omath::hud } // ── Spacers ───────────────────────────────────────────────────── - EntityOverlay& add_right_spacer(float size); - EntityOverlay& add_left_spacer(float size); - EntityOverlay& add_top_spacer(float size); - EntityOverlay& add_bottom_spacer(float size); + EntityOverlay& add_right_space_vertical(float size); + EntityOverlay& add_right_space_horizontal(float size); + EntityOverlay& add_left_space_vertical(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 ────────────────────────────────────────────── EntityOverlay& add_right_progress_ring(const Color& color, const Color& bg, float radius, float ratio, diff --git a/include/omath/hud/entity_overlay_widgets.hpp b/include/omath/hud/entity_overlay_widgets.hpp index eaf2fc4..8a370cd 100644 --- a/include/omath/hud/entity_overlay_widgets.hpp +++ b/include/omath/hud/entity_overlay_widgets.hpp @@ -99,8 +99,14 @@ namespace omath::hud::widget template Centered(W) -> Centered; - /// Empty gap that advances the side cursor without drawing. - struct Spacer + /// Empty vertical gap that advances the Y cursor without drawing. + struct SpaceVertical + { + float size; + }; + + /// Empty horizontal gap that advances the X cursor without drawing. + struct SpaceHorizontal { float size; }; @@ -120,7 +126,7 @@ namespace omath::hud::widget struct None { }; ///< No-op placeholder — used by widget::when for disabled elements. - using SideWidget = std::variant, Spacer, ProgressRing>; + using SideWidget = std::variant, SpaceVertical, SpaceHorizontal, ProgressRing>; // ── Side containers ─────────────────────────────────────────────────────── // Storing std::initializer_list is safe here: the backing array diff --git a/source/hud/entity_overlay.cpp b/source/hud/entity_overlay.cpp index a397707..c5691cf 100644 --- a/source/hud/entity_overlay.cpp +++ b/source/hud/entity_overlay.cpp @@ -458,30 +458,54 @@ namespace omath::hud { } // ── 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; 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; 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; 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; return *this; } + EntityOverlay& EntityOverlay::add_bottom_space_horizontal(const float size) + { + m_text_cursor_bottom.x += size; + return *this; + } + // ── Progress rings ────────────────────────────────────────────────────────── EntityOverlay& EntityOverlay::add_right_progress_ring(const Color& color, const Color& bg, const float radius, 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); }, - [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) { @@ -632,9 +660,13 @@ namespace omath::hud { 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) { @@ -670,9 +702,13 @@ namespace omath::hud { 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) { @@ -708,9 +744,13 @@ namespace omath::hud add_centered_bottom_label(w.child.color, w.child.offset, w.child.outlined, 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) {