Add ImGuiTextFmt
This commit is contained in:
27
openVulkanoCpp/Scene/UI/ImGuiExtensions/ImGuiTextFmt.hpp
Normal file
27
openVulkanoCpp/Scene/UI/ImGuiExtensions/ImGuiTextFmt.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <imgui.h>
|
||||
#include <string>
|
||||
|
||||
#if __has_include("fmt/format.h")
|
||||
#include <fmt/format.h>
|
||||
#elif __has_include("spdlog/fmt/fmt.h")
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
#else
|
||||
#error "Failed to find fmt include"
|
||||
#endif
|
||||
|
||||
namespace ImGui
|
||||
{
|
||||
template <typename T, typename... Args>
|
||||
IMGUI_API void TextFmt(T&& fmt, const Args &... args) {
|
||||
std::string str = fmt::format(std::forward<T>(fmt), args...);
|
||||
ImGui::TextUnformatted(&*str.begin(), &*str.end());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user