mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-01 05:10:41 +00:00
Progress Indicators (spinner + loading bar) #1901
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#1901
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
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):
Version/Branch of Dear ImGui: dear imgui, v1.62 WIP
Standalone, minimal, complete and verifiable example:
edit (June 25th): Updated code based on feedback provided (https://github.com/ocornut/imgui/issues/1901#issuecomment-399868577)
Thanks for posting those! Added this thread to the wiki index.
Two suggestions:
std::vectorand usewindow->DrawList->PathLineTo(). There's already a vector in there for that purpose and it would have amortized so it'll work with no allocation (whereas your new vector would need to allocate)g.Timevalue as well (in seconds) to avoid that parameter.Thanks for posting those! Added this thread to the wiki index.
Two suggestions:
std::vectorand usewindow->DrawList->PathLineTo(). There's already a vector in there for that purpose and it would have amortized so it'll work with no allocation (whereas your new vector would need to allocate)g.Timevalue as well (in seconds) to avoid that parameter.@ocornut Thanks for the great feedback! I've updated the code in the original post above.
@ocornut Thanks for the great feedback! I've updated the code in the original post above.
That's useful, thanks!
I've been using something extremely simple in my app like
That's useful, thanks!
I've been using something extremely simple in my app like
@DoctorGester I've been using an even more lo-fi version of that :)
ImGui::Text("Loading %c", "|/-\\"[(int)(ImGui::GetTime() / 0.05f) & 3]);@DoctorGester I've been using an even more lo-fi version of that :)
ImGui::Text("Loading %c", "|/-\\"[(int)(ImGui::GetTime() / 0.05f) & 3]);@ocornut I want to do something in my software just so I can use that text spinner in my status bar 😆
@ocornut I want to do something in my software just so I can use that text spinner in my status bar 😆
I thought I might also share my loading indicator. It's pretty simple, but might be interesting to some.

Edit 2023-11-16: Updated loading circles to fix content box.
I thought I might also share my loading indicator. It's pretty simple, but might be interesting to some.

Edit 2023-11-16: Updated loading circles to fix content box.
I tried my hand at making the original spinner by @zfedoran adhere more closely to the material design implementations. This is inspired by the implementation in Flutter (found here), and I just used the cubic_bezier implementation from chromium.
I've tried to make sense of all the random constants in the Flutter version as well and assign them to meaningful variables.
I tried my hand at making the original spinner by @zfedoran adhere more closely to the material design implementations. This is inspired by the implementation in Flutter (found here), and I just used the cubic_bezier implementation from chromium.
I've tried to make sense of all the random constants in the Flutter version as well and assign them to meaningful variables.
@zfedoran could you confirm what's the license on your code snippet? This is really cool!
@zfedoran could you confirm what's the license on your code snippet? This is really cool!
Feel free to use the snippet however you'd like. Consider the license on the snippet MIT, same as this repository. If you build something cool with it, we'd love to see it ;)
Feel free to use the snippet however you'd like. Consider the license on the snippet MIT, same as this repository. If you build something cool with it, we'd love to see it ;)
Thanks!
Thanks!
Works Great TY
Works Great TY
Nice work! Using this in my Game (Springtech-Studios/SisijaFight)
I know this is a little old but how do I make the spinner play for a certian time?
You may store the start time at some variable and then display the spinner only if current time is less than start + {whatever interval you need}
Can you make an example?
Tried it out. Simply sleeping for n seconds seems easier.
FYI, the
SpinnerandBufferingBarfunctions have a return type specified asbool, but don't actually return at the end of the functions. This will cause a runtime crash if you just copy the code as is.