Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add update progress bar ? #7901

Open
aymen157 opened this issue Jul 1, 2023 · 10 comments · May be fixed by #12530
Open

[Feature Request] Add update progress bar ? #7901

aymen157 opened this issue Jul 1, 2023 · 10 comments · May be fixed by #12530
Milestone

Comments

@aymen157
Copy link

aymen157 commented Jul 1, 2023

Pretty useful in game updates / downloads ... and pretty simple to implement
image
Maybe something like SDL_SetTaskbarIconProgress(int percent)

possible use cases: not having to constantly alt-tab between game/whatever doing to check update progress. also can be used for in-game things such as map loading, mod loading, ... or for multiplayer games as screen loader (like the one in league of legends) or a death-timer etc..

@icculus
Copy link
Collaborator

icculus commented Jul 1, 2023

Does anything but Windows offer this?

@aymen157
Copy link
Author

aymen157 commented Jul 1, 2023

Yes. Mac os has many in fact
image
image
and more.

i don't know about linux, but pretty sure it does. either way these two dominate over 90% of desktop games

@Semphriss
Copy link
Contributor

For information, a similar bar is possible on Ubuntu 22.04. It's observable by copying a large file from the file manager:
image
This is Gnome; I did not check if other desktop environments support it.

@ritalat
Copy link
Contributor

ritalat commented Jul 10, 2023

KDE also seems to support this.
Screenshot_20230710_185335

@slouken
Copy link
Collaborator

slouken commented Jul 10, 2023

Sure, this sounds like a great feature for SDL 3.0. Feel free to submit a PR for it.

@slouken slouken added this to the 3.x milestone Jul 10, 2023
@ssokolow
Copy link

ssokolow commented Dec 5, 2024

There's one caveat on the Linux side.

Those progress bars are implementations of the Unity Launcher API... which, in a design which is not typical for such D-Bus APIs, gratuitously requires that the application refer to itself by naming an installed .desktop file.

Here are some relevant resources:

@MikuAuahDark
Copy link
Contributor

MikuAuahDark commented Jan 1, 2025

Alright, chiming in on how the API should look like.

In Windows, taskbar progress is implemented through ITaskbarList3 COM interface. More specifically, the ITaskbarList3::SetProgressState and ITaskbarList3::SetProgressValue is the most important one. Taskbar progress has these states:

  • None (no taskbar progress)
  • Indeterminate (shown as green but cycles the progress bar)
  • Normal (shown as green)
  • Paused (shown as yellow)
  • Error (shown as red)

Reading the Ubuntu Unity Launcher API, it only expose 2 state: visible progress or invisible progress. However it also has "urgency" state. If my assumption is right, this means it's possible to emulate "error" state by setting the "urgency" with visible progress.

Based on capability of those 2, I propose this API:

typedef enum SDL_ProgressState {
    SDL_PROGRESS_STATE_NONE,
    SDL_PROGRESS_STATE_NORMAL,
    SDL_PROGRESS_STATE_ERROR,
} SDL_ProgressState;

bool SDL_SetWindowProgressState(SDL_Window *window, SDL_ProgressState state);
bool SDL_SetWindowProgressValue(SDL_Window *window, double value);

For SDL_SetWindowProgressValue, the value is between 0.0 and 1.0, inclusive.

There's no "getter" function for those. Application is responsible on tracking the states themselves. It's safe to assume newly created SDL_Window* has SDL_PROGRESS_STATE_NONE progress state with value of 0.0.

I'm not sure what states are available for macOS, but if it has "paused" state then we can add an additional SDL_PROGRESS_STATE_PAUSED which is also supported in Windows.

As for the number badges, Ubuntu Launcher API seems have API for it. macOS should have a way to show it (as per above screenshot). However, Windows is the problematic one as it only offers generic "icon overlay" API which means the number badge icon must be supplied manually.

@Semphriss
Copy link
Contributor

I might give this a try once I'll be done with my current tasks. If someone else wants to try, please leave a comment here so that I don't duplicate the efforts :)

@MikuAuahDark
Copy link
Contributor

I can work on the Windows backend for this, although I'm gonna leave it to you for the boilerplate. I don't have the confidence to create boilerplate for this, so go ahead.

@RT2Code
Copy link
Contributor

RT2Code commented Mar 12, 2025

I submitted a PR for this feature: #12530

@slouken slouken modified the milestones: 3.x, 3.4.0 Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants