iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
IGraphicsFaustUI Class Reference

Builds an IGraphics user interface from the UI description of an IPlugFaust DSP, like Faust's own generic GUIs. More...

#include <IGraphicsFaustUI.h>

Classes

class  BoxControl
 
class  ButtonControl
 A momentary button, for Faust's button() More...
 
class  ValueDisplayControl
 Displays a bargraph's value as text, for [style:numerical]. More...
 

Public Types

using Item = FaustUIItem
 
using EType = FaustUIItem::EType
 
using CreateControlFunc = std::function< IControl *(const Item &item, int paramIdx, const IVStyle &style)>
 Creates the control for a widget. More...
 
using ControlBoundsFunc = std::function< IRECT(const Item &item, const IRECT &cell)>
 Returns the bounds of a widget's control, given the cell that the layout allocated for it. More...
 

Public Member Functions

 IGraphicsFaustUI (IPlugFaust &faust, const IVStyle &style=DEFAULT_STYLE)
 
IControl * CreateControl (const IRECT &bounds)
 Create a control containing the whole Faust UI. More...
 
void SetCreateControlFunc (EType type, CreateControlFunc func)
 Replace the function that creates the controls for a widget type. More...
 
void SetControlBoundsFunc (ControlBoundsFunc func)
 Replace the function that sizes the controls within their layout cells. More...
 
void SetPadding (float padding)
 Set the padding between controls and around boxes. More...
 
void SetTabBarHeight (float height)
 Set the height of the tab bar for tab boxes. More...
 

Static Public Member Functions

static IControl * DefaultCreateControl (const Item &item, int paramIdx, const IVStyle &style)
 The default control for each widget type. More...
 
static IRECT DefaultControlBounds (const Item &item, const IRECT &cell)
 Default control sizing: stops controls from stretching too much in large cells. More...
 

Detailed Description

Builds an IGraphics user interface from the UI description of an IPlugFaust DSP, like Faust's own generic GUIs.

Faust boxes become panels (hgroup/vgroup) or tabbed pages (tgroup), widgets become IVControls linked to the IPlug parameters created by IPlugFaust::CreateIPlugParameters() and bargraphs become meters/LEDs/value displays updated via their control tags. Widget metadata such as [style:knob], [style:menu{...}], [style:radio{...}], [style:led], [style:numerical], [unit:dB], [tooltip:...] and [hidden:1] is respected.

Basic usage, in the plug-in's layout function:

IGraphicsFaustUI faustUI(mFaust);
pGraphics->AttachControl(faustUI.CreateControl(pGraphics->GetBounds().GetPadded(-10.f)));
Builds an IGraphics user interface from the UI description of an IPlugFaust DSP, like Faust's own gen...

The control keeps a copy of the UI description, so the IGraphicsFaustUI object doesn't need to outlive it. If the DSP is recompiled (see FaustGen::SetOnCompileFunc), remove the control and create a new one. The functions used to create the controls for each widget type and to size them can be replaced to customise the UI.

Definition at line 45 of file IGraphicsFaustUI.h.

Member Typedef Documentation

◆ ControlBoundsFunc

using IGraphicsFaustUI::ControlBoundsFunc = std::function<IRECT(const Item& item, const IRECT& cell)>

Returns the bounds of a widget's control, given the cell that the layout allocated for it.

Definition at line 59 of file IGraphicsFaustUI.h.

◆ CreateControlFunc

using IGraphicsFaustUI::CreateControlFunc = std::function<IControl*(const Item& item, int paramIdx, const IVStyle& style)>

Creates the control for a widget.

Parameters
itemThe widget's description
paramIdxThe IPlug parameter linked to the widget, or kNoParameter
styleThe style to use
Returns
The new control, or nullptr to skip the widget

Definition at line 56 of file IGraphicsFaustUI.h.

◆ EType

using IGraphicsFaustUI::EType = FaustUIItem::EType

Definition at line 49 of file IGraphicsFaustUI.h.

◆ Item

Definition at line 48 of file IGraphicsFaustUI.h.

Constructor & Destructor Documentation

◆ IGraphicsFaustUI()

IGraphicsFaustUI::IGraphicsFaustUI ( IPlugFaust &  faust,
const IVStyle &  style = DEFAULT_STYLE 
)
inline
Parameters
faustThe Faust DSP, which must have been initialized. Call IPlugFaust::CreateIPlugParameters() first to link the controls to parameters.
styleThe style for the controls

Definition at line 123 of file IGraphicsFaustUI.h.

References DefaultControlBounds(), and DefaultCreateControl().

Member Function Documentation

◆ CreateControl()

IControl * IGraphicsFaustUI::CreateControl ( const IRECT &  bounds)
inline

Create a control containing the whole Faust UI.

Attach it with IGraphics::AttachControl()

Parameters
boundsThe bounds of the UI
Returns
The control, or nullptr if the DSP has no UI

Definition at line 455 of file IGraphicsFaustUI.h.

References IPlugFaust::GetPlugParamIdx(), IPlugFaust::GetUIRoot(), and IPlugFaust::NParams().

◆ DefaultControlBounds()

static IRECT IGraphicsFaustUI::DefaultControlBounds ( const Item &  item,
const IRECT &  cell 
)
inlinestatic

Default control sizing: stops controls from stretching too much in large cells.

Definition at line 211 of file IGraphicsFaustUI.h.

References IRECT::GetCentredInside(), IRECT::H(), and IRECT::W().

Referenced by IGraphicsFaustUI().

◆ DefaultCreateControl()

static IControl * IGraphicsFaustUI::DefaultCreateControl ( const Item &  item,
int  paramIdx,
const IVStyle &  style 
)
inlinestatic

The default control for each widget type.

Definition at line 153 of file IGraphicsFaustUI.h.

References IControl::SetTooltip().

Referenced by IGraphicsFaustUI().

◆ SetControlBoundsFunc()

void IGraphicsFaustUI::SetControlBoundsFunc ( ControlBoundsFunc  func)
inline

Replace the function that sizes the controls within their layout cells.

Definition at line 144 of file IGraphicsFaustUI.h.

◆ SetCreateControlFunc()

void IGraphicsFaustUI::SetCreateControlFunc ( EType  type,
CreateControlFunc  func 
)
inline

Replace the function that creates the controls for a widget type.

Definition at line 141 of file IGraphicsFaustUI.h.

◆ SetPadding()

void IGraphicsFaustUI::SetPadding ( float  padding)
inline

Set the padding between controls and around boxes.

Definition at line 147 of file IGraphicsFaustUI.h.

◆ SetTabBarHeight()

void IGraphicsFaustUI::SetTabBarHeight ( float  height)
inline

Set the height of the tab bar for tab boxes.

Definition at line 150 of file IGraphicsFaustUI.h.


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