7 bool BufferingBar(
const char* label,
float value,
const ImVec2& size_arg,
const ImU32& bg_col,
const ImU32& fg_col) {
8 ImGuiWindow* window = GetCurrentWindow();
12 ImGuiContext& g = *GImGui;
13 const ImGuiStyle& style = g.Style;
14 const ImGuiID
id = window->GetID(label);
16 ImVec2 pos = window->DC.CursorPos;
17 ImVec2 size = size_arg;
18 size.x -= style.FramePadding.x * 2.0f;
20 const ImRect bb(pos, ImVec2(pos.x + size.x, pos.y + size.y));
21 ItemSize(bb, style.FramePadding.y);
26 const float circleStart = size.x * 0.7f;
27 const float circleEnd = size.x;
28 const float circleWidth = circleEnd - circleStart;
30 window->DrawList->AddRectFilled(bb.Min, ImVec2(pos.x + circleStart, bb.Max.y), bg_col);
31 window->DrawList->AddRectFilled(bb.Min, ImVec2(pos.x + circleStart*value, bb.Max.y), fg_col);
33 const float t = (float) g.Time;
34 const float r = size.y / 2.0f;
35 const float speed = 1.5f;
37 const float a = speed*0;
38 const float b = speed*0.333f;
39 const float c = speed*0.666f;
41 const float o1 = (circleWidth+r) * (t+a - speed * (
int)((t+a) / speed)) / speed;
42 const float o2 = (circleWidth+r) * (t+b - speed * (
int)((t+b) / speed)) / speed;
43 const float o3 = (circleWidth+r) * (t+c - speed * (
int)((t+c) / speed)) / speed;
45 window->DrawList->AddCircleFilled(ImVec2(pos.x + circleEnd - o1, bb.Min.y + r), r, bg_col);
46 window->DrawList->AddCircleFilled(ImVec2(pos.x + circleEnd - o2, bb.Min.y + r), r, bg_col);
47 window->DrawList->AddCircleFilled(ImVec2(pos.x + circleEnd - o3, bb.Min.y + r), r, bg_col);
51 bool Spinner(
const char* label,
float radius,
int thickness,
const ImU32& color) {
52 ImGuiWindow* window = GetCurrentWindow();
53 if (window->SkipItems)
56 ImGuiContext& g = *GImGui;
57 const ImGuiStyle& style = g.Style;
58 const ImGuiID
id = window->GetID(label);
60 ImVec2 pos = window->DC.CursorPos;
61 ImVec2 size((radius )*2, (radius + style.FramePadding.y)*2);
63 const ImRect bb(pos, ImVec2(pos.x + size.x, pos.y + size.y));
64 ItemSize(bb, style.FramePadding.y);
69 window->DrawList->PathClear();
71 int num_segments = 30;
72 int start = (int) abs(ImSin((
float)g.Time*1.8f)*(num_segments-5));
74 const float a_min = IM_PI*2.0f * ((float)start) / (float)num_segments;
75 const float a_max = IM_PI*2.0f * ((float)num_segments-3) / (float)num_segments;
77 const ImVec2 centre = ImVec2(pos.x+radius, pos.y+radius+style.FramePadding.y);
79 for (
int i = 0; i < num_segments; i++) {
80 const float a = a_min + ((float)i / (
float)num_segments) * (a_max - a_min);
81 window->DrawList->PathLineTo(ImVec2(centre.x + ImCos(a+(
float)g.Time*8.0f) * radius,
82 centre.y + ImSin(a+(
float)g.Time*8.0f) * radius));
85 window->DrawList->PathStroke(color,
false, (
float)thickness);