Skip to content

Instantly share code, notes, and snippets.

View petrihakkinen's full-sized avatar

Petri Häkkinen petrihakkinen

  • Almost Human Ltd. / Ctrl Alt Ninja Ltd.
  • Finland
  • X @petrih3
View GitHub Profile
@petrihakkinen
petrihakkinen / InputTextRightAligned.cpp
Created June 7, 2024 13:53
ImGui InputText with right aligned text (when text wider than widget)
bool InputTextRightAligned(const char* label, const char* text, size_t length, ImGuiInputTextFlags flags, ImGuiInputTextCallback pCallback, void* pUserData)
{
const ImGuiContext& g = *ImGui::GetCurrentContext();
const ImGuiStyle& style = ImGui::GetStyle();
ImGuiWindow& window = *ImGui::GetCurrentWindow();
ImGuiID id = window.GetID(label);
bool active = g.ActiveId == id;
ImVec2 labelSize = ImGui::CalcTextSize(label, nullptr, true);