Add centered image helper.

This commit is contained in:
Bartosz Taudul 2022-07-26 02:06:43 +02:00
parent 1eacce9e06
commit 66a6488980
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -59,6 +59,12 @@ static constexpr const ImVec4 SyntaxColorsDimmed[] = {
return ImGui::GetTextLineHeight() / 15.f; return ImGui::GetTextLineHeight() / 15.f;
} }
[[maybe_unused]] static inline void ImageCentered( ImTextureID user_texture_id, const ImVec2& size )
{
ImGui::SetCursorPosX( ( ImGui::GetWindowWidth() - size.x ) * 0.5f );
ImGui::Image( user_texture_id, size );
}
[[maybe_unused]] static inline void TextCentered( const char* text ) [[maybe_unused]] static inline void TextCentered( const char* text )
{ {
const auto tw = ImGui::CalcTextSize( text ).x; const auto tw = ImGui::CalcTextSize( text ).x;