MCPcopy Create free account
hub / github.com/cinder/Cinder / TextAlignedV

Method TextAlignedV

src/imgui/imgui_widgets.cpp:352–379  ·  view source on GitHub ↗

align_x: 0.0f = left, 0.5f = center, 1.0f = right. size_x : 0.0f = shortcut for GetContentRegionAvail().x FIXME-WIP: Works but API is likely to be reworked. This is designed for 1 item on the line. (#7024)

Source from the content-addressed store, hash-verified

350// size_x : 0.0f = shortcut for GetContentRegionAvail().x
351// FIXME-WIP: Works but API is likely to be reworked. This is designed for 1 item on the line. (#7024)
352void ImGui::TextAlignedV(float align_x, float size_x, const char* fmt, va_list args)
353{
354 ImGuiWindow* window = GetCurrentWindow();
355 if (window->SkipItems)
356 return;
357
358 const char* text, *text_end;
359 ImFormatStringToTempBufferV(&text, &text_end, fmt, args);
360 const ImVec2 text_size = CalcTextSize(text, text_end);
361 size_x = CalcItemSize(ImVec2(size_x, 0.0f), 0.0f, text_size.y).x;
362
363 ImVec2 pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
364 ImVec2 pos_max(pos.x + size_x, window->ClipRect.Max.y);
365 ImVec2 size(ImMin(size_x, text_size.x), text_size.y);
366 window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, pos.x + text_size.x);
367 window->DC.IdealMaxPos.x = ImMax(window->DC.IdealMaxPos.x, pos.x + text_size.x);
368 if (align_x > 0.0f && text_size.x < size_x)
369 pos.x += ImTrunc((size_x - text_size.x) * align_x);
370 RenderTextEllipsis(window->DrawList, pos, pos_max, pos_max.x, text, text_end, &text_size);
371
372 const ImVec2 backup_max_pos = window->DC.CursorMaxPos;
373 ItemSize(size);
374 ItemAdd(ImRect(pos, pos + size), 0);
375 window->DC.CursorMaxPos.x = backup_max_pos.x; // Cancel out extending content size because right-aligned text would otherwise mess it up.
376
377 if (size_x < text_size.x && IsItemHovered(ImGuiHoveredFlags_NoNavOverride | ImGuiHoveredFlags_AllowWhenDisabled | ImGuiHoveredFlags_ForTooltip))
378 SetTooltip("%.*s", (int)(text_end - text), text);
379}
380
381void ImGui::LabelText(const char* label, const char* fmt, ...)
382{

Callers

nothing calls this directly

Calls 8

GetCurrentWindowFunction · 0.85
ImVec2Function · 0.85
ImMinFunction · 0.85
ImMaxFunction · 0.85
ImTruncFunction · 0.85
ItemSizeFunction · 0.85
ImRectFunction · 0.50

Tested by

no test coverage detected