IssueRaiser

Progress Indicators (spinner + loading bar)

Thought someone else might find these useful. Please feel free to use / change or upgrade code as needed. These are rough but work well enough for my use. (Note: Loosely inspired by Material Design.) **Screenshots/Video** ![progress_indicators](https://user-images.githubusercontent.com/623790/41831953-e5a624ee-7817-11e8-964a-4212766cb4e7.gif) If you do change them, please post your versions, I'd love to see what you come up with. Full Code (usage example can be found below): ```c++ namespace ImGui { bool BufferingBar(const char* label, float value, const ImVec2& size_arg, const ImU32& bg_col, const ImU32& fg_col) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); ImVec2 pos = window->DC.CursorPos; ImVec2 size = size_arg; size.x -= style.FramePadding.x * 2; const ImRect bb(pos, ImVec2(pos.x + size.x, pos.y + size.y)); ItemSize(bb, style.FramePadding.y); if (!ItemAdd(bb, id)) return false; // Render const float circleStart = size.x * 0.7f; const float circleEnd = size.x; const float circleWidth = circleEnd - circleStart; window->DrawList->AddRectFilled(bb.Min, ImVec2(pos.x + circleStart, bb.Max.y), bg_col); window->DrawList->AddRectFilled(

Posted by zfedoran on Jun 25, 2018, 5:41 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

github (Other)

Progress Indicators (spinner + loading bar)

zfedoranJun 25, 2018, 5:41 AM

Thought someone else might find these useful. Please feel free to use / change or upgrade code as needed. These are rough but work well enough for my use. (Note: Loosely inspired by Material Design.) **Screenshots/Video** ![progress_indicators](https://user-images.githubusercontent.com/623790/41831953-e5a624ee-7817-11e8-964a-4212766cb4e7.gif) If you do change them, please post your versions, I'd love to see what you come up with. Full Code (usage example can be found below): ```c++ namespace ImGui { bool BufferingBar(const char* label, float value, const ImVec2& size_arg, const ImU32& bg_col, const ImU32& fg_col) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); ImVec2 pos = window->DC.CursorPos; ImVec2 size = size_arg; size.x -= style.FramePadding.x * 2; const ImRect bb(pos, ImVec2(pos.x + size.x, pos.y + size.y)); ItemSize(bb, style.FramePadding.y); if (!ItemAdd(bb, id)) return false; // Render const float circleStart = size.x * 0.7f; const float circleEnd = size.x; const float circleWidth = circleEnd - circleStart; window->DrawList->AddRectFilled(bb.Min, ImVec2(pos.x + circleStart, bb.Max.y), bg_col); window->DrawList->AddRectFilled(

Comments (0)

No comments yet. Start the discussion.

Comment on this issue