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

gfx/preferences_panel.h

A preferences window's contents: a row of page buttons along the top, and the chosen page below them.

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

Design notes

How it differs from a TabbedComponent

containers.h's tabs OWN nothing and keep every page alive: right for an instrument's oscillator/filter/envelope pages, which hold controls bound to parameters and are switched between constantly. A preferences page is the opposite. It is opened rarely, it may be expensive to build (an audio device list that asks every driver what it has), and it should show the state of things NOW, not as they were when the window first opened. So -- as the reference does -- a page here is a component made on demand by createComponentForPage() when its button is chosen, and destroyed when another is: switching back to "Audio" re-reads the devices.

The buttons are square, an icon above a label, the current one drawn toggled; they are painted by the LookAndFeel's icon-button background so a theme reaches them without a new hook. An icon is an SVG string (svg.h's Drawable), drawn in the theme's colour when it uses currentColor.

Where it is shown is the caller's business: in an application window, in a DocumentWindow, or inside a plugin editor as an Overlay's content.

Types 1

class PreferencesPanel : public Widget

A preferences window's contents: page buttons along the top and the chosen page below -- the reference's PreferencesPanel. The file comment says why a page is built on demand rather than kept.

Supply pages by overriding createComponentForPage() or by setting createPage -- before the first addSettingsPage(), which builds the first page at once. The panel owns the current page and lets it go whenever another is chosen -- with its own buttons, or with setCurrentPage from anywhere, a handler on the page itself included: the page is then kept until the next paint, so that handler returns into a page still there. Nothing should keep a pointer from getCurrentPageComponent() across a switch. Message thread only.

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