Dusk Audio Framework
Loading...
Searching...
No Matches
UI Class Reference

#include <DafUI.hpp>

Inheritance diagram for UI:

Public Member Functions

 UI (uint width=0, uint height=0, bool automaticallyScaleAndSetAsMinimumSize=false)
 ~UI () override
bool isResizable () const noexcept
uint getBackgroundColor () const noexcept
uint getForegroundColor () const noexcept
double getSampleRate () const noexcept
const char * getBundlePath () const noexcept
void editParameter (uint32_t index, bool started)
void setParameterValue (uint32_t index, float value)
void setState (const char *key, const char *value)
bool requestStateFile (const char *key)
void sendNote (uint8_t channel, uint8_t note, uint8_t velocity)
void * getPluginInstancePointer () const noexcept

Protected Member Functions

virtual void parameterChanged (uint32_t index, float value)
virtual void programLoaded (uint32_t index)
virtual void stateChanged (const char *key, const char *value)
virtual void sampleRateChanged (double newSampleRate)
virtual void uiIdle ()
virtual void uiScaleFactorChanged (double scaleFactor)
std::vector< DGL_NAMESPACE::ClipboardDataOffer > getClipboardDataOfferTypes ()
virtual uint32_t uiClipboardDataOffer ()
virtual void uiFocus (bool focus, DGL_NAMESPACE::CrossingMode mode)
virtual void uiReshape (uint width, uint height)
void onResize (const ResizeEvent &ev) override

Friends

class PluginWindow
class UIExporter

Detailed Description

DAF UI class from where UI instances are created.

Note
You must call setSize during construction, @TODO Detailed information about this class.

Constructor & Destructor Documentation

◆ UI()

UI::UI ( uint width = 0,
uint height = 0,
bool automaticallyScaleAndSetAsMinimumSize = false )

UI class constructor. The UI should be initialized to a default state that matches the plugin side.

When automaticallyScale is set to true, DAF will automatically scale up the UI to fit the host/desktop scale factor.
It assumes aspect ratio is meant to be kept. Manually call setGeometryConstraints instead if keeping UI aspect ratio is not required.

◆ ~UI()

UI::~UI ( )
override

Destructor.

Member Function Documentation

◆ isResizable()

bool UI::isResizable ( ) const
noexcept

Check if this UI window is resizable (by the user or window manager). There are situations where an UI supports resizing but the plugin host does not, so this could return false.

You might want to add a resize handle for such cases, so the user is still allowed to resize the window. (programmatically resizing a window is always possible, but the same is not true for the window manager)

◆ getBackgroundColor()

uint UI::getBackgroundColor ( ) const
noexcept

Get the color used for UI background (i.e. window color) in RGBA format. Returns 0 by default, in case of error or lack of host support.

The following example code can be use to extract individual colors:

int red = (bgColor >> 24) & 0xff;
int green = (bgColor >> 16) & 0xff;
int blue = (bgColor >> 8) & 0xff;
See also
Color::fromRGB

◆ getForegroundColor()

uint UI::getForegroundColor ( ) const
noexcept

Get the color used for UI foreground (i.e. text color) in RGBA format. Returns 0xffffffff by default, in case of error or lack of host support.

The following example code can be use to extract individual colors:

int red = (fgColor >> 24) & 0xff;
int green = (fgColor >> 16) & 0xff;
int blue = (fgColor >> 8) & 0xff;
See also
Color::fromRGB

◆ getSampleRate()

double UI::getSampleRate ( ) const
noexcept

Get the current sample rate used in plugin processing.

See also
sampleRateChanged(double)

◆ getBundlePath()

const char * UI::getBundlePath ( ) const
noexcept

Get the bundle path where the UI resides.
Can return null if the UI is not available in a bundle (if it is a single binary).

See also
getBinaryFilename

◆ editParameter()

void UI::editParameter ( uint32_t index,
bool started )

editParameter.

Touch/pressed-down event. Lets the host know the user is tweaking a parameter. Required in some hosts to record automation.

◆ setParameterValue()

void UI::setParameterValue ( uint32_t index,
float value )

setParameterValue.

Change a parameter value in the Plugin.

◆ setState()

void UI::setState ( const char * key,
const char * value )

setState. @TODO Document this.

◆ requestStateFile()

bool UI::requestStateFile ( const char * key)

Request a new file from the host, matching the properties of a state key.
This will use the native host file browser if available, otherwise a DAF built-in file browser is used.
Response will be sent asynchronously to stateChanged, with the matching key and the new file as the value.
It is not possible to know if the action was cancelled by the user.

Returns
Success if a file-browser was opened, otherwise false.
Note
You cannot request more than one file at a time.

◆ sendNote()

void UI::sendNote ( uint8_t channel,
uint8_t note,
uint8_t velocity )

Send a single MIDI note from the UI to the plugin DSP side.
A note with zero velocity will be sent as note-off (MIDI 0x80), otherwise note-on (MIDI 0x90).

◆ getPluginInstancePointer()

void * UI::getPluginInstancePointer ( ) const
noexcept

getPluginInstancePointer. @TODO Document this.

◆ parameterChanged()

virtual void UI::parameterChanged ( uint32_t index,
float value )
protectedvirtual

A parameter has changed on the plugin side.
This is called by the host to inform the UI about parameter changes.

◆ programLoaded()

virtual void UI::programLoaded ( uint32_t index)
protectedvirtual

A program has been loaded on the plugin side.
This is called by the host to inform the UI about program changes.

◆ stateChanged()

virtual void UI::stateChanged ( const char * key,
const char * value )
protectedvirtual

A state has changed on the plugin side.
This is called by the host to inform the UI about state changes.

◆ sampleRateChanged()

virtual void UI::sampleRateChanged ( double newSampleRate)
protectedvirtual

Optional callback to inform the UI about a sample rate change on the plugin side.

See also
getSampleRate()

◆ uiIdle()

virtual void UI::uiIdle ( )
inlineprotectedvirtual

UI idle function, called to give idle time to the plugin UI directly from the host. This is called right after OS event handling and Window idle events (within the same cycle). There are no guarantees in terms of timing.

See also
addIdleCallback(IdleCallback*, uint).

◆ uiScaleFactorChanged()

virtual void UI::uiScaleFactorChanged ( double scaleFactor)
protectedvirtual

Window scale factor function, called when the scale factor changes. This function is for plugin UIs to be able to override Window::onScaleFactorChanged(double).

The default implementation does nothing. WARNING function needs a proper name

◆ getClipboardDataOfferTypes()

std::vector< DGL_NAMESPACE::ClipboardDataOffer > UI::getClipboardDataOfferTypes ( )
protected

Get the types available for the data in a clipboard. Must only be called within the context of uiClipboardDataOffer.

◆ uiClipboardDataOffer()

virtual uint32_t UI::uiClipboardDataOffer ( )
protectedvirtual

Window clipboard data offer function, called when clipboard has data present, possibly with several datatypes. While handling this event, the data types can be investigated with getClipboardDataOfferTypes() to decide whether to accept the offer.

Reimplement and return a non-zero id to accept the clipboard data offer for a particular type. UIs must ignore any type they do not recognize.

The default implementation accepts the "text/plain" mimetype.

◆ uiFocus()

virtual void UI::uiFocus ( bool focus,
DGL_NAMESPACE::CrossingMode mode )
protectedvirtual

Windows focus function, called when the window gains or loses the keyboard focus. This function is for plugin UIs to be able to override Window::onFocus(bool, CrossingMode).

The default implementation does nothing.

◆ uiReshape()

virtual void UI::uiReshape ( uint width,
uint height )
protectedvirtual

Window reshape function, called when the window is resized. This function is for plugin UIs to be able to override Window::onReshape(uint, uint).

Called from the drawing path, with the graphics context current, before the first draw that follows the resize. The plugin UI size has already been set by the time this runs. The default implementation sets up the drawing context where necessary.

You should almost never need to override this function. The most common exception is custom OpenGL setup, but only really needed for custom OpenGL drawing code.

◆ onResize()

void UI::onResize ( const ResizeEvent & ev)
overrideprotected

Widget resize function, called when the widget is resized. This is overridden here so the host knows when the UI is resized by you.

See also
Widget::onResize(const ResizeEvent&)

The documentation for this class was generated from the following file: