diff options
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 |