#pragma once

#include <imgui.h>

namespace crDevUtils
{
    // right-aligns within the remaining content width. after a SameLine that width is what is left on the current row, so this aligns to the row's end rather than the window's
    inline void TextRight( const char* text )
    {
        const float textWidth = ImGui::CalcTextSize( text ).x;
        const float available = ImGui::GetContentRegionAvail().x;
        if( available > textWidth )
            ImGui::SetCursorPosX( ImGui::GetCursorPosX() + ( available - textWidth ) );

        ImGui::TextUnformatted( text );
    }

    inline bool ButtonRight( const char* label )
    {
        const float buttonWidth = ( ImGui::CalcTextSize( label ).x + ( ImGui::GetStyle().FramePadding.x * 2.0f ) );
        const float available   = ImGui::GetContentRegionAvail().x;
        if( available > buttonWidth )
            ImGui::SetCursorPosX( ImGui::GetCursorPosX() + ( available - buttonWidth ) );

        return ImGui::Button( label );
    }
}
