core
core copied to clipboard
Progress Bar/Indicator
Do you have plans to incorporate progress bar or indicator widget into gi? For example, while downloading files, each downloading file is represented by a progress bar where the progress is highlighted with a different color and a percentage in it. I tried doing it manually using a label with a centered percentage but had problems with the internal color representing the progress. My attempt was also very involved as it manually tracked the progress. It should have been provided a lower and upper indicators and a goroutine spawned automatically to do the work at the end of which a successful result reported back or failure reported when no progress is detected for a predetermined time period. But I don't know exactly how to do it.
Yep I'll do that -- would be generally useful. Meanwhile, here's one version that uses the slider. One question overall is the best visual representation for such a thing -- any suggestions?
https://github.com/goki/gopix/blob/master/gopix/pprog.go
Visually the progress indicator can be just a simple horizontal or vertical bar/box. The distinguishing factor is how the indicator is rendered. The most common is the deterministic progress indicator whose background color of the bar/box changes progressively to reflect the progress. The indicator defaults to the percentage of completion. A possible enhancement is to allow the programmer to supply a custom progress indicator (which must be capable of being rendered textually), eg. clockwise rotating bar, repeating textual tokens (eg. #), etc. The custom progress indicator is supplied as a function returning a string; if not supplied, defaults to percentage. For indeterministic progress indicator where the program does not know in advance the max value, a simple textual token that repeatedly runs from left to right (or top to bottom) suffices. For timed progress indicator, i.e. a timer, the indicator could just be a countdown (i.e. time remaining); however, if the time is indeterministic (i.e. don't know in advance when task will finish), a countup(i.e. time elapsed) perhaps will be more appropriate. Above are just my suggestions. Time limiting, the deterministic progress indicator with percentage is the most useful.
The example above from gopix does the first case you mention.. I will put it into gi sometime soon..
added gi.ProgressBar -- see docs there:
/ ProgressBar is a progress bar that fills up bar as progress continues. // Call Start with a maximum value to work toward, and ProgStep each time // a progress step has been accomplished -- increments the ProgCur by one // and display is updated every ProgInc such steps.
Support for a label should be added to the progress bar. Once that is done, this issue should be closed.
The plan is to add a Meter
type that just does the progress bar, and supports different formats including a circular wheel type.
Implemented in d48855d632b5fa90238ac9b60425c6afa63d1936 and the commits around it. See #693 for circular/conic meters.