MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / draw_busy_overlay

Function draw_busy_overlay

examples/main_image.cpp:321–348  ·  view source on GitHub ↗

Draw a spinning indicator + message as a centered overlay

Source from the content-addressed store, hash-verified

319
320// Draw a spinning indicator + message as a centered overlay
321static void draw_busy_overlay(const char* message) {
322 ImGuiIO& io = ImGui::GetIO();
323 ImVec2 center(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
324
325 // Dim background
326 ImGui::GetForegroundDrawList()->AddRectFilled(
327 ImVec2(0, 0), io.DisplaySize, IM_COL32(0, 0, 0, 140));
328
329 // Spinner
330 float t = (float)ImGui::GetTime();
331 float radius = 20.0f;
332 int num_segments = 12;
333 for (int i = 0; i < num_segments; ++i) {
334 float angle = t * 5.0f + i * (2.0f * 3.14159f / num_segments);
335 float alpha = (float)(i + 1) / num_segments;
336 float x = center.x + cosf(angle) * radius;
337 float y = center.y - 30.0f + sinf(angle) * radius;
338 ImGui::GetForegroundDrawList()->AddCircleFilled(
339 ImVec2(x, y), 3.0f,
340 IM_COL32(255, 255, 255, (int)(alpha * 255)));
341 }
342
343 // Text below spinner
344 ImVec2 text_size = ImGui::CalcTextSize(message);
345 ImGui::GetForegroundDrawList()->AddText(
346 ImVec2(center.x - text_size.x * 0.5f, center.y + 10.0f),
347 IM_COL32(255, 255, 255, 255), message);
348}
349
350// ── Main ─────────────────────────────────────────────────────────────────────
351

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected