corrected code style

This commit is contained in:
2026-03-16 01:54:45 +03:00
parent 1744172694
commit 6487554844
5 changed files with 174 additions and 87 deletions

View File

@@ -12,6 +12,7 @@ AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignTrailingComments: false AlignTrailingComments: false
AllowShortBlocksOnASingleLine: Never AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: None AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false AllowShortLoopsOnASingleLine: false
BreakTemplateDeclarations: Leave BreakTemplateDeclarations: Leave

View File

@@ -167,8 +167,7 @@ namespace imgui_desktop::gui
m_corner_ratio, m_box_thickness}), m_corner_ratio, m_box_thickness}),
when(m_show_dashed_box, DashedBox{m_dash_color, m_dash_len, m_dash_gap, m_dash_thickness}), when(m_show_dashed_box, DashedBox{m_dash_color, m_dash_len, m_dash_gap, m_dash_thickness}),
RightSide RightSide{
{
when(m_show_right_bar, bar), when(m_show_right_bar, bar),
when(m_show_right_dashed_bar, dbar), when(m_show_right_dashed_bar, dbar),
when(m_show_right_labels, when(m_show_right_labels,
@@ -178,8 +177,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*"}),
}, },
LeftSide LeftSide{
{
when(m_show_left_bar, bar), when(m_show_left_bar, bar),
when(m_show_left_dashed_bar, dbar), when(m_show_left_dashed_bar, dbar),
when(m_show_left_labels, Label{omath::Color::from_rgba(255, 128, 0, 255), when(m_show_left_labels, Label{omath::Color::from_rgba(255, 128, 0, 255),
@@ -187,8 +185,7 @@ namespace imgui_desktop::gui
when(m_show_left_labels, Label{omath::Color::from_rgba(0, 200, 255, 255), when(m_show_left_labels, Label{omath::Color::from_rgba(0, 200, 255, 255),
m_label_offset, m_outlined, "Level: 42"}), m_label_offset, m_outlined, "Level: 42"}),
}, },
TopSide TopSide{
{
when(m_show_top_bar, bar), when(m_show_top_bar, bar),
when(m_show_top_dashed_bar, dbar), when(m_show_top_dashed_bar, dbar),
when(m_show_centered_top, Centered{Label{omath::Color::from_rgba(0, 255, 255, 255), when(m_show_centered_top, Centered{Label{omath::Color::from_rgba(0, 255, 255, 255),
@@ -198,8 +195,7 @@ namespace imgui_desktop::gui
when(m_show_top_labels, Label{omath::Color::from_rgba(255, 0, 0, 255), m_label_offset, when(m_show_top_labels, Label{omath::Color::from_rgba(255, 0, 0, 255), m_label_offset,
m_outlined, "*BLEEDING*"}), m_outlined, "*BLEEDING*"}),
}, },
BottomSide BottomSide{
{
when(m_show_bottom_bar, bar), when(m_show_bottom_bar, bar),
when(m_show_bottom_dashed_bar, dbar), when(m_show_bottom_dashed_bar, dbar),
when(m_show_centered_bottom, Centered{Label{omath::Color::from_rgba(255, 255, 255, 255), when(m_show_centered_bottom, Centered{Label{omath::Color::from_rgba(255, 255, 255, 255),

View File

@@ -142,15 +142,15 @@ namespace omath::hud
dispatch(*w); dispatch(*w);
} }
void dispatch(const widget::Box& w); void dispatch(const widget::Box& box);
void dispatch(const widget::CorneredBox& w); void dispatch(const widget::CorneredBox& cornered_box);
void dispatch(const widget::DashedBox& w); void dispatch(const widget::DashedBox& dashed_box);
void dispatch(const widget::RightSide& w); void dispatch(const widget::RightSide& right_side);
void dispatch(const widget::LeftSide& w); void dispatch(const widget::LeftSide& left_side);
void dispatch(const widget::TopSide& w); void dispatch(const widget::TopSide& top_side);
void dispatch(const widget::BottomSide& w); void dispatch(const widget::BottomSide& bottom_side);
void dispatch(const widget::Skeleton& w); void dispatch(const widget::Skeleton& skeleton);
void dispatch(const widget::SnapLine& w); void dispatch(const widget::SnapLine& snap_line);
void draw_outlined_text(const Vector2<float>& position, const Color& color, const std::string_view& text); void draw_outlined_text(const Vector2<float>& position, const Color& color, const std::string_view& text);
void draw_dashed_line(const Vector2<float>& from, const Vector2<float>& to, const Color& color, float dash_len, void draw_dashed_line(const Vector2<float>& from, const Vector2<float>& to, const Color& color, float dash_len,
float gap_len, float thickness) const; float gap_len, float thickness) const;

View File

@@ -84,9 +84,9 @@ namespace omath::hud::widget
struct Label struct Label
{ {
Color color; Color color;
float offset; float offset;
bool outlined; bool outlined;
std::string_view text; std::string_view text;
}; };
@@ -100,7 +100,9 @@ namespace omath::hud::widget
Centered(W) -> Centered<W>; Centered(W) -> Centered<W>;
// ── Side widget variant ─────────────────────────────────────────────────── // ── Side widget variant ───────────────────────────────────────────────────
struct None {}; ///< No-op placeholder — used by widget::when for disabled elements. struct None
{
}; ///< No-op placeholder — used by widget::when for disabled elements.
using SideWidget = std::variant<None, Bar, DashedBar, Label, Centered<Label>>; using SideWidget = std::variant<None, Bar, DashedBar, Label, Centered<Label>>;
// ── Side containers ─────────────────────────────────────────────────────── // ── Side containers ───────────────────────────────────────────────────────
@@ -109,10 +111,34 @@ namespace omath::hud::widget
// temporary side-container object, which is consumed within the same // temporary side-container object, which is consumed within the same
// full-expression by EntityOverlay::dispatch. No heap allocation occurs. // full-expression by EntityOverlay::dispatch. No heap allocation occurs.
struct RightSide { std::initializer_list<SideWidget> children; RightSide(std::initializer_list<SideWidget> c) : children(c) {} }; struct RightSide
struct LeftSide { std::initializer_list<SideWidget> children; LeftSide(std::initializer_list<SideWidget> c) : children(c) {} }; {
struct TopSide { std::initializer_list<SideWidget> children; TopSide(std::initializer_list<SideWidget> c) : children(c) {} }; std::initializer_list<SideWidget> children;
struct BottomSide { std::initializer_list<SideWidget> children; BottomSide(std::initializer_list<SideWidget> c) : children(c) {} }; RightSide(const std::initializer_list<SideWidget> c): children(c)
{
}
};
struct LeftSide
{
std::initializer_list<SideWidget> children;
LeftSide(const std::initializer_list<SideWidget> c): children(c)
{
}
};
struct TopSide
{
std::initializer_list<SideWidget> children;
TopSide(const std::initializer_list<SideWidget> c): children(c)
{
}
};
struct BottomSide
{
std::initializer_list<SideWidget> children;
BottomSide(const std::initializer_list<SideWidget> c): children(c)
{
}
};
} // namespace omath::hud::widget } // namespace omath::hud::widget
@@ -121,10 +147,11 @@ namespace omath::hud::widget
/// Inside XxxSide containers: returns the widget as a SideWidget when condition is true, /// Inside XxxSide containers: returns the widget as a SideWidget when condition is true,
/// or None{} otherwise. Preferred over hud::when for types inside the SideWidget variant. /// or None{} otherwise. Preferred over hud::when for types inside the SideWidget variant.
template<typename W> template<typename W>
requires std::constructible_from<SideWidget, W> requires std::constructible_from<SideWidget, W>
SideWidget when(const bool condition, W widget) SideWidget when(const bool condition, W widget)
{ {
if (condition) return SideWidget{std::move(widget)}; if (condition)
return SideWidget{std::move(widget)};
return None{}; return None{};
} }
} // namespace omath::hud::widget } // namespace omath::hud::widget
@@ -136,7 +163,8 @@ namespace omath::hud
template<typename W> template<typename W>
std::optional<W> when(const bool condition, W widget) std::optional<W> when(const bool condition, W widget)
{ {
if (condition) return std::move(widget); if (condition)
return std::move(widget);
return std::nullopt; return std::nullopt;
} }
} // namespace omath::hud } // namespace omath::hud

View File

@@ -458,84 +458,146 @@ namespace omath::hud
{ {
} }
// ── widget dispatch ─────────────────────────────────────────────────────── // ── widget dispatch ───────────────────────────────────────────────────────
void EntityOverlay::dispatch(const widget::Box& w) void EntityOverlay::dispatch(const widget::Box& box)
{ add_2d_box(w.color, w.fill, w.thickness); } {
add_2d_box(box.color, box.fill, box.thickness);
}
void EntityOverlay::dispatch(const widget::CorneredBox& w) void EntityOverlay::dispatch(const widget::CorneredBox& cornered_box)
{ add_cornered_2d_box(w.color, w.fill, w.corner_ratio, w.thickness); } {
add_cornered_2d_box(cornered_box.color, cornered_box.fill, cornered_box.corner_ratio, cornered_box.thickness);
}
void EntityOverlay::dispatch(const widget::DashedBox& w) void EntityOverlay::dispatch(const widget::DashedBox& dashed_box)
{ add_dashed_box(w.color, w.dash_len, w.gap_len, w.thickness); } {
add_dashed_box(dashed_box.color, dashed_box.dash_len, dashed_box.gap_len, dashed_box.thickness);
}
void EntityOverlay::dispatch(const widget::Skeleton& w) void EntityOverlay::dispatch(const widget::Skeleton& skeleton)
{ add_skeleton(w.color, w.thickness); } {
add_skeleton(skeleton.color, skeleton.thickness);
}
void EntityOverlay::dispatch(const widget::SnapLine& w) void EntityOverlay::dispatch(const widget::SnapLine& snap_line)
{ add_snap_line(w.start, w.color, w.width); } {
add_snap_line(snap_line.start, snap_line.color, snap_line.width);
}
// ── Side container dispatch ─────────────────────────────────────────────── // ── Side container dispatch ───────────────────────────────────────────────
void EntityOverlay::dispatch(const widget::RightSide& s) void EntityOverlay::dispatch(const widget::RightSide& s)
{ {
for (const auto& child : s.children) for (const auto& child : s.children)
std::visit(widget::Overloaded{ std::visit(
[](const widget::None&) {}, widget::Overloaded{
[this](const widget::Bar& w) [](const widget::None&)
{ add_right_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.offset); }, {
[this](const widget::DashedBar& w) },
{ add_right_dashed_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.dash_len, w.gap_len, w.offset); }, [this](const widget::Bar& w)
[this](const widget::Label& w) {
{ add_right_label(w.color, w.offset, w.outlined, w.text); }, add_right_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.offset);
[this](const widget::Centered<widget::Label>& w) },
{ add_right_label(w.child.color, w.child.offset, w.child.outlined, w.child.text); }, [this](const widget::DashedBar& w)
}, child); {
add_right_dashed_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.dash_len, w.gap_len,
w.offset);
},
[this](const widget::Label& w)
{
add_right_label(w.color, w.offset, w.outlined, w.text);
},
[this](const widget::Centered<widget::Label>& w)
{
add_right_label(w.child.color, w.child.offset, w.child.outlined, w.child.text);
},
},
child);
} }
void EntityOverlay::dispatch(const widget::LeftSide& s) void EntityOverlay::dispatch(const widget::LeftSide& s)
{ {
for (const auto& child : s.children) for (const auto& child : s.children)
std::visit(widget::Overloaded{ std::visit(
[](const widget::None&) {}, widget::Overloaded{
[this](const widget::Bar& w) [](const widget::None&)
{ add_left_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.offset); }, {
[this](const widget::DashedBar& w) },
{ add_left_dashed_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.dash_len, w.gap_len, w.offset); }, [this](const widget::Bar& w)
[this](const widget::Label& w) {
{ add_left_label(w.color, w.offset, w.outlined, w.text); }, add_left_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.offset);
[this](const widget::Centered<widget::Label>& w) },
{ add_left_label(w.child.color, w.child.offset, w.child.outlined, w.child.text); }, [this](const widget::DashedBar& w)
}, child); {
add_left_dashed_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.dash_len, w.gap_len,
w.offset);
},
[this](const widget::Label& w)
{
add_left_label(w.color, w.offset, w.outlined, w.text);
},
[this](const widget::Centered<widget::Label>& w)
{
add_left_label(w.child.color, w.child.offset, w.child.outlined, w.child.text);
},
},
child);
} }
void EntityOverlay::dispatch(const widget::TopSide& s) void EntityOverlay::dispatch(const widget::TopSide& top_side)
{ {
for (const auto& child : s.children) for (const auto& child : top_side.children)
std::visit(widget::Overloaded{ std::visit(
[](const widget::None&) {}, widget::Overloaded{
[this](const widget::Bar& w) [](const widget::None&)
{ add_top_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.offset); }, {
[this](const widget::DashedBar& w) },
{ add_top_dashed_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.dash_len, w.gap_len, w.offset); }, [this](const widget::Bar& w)
[this](const widget::Label& w) {
{ add_top_label(w.color, w.offset, w.outlined, w.text); }, add_top_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.offset);
[this](const widget::Centered<widget::Label>& w) },
{ add_centered_top_label(w.child.color, w.child.offset, w.child.outlined, w.child.text); }, [this](const widget::DashedBar& w)
}, child); {
add_top_dashed_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.dash_len, w.gap_len,
w.offset);
},
[this](const widget::Label& w)
{
add_top_label(w.color, w.offset, w.outlined, w.text);
},
[this](const widget::Centered<widget::Label>& w)
{
add_centered_top_label(w.child.color, w.child.offset, w.child.outlined, w.child.text);
},
},
child);
} }
void EntityOverlay::dispatch(const widget::BottomSide& bottom_side)
void EntityOverlay::dispatch(const widget::BottomSide& s)
{ {
for (const auto& child : s.children) for (const auto& child : bottom_side.children)
std::visit(widget::Overloaded{ std::visit(
[](const widget::None&) {}, widget::Overloaded{
[this](const widget::Bar& w) [](const widget::None&)
{ add_bottom_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.offset); }, {
[this](const widget::DashedBar& w) },
{ add_bottom_dashed_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.dash_len, w.gap_len, w.offset); }, [this](const widget::Bar& w)
[this](const widget::Label& w) {
{ add_bottom_label(w.color, w.offset, w.outlined, w.text); }, add_bottom_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.offset);
[this](const widget::Centered<widget::Label>& w) },
{ add_centered_bottom_label(w.child.color, w.child.offset, w.child.outlined, w.child.text); }, [this](const widget::DashedBar& w)
}, child); {
add_bottom_dashed_bar(w.color, w.outline, w.bg, w.size, w.ratio, w.dash_len, w.gap_len,
w.offset);
},
[this](const widget::Label& w)
{
add_bottom_label(w.color, w.offset, w.outlined, w.text);
},
[this](const widget::Centered<widget::Label>& w)
{
add_centered_bottom_label(w.child.color, w.child.offset, w.child.outlined,
w.child.text);
},
},
child);
} }
} // namespace omath::hud } // namespace omath::hud