diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-28 03:44:47 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-28 04:05:05 +0200 |
commit | 37215facfcecb3a4133a740d7fda57c0ef564395 (patch) | |
tree | 22e4da3a44314c75977438e9b65eeb9b6e452ded /editor/imgui-raii.cpp | |
parent | b8a295f01dbb82e19dce92fd3a2048d98554eb75 (diff) |
w
Diffstat (limited to 'editor/imgui-raii.cpp')
-rw-r--r-- | editor/imgui-raii.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/editor/imgui-raii.cpp b/editor/imgui-raii.cpp index 8cae0818..b5997c7b 100644 --- a/editor/imgui-raii.cpp +++ b/editor/imgui-raii.cpp @@ -1,5 +1,6 @@ #include "imgui-raii.hpp" #include "compat/assert.hpp" +#include <cstdio> #include <Corrade/Containers/StringView.h> #include <Magnum/Magnum.h> #include <Magnum/Math/Color.h> @@ -159,4 +160,17 @@ raii_wrapper begin_child(StringView name, const ImVec2& size, int flags, int win return {&ImGui::EndChild}; } +const char* label_left_(StringView label, char* buf, size_t buf_len, float width); + +const char* label_left_(StringView label, char* buf, size_t buf_len, float width) +{ + std::snprintf(buf, buf_len, "##%s", label.data()); + float x = ImGui::GetCursorPosX(); + ImGui::TextEx(label.data(), label.data() + label.size()); + ImGui::SameLine(); + ImGui::SetCursorPosX(x + width + ImGui::GetStyle().ItemInnerSpacing.x); + ImGui::SetNextItemWidth(-1); + return buf; +} + } // namespace floormat::imgui |