From 9a9c253cd7fad715740bfa0c722a8b17015cc95a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 25 May 2023 12:57:39 +0200 Subject: editor/inspect: cleanup --- editor/inspect.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/editor/inspect.cpp b/editor/inspect.cpp index e6448e4e..0b707882 100644 --- a/editor/inspect.cpp +++ b/editor/inspect.cpp @@ -16,13 +16,14 @@ namespace floormat::entities { namespace { -const char* label_left(StringView label, char* buf, size_t len, float width) +template +const char* label_left(StringView label, char(&buf)[N], size_t width) { - std::snprintf(buf, len, "##%s", label.data()); + std::snprintf(buf, N, "##%s", label.data()); float x = ImGui::GetCursorPosX(); ImGui::Text("%s", label.data()); ImGui::SameLine(); - ImGui::SetCursorPosX(x + width + ImGui::GetStyle().ItemInnerSpacing.x); + ImGui::SetCursorPosX(x + (float)width + ImGui::GetStyle().ItemInnerSpacing.x); ImGui::SetNextItemWidth(-1); return buf; } @@ -40,8 +41,8 @@ template<> struct IGDT_ : std::integral_constant constexpr auto IGDT = IGDT_::value; template requires std::is_integral_v constexpr bool eqv(T a, T b) { return a == b; } -inline bool eqv(float a, float b) { return std::fabs(a - b) < 1e-8f; } -inline bool eqv(const String& a, const String& b) { return a == b; } +bool eqv(float a, float b) { return std::fabs(a - b) < 1e-8f; } +bool eqv(const String& a, const String& b) { return a == b; } template constexpr bool eqv(const Math::Vector& a, const Math::Vector& b) { return a == b; } int corrade_string_resize_callback(ImGuiInputTextCallbackData* data) @@ -80,7 +81,7 @@ bool do_inspect_field(void* datum, const erased_accessor& accessor, field_repr r should_disable = should_disable || !accessor.can_write(); [[maybe_unused]] auto disabler = begin_disabled(should_disable); bool ret = false; - const char* const label = label_left(accessor.field_name, buf, sizeof buf, (float)label_width); + const char* const label = label_left(accessor.field_name, buf, label_width); T value{}; accessor.read_fun(datum, accessor.reader, &value); auto orig = value; -- cgit v1.2.3