MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / LabelTextV

Method LabelTextV

ImGUI GLFW Tutorial/imgui/imgui_widgets.cpp:345–371  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

343
344// Add a label+text combo aligned to other label+value widgets
345void ImGui::LabelTextV(const char* label, const char* fmt, va_list args)
346{
347 ImGuiWindow* window = GetCurrentWindow();
348 if (window->SkipItems)
349 return;
350
351 ImGuiContext& g = *GImGui;
352 const ImGuiStyle& style = g.Style;
353 const float w = CalcItemWidth();
354
355 const char* value_text_begin = &g.TempBuffer[0];
356 const char* value_text_end = value_text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
357 const ImVec2 value_size = CalcTextSize(value_text_begin, value_text_end, false);
358 const ImVec2 label_size = CalcTextSize(label, NULL, true);
359
360 const ImVec2 pos = window->DC.CursorPos;
361 const ImRect value_bb(pos, pos + ImVec2(w, value_size.y + style.FramePadding.y * 2));
362 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));
363 ItemSize(total_bb, style.FramePadding.y);
364 if (!ItemAdd(total_bb, 0))
365 return;
366
367 // Render
368 RenderTextClipped(value_bb.Min + style.FramePadding, value_bb.Max, value_text_begin, value_text_end, &value_size, ImVec2(0.0f, 0.0f));
369 if (label_size.x > 0.0f)
370 RenderText(ImVec2(value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y + style.FramePadding.y), label);
371}
372
373void ImGui::BulletText(const char* fmt, ...)
374{

Callers

nothing calls this directly

Calls 4

GetCurrentWindowFunction · 0.70
ImFormatStringVFunction · 0.70
ImVec2Function · 0.70
ImMaxFunction · 0.70

Tested by

no test coverage detected