DISTRHO Plugin Framework
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
UI Class Referenceabstract

#include <DistrhoUI.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
 

Static Public Member Functions

static const char * getNextBundlePath () noexcept
 
static double getNextScaleFactor () noexcept
 
static uintptr_t getNextWindowId () noexcept
 

Protected Member Functions

virtual void parameterChanged (uint32_t index, float value)=0
 
virtual void programLoaded (uint32_t index)=0
 
virtual void stateChanged (const char *key, const char *value)=0
 
virtual void sampleRateChanged (double newSampleRate)
 
virtual void uiIdle ()
 
virtual void uiScaleFactorChanged (double scaleFactor)
 
void sizeChanged (uint width, uint height) override
 

Friends

class PluginWindow
 
class UIExporter
 

Detailed Description

DPF 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, DPF 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. (programatically 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:

const int red = (bgColor >> 24) & 0xff;
const int green = (bgColor >> 16) & 0xff;
const int blue = (bgColor >> 8) & 0xff;

◆ 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:

const int red = (fgColor >> 24) & 0xff;
const int green = (fgColor >> 16) & 0xff;
const int blue = (fgColor >> 8) & 0xff;

◆ 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 DPF 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.

◆ getNextBundlePath()

static const char* UI::getNextBundlePath ( )
staticnoexcept

Get the bundle path that will be used for the next UI.

Note
: This function is only valid during createUI(), it will return null when called from anywhere else.

◆ getNextScaleFactor()

static double UI::getNextScaleFactor ( )
staticnoexcept

Get the scale factor that will be used for the next UI.

Note
: This function is only valid during createUI(), it will return 1.0 when called from anywhere else.

◆ getNextWindowId()

static uintptr_t UI::getNextWindowId ( )
staticnoexcept

Get the Window Id that will be used for the next created window.

Note
: This function is only valid during createUI(), it will return 0 when called from anywhere else.

◆ parameterChanged()

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

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)
protectedpure virtual

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 
)
protectedpure virtual

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

◆ sizeChanged()

void UI::sizeChanged ( uint  width,
uint  height 
)
overrideprotected

External Window resize function, called when the window is resized. This is overriden here so the host knows when the UI is resized by you.

See also
ExternalWindow::sizeChanged(uint,uint)

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