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

gfx/alert.h

Telling the user something, and asking them something.

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

Design notes

The gap this fills

A plugin had no way to say anything. It could show values and take clicks, and if a sample failed to load, or a preset came from a newer version, or an action was about to throw away an edit, the only options were to fail silently or to print to a console nobody sees. "It just didn't load" is one of the worst bug reports to receive and the easiest to prevent.

Why these are overlays and not windows

An alert is conventionally a real top-level window, and for an application that is right. For a PLUGIN it is close to the worst thing you can do: a modal window owned by a plugin can end up behind the host's own window, where the user cannot see it and cannot dismiss it, and the host's message loop is waiting on a click that can never happen. Every DAW forum has this thread.

So these live INSIDE the editor. An overlay covers the editor, takes every click, and cannot be lost behind anything -- because it is not a window, it is a rectangle in a window the host is already showing. It also means one implementation rather than three peers' worth, and it can be tested against a Bitmap with no display at all.

The cost is honest and worth stating: an overlay cannot extend past the editor's edge, so a long message wraps rather than widening. A plugin editor is not the place for a long message.

Types 3

class Overlay : public Widget

A component that covers its parent and swallows everything.

The swallowing is the point. Without it the editor behind stays live: a "discard your changes?" question with a working knob behind it is not a question, and a click that lands on both is a click the user did not mean to make twice.

class AlertOverlay : public Overlay

A message, and one or more answers.

Modal in behaviour and not in implementation: nothing blocks, and the answer arrives through onChoice. A plugin that blocked its own editor thread would stop the host's message loop, which is how a "harmless" dialog becomes a hung DAW.

class CallOutBox : public Overlay

A bubble anchored to a control.

For the things a tooltip is too small for and a dialog is too much for: a short explanation, a small set of options, a colour picker hanging off a swatch. It points AT something, which is what makes it different from a panel that happens to be nearby.

Dismissed by a click anywhere outside the bubble, and by Escape.

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