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

Method ProgressBar

KBotExt/imgui/imgui_widgets.cpp:1264–1298  ·  view source on GitHub ↗

size_arg (for each axis) < 0.0f: align to end, 0.0f: auto, > 0.0f: specified size

Source from the content-addressed store, hash-verified

1262
1263// size_arg (for each axis) < 0.0f: align to end, 0.0f: auto, > 0.0f: specified size
1264void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* overlay)
1265{
1266 ImGuiWindow* window = GetCurrentWindow();
1267 if (window->SkipItems)
1268 return;
1269
1270 ImGuiContext& g = *GImGui;
1271 const ImGuiStyle& style = g.Style;
1272
1273 ImVec2 pos = window->DC.CursorPos;
1274 ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y * 2.0f);
1275 ImRect bb(pos, pos + size);
1276 ItemSize(size, style.FramePadding.y);
1277 if (!ItemAdd(bb, 0))
1278 return;
1279
1280 // Render
1281 fraction = ImSaturate(fraction);
1282 RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
1283 bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize));
1284 const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y);
1285 RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding);
1286
1287 // Default displaying the fraction as percentage string, but user can override it
1288 char overlay_buf[32];
1289 if (!overlay)
1290 {
1291 ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction * 100 + 0.01f);
1292 overlay = overlay_buf;
1293 }
1294
1295 ImVec2 overlay_size = CalcTextSize(overlay, NULL);
1296 if (overlay_size.x > 0.0f)
1297 RenderTextClipped(ImVec2(ImClamp(fill_br.x + style.ItemSpacing.x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImVec2(0.0f, 0.5f), &bb);
1298}
1299
1300void ImGui::Bullet()
1301{

Callers

nothing calls this directly

Calls 7

GetCurrentWindowFunction · 0.85
ItemSizeFunction · 0.85
ImSaturateFunction · 0.85
ImVec2Function · 0.85
ImLerpFunction · 0.85
ImFormatStringFunction · 0.85
ImClampFunction · 0.85

Tested by

no test coverage detected