Search guides and the APICtrl K
  1. API reference
  2. Native GUI

gfx/splash_screen.h

SplashScreen: a borderless window that shows an image while an application starts, and fades away once it has been up for long enough.

#include <sonore/gfx/splash_screen.h>
On this page

Design notes

The reference's shape

Made with new as the application starts; shown at once, centred, above everything and off the taskbar. When the application is ready it calls deleteAfterDelay(minimum, removeOnMouseClick): the splash stays until it has been on screen for at least minimum (so a fast start does not flash it), then fades out and deletes ITSELF. With removeOnMouseClick a click starts the fade at once. Nothing else may delete it after deleteAfterDelay.

Time as an argument

The clock is advance(elapsedMs), as everywhere in this SDK that times something: the window's 33 ms tick drives it, and a test drives it with exact numbers -- "at 999 ms it is still opaque, at 1000 the fade begins" is an assertion, not a sleep.

The fade is the window's alpha (a layered window on Windows, alphaValue on macOS, _NET_WM_WINDOW_OPACITY on X11, which a compositor may ignore). The deletion goes through the message queue, never from inside the tick or the click that ended it.

RUN on Windows: style, placement, the timing at its edges, the fade's alpha read back from the window, the click, and the self-deletion.

Types 1

class SplashScreen : public TopLevelWindow

A borderless window showing an image while an application starts, that fades out and deletes itself -- the reference's SplashScreen, with the same ownership. See the file comment for the timing and the fade.

Make it with new; it shows itself, centred and on top, from the constructor. Once deleteAfterDelay() is called it OWNS ITSELF: nothing else may delete it, and it is deleted from the message queue after the fade, with onDismissed called first. An application's window, not a plugin's. Message thread only.

↑↓ to move↵ to openEvery public name in the headers, and every guide