core icon indicating copy to clipboard operation
core copied to clipboard

Progress Bar/Indicator

Open susugagalala opened this issue 4 years ago • 4 comments

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.

susugagalala avatar Feb 02 '21 02:02 susugagalala

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

rcoreilly avatar Feb 02 '21 04:02 rcoreilly

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.

susugagalala avatar Feb 02 '21 17:02 susugagalala

The example above from gopix does the first case you mention.. I will put it into gi sometime soon..

rcoreilly avatar Feb 03 '21 09:02 rcoreilly

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.

rcoreilly avatar Feb 09 '21 13:02 rcoreilly

Support for a label should be added to the progress bar. Once that is done, this issue should be closed.

kkoreilly avatar Aug 09 '23 20:08 kkoreilly

The plan is to add a Meter type that just does the progress bar, and supports different formats including a circular wheel type.

rcoreilly avatar Dec 25 '23 01:12 rcoreilly

Implemented in d48855d632b5fa90238ac9b60425c6afa63d1936 and the commits around it. See #693 for circular/conic meters.

kkoreilly avatar Jan 16 '24 06:01 kkoreilly