MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / LabelTextV

Method LabelTextV

KBotExt/imgui/imgui_widgets.cpp:337–363  ·  view source on GitHub ↗

Add a label+text combo aligned to other label+value widgets

Source from the content-addressed store, hash-verified

335
336// Add a label+text combo aligned to other label+value widgets
337void ImGui::LabelTextV(const char* label, const char* fmt, va_list args)
338{
339 ImGuiWindow* window = GetCurrentWindow();
340 if (window->SkipItems)
341 return;
342
343 ImGuiContext& g = *GImGui;
344 const ImGuiStyle& style = g.Style;
345 const float w = CalcItemWidth();
346
347 const char* value_text_begin, * value_text_end;
348 ImFormatStringToTempBufferV(&value_text_begin, &value_text_end, fmt, args);
349 const ImVec2 value_size = CalcTextSize(value_text_begin, value_text_end, false);
350 const ImVec2 label_size = CalcTextSize(label, NULL, true);
351
352 const ImVec2 pos = window->DC.CursorPos;
353 const ImRect value_bb(pos, pos + ImVec2(w, value_size.y + style.FramePadding.y * 2));
354 const ImRect total_bb(pos, pos + ImVec2(w + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), ImMax(value_size.y, label_size.y) + style.FramePadding.y * 2));
355 ItemSize(total_bb, style.FramePadding.y);
356 if (!ItemAdd(total_bb, 0))
357 return;
358
359 // Render
360 RenderTextClipped(value_bb.Min + style.FramePadding, value_bb.Max, value_text_begin, value_text_end, &value_size, ImVec2(0.0f, 0.0f));
361 if (label_size.x > 0.0f)
362 RenderText(ImVec2(value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y + style.FramePadding.y), label);
363}
364
365void ImGui::BulletText(const char* fmt, ...)
366{

Callers

nothing calls this directly

Calls 5

GetCurrentWindowFunction · 0.85
ImVec2Function · 0.85
ImMaxFunction · 0.85
ItemSizeFunction · 0.85

Tested by

no test coverage detected