Vital
Loading...
Searching...
No Matches
ModulationButton Class Reference

A component representing a modulation source or connection button. More...

#include <modulation_button.h>

Inheritance diagram for ModulationButton:
PlainShapeComponent OpenGlImageComponent OpenGlComponent

Classes

class  Listener
 Interface for receiving notifications about modulation events from the ModulationButton. More...
 

Public Types

enum  MenuId { kCancel = 0 , kDisconnect , kModulationList }
 Identifiers for menu actions on the ModulationButton. More...
 
enum  MouseState {
  kNone , kHover , kMouseDown , kMouseDragging ,
  kDraggingOut
}
 States representing the current mouse interaction state. More...
 

Public Member Functions

 ModulationButton (String name)
 Constructs a ModulationButton.
 
virtual ~ModulationButton ()
 Destructor.
 
void paintBackground (Graphics &g) override
 Paints the background of the button, including meter areas and text.
 
void parentHierarchyChanged () override
 Called when the component's parent hierarchy changes.
 
void resized () override
 Called when the component is resized. Repositions internal sub-components.
 
virtual void render (OpenGlWrapper &open_gl, bool animate) override
 Renders the drag-drop shape overlay using OpenGL.
 
void mouseDown (const MouseEvent &e) override
 Handles mouse down events to select or show disconnect menus.
 
void mouseDrag (const MouseEvent &e) override
 Handles mouse drag events to start modulation mapping or continue dragging.
 
void mouseUp (const MouseEvent &e) override
 Handles mouse up events to finalize selection or modulation mappings.
 
void mouseEnter (const MouseEvent &e) override
 Handles mouse enter events to show the drag-drop overlay.
 
void mouseExit (const MouseEvent &e) override
 Handles mouse exit events to hide the drag-drop overlay.
 
void mouseWheelMove (const MouseEvent &e, const MouseWheelDetails &wheel) override
 Handles mouse wheel events to adjust modulation parameters.
 
void focusLost (FocusChangeType cause) override
 Called when the component loses keyboard focus.
 
void addListener (Listener *listener)
 Adds a Listener to receive events from this ModulationButton.
 
void disconnectIndex (int index)
 Disconnects a modulation connection at a given index in the popup menu.
 
void select (bool select)
 Selects or deselects this modulation source.
 
bool isSelected () const
 Checks if the modulation button is currently selected.
 
void setActiveModulation (bool active)
 Sets whether this modulation source is actively modulating something.
 
bool isActiveModulation () const
 Checks if the modulation source is active.
 
void setForceEnableModulationSource ()
 Forces the enable state of this modulation source in the parent synthesizer interface.
 
bool hasAnyModulation ()
 Checks if this modulation source is currently connected to any parameters.
 
void setFontSize (float size)
 Sets the font size for the modulation source text.
 
Rectangle< int > getModulationAmountBounds (int index, int total)
 Gets the bounds for a modulation amount knob at a given index.
 
Rectangle< int > getModulationAreaBounds ()
 Gets the bounding area used for modulation knobs.
 
Rectangle< int > getMeterBounds ()
 Gets the bounding area used for a modulation meter.
 
void setConnectRight (bool connect)
 Sets whether the modulation button should connect to the right edge.
 
void setDrawBorder (bool border)
 Sets whether a border should be drawn around the button.
 
void overrideText (String text)
 Overrides the displayed text on the modulation button.
 
- Public Member Functions inherited from PlainShapeComponent
 PlainShapeComponent (String name)
 Constructs a PlainShapeComponent with a given name.
 
void paintToImage (Graphics &g) override
 Renders the associated component (or itself) into the provided Graphics context.
 
void setShape (Path shape)
 Sets the shape to be drawn.
 
void setJustification (Justification justification)
 Sets the justification used when scaling the shape.
 
- Public Member Functions inherited from OpenGlImageComponent
 OpenGlImageComponent (String name="")
 Constructs an OpenGlImageComponent.
 
virtual ~OpenGlImageComponent ()=default
 Destructor.
 
virtual void init (OpenGlWrapper &open_gl) override
 Initializes any OpenGL resources for rendering this component.
 
virtual void destroy (OpenGlWrapper &open_gl) override
 Destroys OpenGL-related resources used by this component.
 
virtual void redrawImage (bool force)
 Redraws the image if necessary, creating or updating the internal Image.
 
void setComponent (Component *component)
 Sets the component to be drawn into the OpenGL image. If not set, uses this component.
 
void setScissor (bool scissor)
 Enables or disables scissor testing when drawing the image.
 
void setUseAlpha (bool use_alpha)
 Enables or disables alpha blending for the image.
 
void setColor (Colour color)
 Sets a color tint for the image.
 
OpenGlImageimage ()
 Provides access to the underlying OpenGlImage.
 
void setActive (bool active)
 Sets whether this component is active (rendered) or not.
 
void setStatic (bool static_image)
 Sets whether the image should be treated as static (not redrawn unless forced).
 
void paintEntireComponent (bool paint_entire_component)
 Controls whether paintToImage should paint the entire component hierarchy or just itself.
 
bool isActive () const
 Checks if this component is currently active.
 
- Public Member Functions inherited from OpenGlComponent
 OpenGlComponent (String name="")
 Constructs an OpenGlComponent.
 
virtual ~OpenGlComponent ()
 Destructor.
 
void addRoundedCorners ()
 Adds rounded corners to the component's edges.
 
void addBottomRoundedCorners ()
 Adds rounded corners only at the bottom of the component.
 
void renderCorners (OpenGlWrapper &open_gl, bool animate, Colour color, float rounding)
 Renders the corner shapes using the given color and rounding amount.
 
void renderCorners (OpenGlWrapper &open_gl, bool animate)
 Renders corners with default body color and rounding.
 
void repaintBackground ()
 Requests a repaint of the component's background on the OpenGL layer.
 
Colour getBodyColor () const
 Retrieves the component's body color.
 
void setParent (const SynthSection *parent)
 Sets a pointer to the parent SynthSection for skin value lookups.
 
float findValue (Skin::ValueId value_id)
 Finds a float value from the skin associated with this component's parent.
 
void setSkinValues (const Skin &skin)
 Applies the skin overrides to this component's colors.
 
void setSkinOverride (Skin::SectionOverride skin_override)
 Sets a skin override to control the component's color scheme.
 
force_inline void checkGlError ()
 Checks for and asserts that there are no OpenGL errors.
 
void setBackgroundColor (const Colour &color)
 Sets the background color of the component for painting operations.
 

Static Public Attributes

static constexpr float kFontAreaHeightRatio = 0.3f
 Ratio of the component's width used to display the text (font area).
 
static constexpr int kModulationKnobColumns = 3
 Number of modulation knob columns.
 
static constexpr int kModulationKnobRows = 2
 Number of modulation knob rows.
 
static constexpr int kMaxModulationKnobs = kModulationKnobRows * kModulationKnobColumns
 Maximum number of modulation knobs displayed.
 
static constexpr float kMeterAreaRatio = 0.05f
 Ratio of the meter area to the total width.
 

Additional Inherited Members

- Static Public Member Functions inherited from OpenGlComponent
static bool setViewPort (Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl)
 Sets the OpenGL viewport to match a specified rectangle within a component.
 
static bool setViewPort (Component *component, OpenGlWrapper &open_gl)
 Convenience overload that sets the viewport for the entire component's local bounds.
 
static void setScissor (Component *component, OpenGlWrapper &open_gl)
 Sets the OpenGL scissor region to the entire component's local bounds.
 
static void setScissorBounds (Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl)
 Sets the OpenGL scissor region to a specified rectangle within a component.
 
static std::unique_ptr< OpenGLShaderProgram::Uniform > getUniform (const OpenGlWrapper &open_gl, const OpenGLShaderProgram &program, const char *name)
 Retrieves a uniform from the shader program if it exists.
 
static std::unique_ptr< OpenGLShaderProgram::Attribute > getAttribute (const OpenGlWrapper &open_gl, const OpenGLShaderProgram &program, const char *name)
 Retrieves an attribute from the shader program if it exists.
 
static String translateFragmentShader (const String &code)
 Translates a fragment shader code snippet to be compatible with the current GL version.
 
static String translateVertexShader (const String &code)
 Translates a vertex shader code snippet to be compatible with the current GL version.
 
- Protected Member Functions inherited from OpenGlComponent
bool setViewPort (OpenGlWrapper &open_gl)
 Sets the viewport for this component using the current OpenGlWrapper.
 
- Protected Attributes inherited from OpenGlImageComponent
Component * component_
 The component being drawn into the image (if any).
 
bool active_
 Whether this component is active and should render.
 
bool static_image_
 Whether the image is static or updated on events.
 
bool paint_entire_component_
 If true, paint entire component hierarchy to image.
 
std::unique_ptr< Image > draw_image_
 The cached image that stores the drawn component.
 
OpenGlImage image_
 The OpenGlImage used to upload and draw the cached image.
 
- Protected Attributes inherited from OpenGlComponent
std::unique_ptr< OpenGlCornerscorners_
 Optional corners for rounded edges.
 
bool only_bottom_corners_
 Flag to round only the bottom corners.
 
Colour background_color_
 The background color of the component.
 
Colour body_color_
 The body color of the component.
 
const SynthSectionparent_
 Pointer to parent SynthSection for skin lookups.
 
Skin::SectionOverride skin_override_
 Skin override for custom appearance.
 
const vital::StatusOutputnum_voices_readout_
 StatusOutput for voice count lookups.
 

Detailed Description

A component representing a modulation source or connection button.

The ModulationButton displays and manages a modulation source, allowing the user to connect it to various parameters, disconnect existing connections, and visualize modulation activity. It supports interaction modes like selecting, dragging out to map modulation, and invoking context menus to disconnect modulations.

Member Enumeration Documentation

◆ MenuId

Identifiers for menu actions on the ModulationButton.

Enumerator
kCancel 
kDisconnect 
kModulationList 

◆ MouseState

States representing the current mouse interaction state.

Enumerator
kNone 
kHover 
kMouseDown 
kMouseDragging 
kDraggingOut 

Constructor & Destructor Documentation

◆ ModulationButton()

ModulationButton::ModulationButton ( String name)

Constructs a ModulationButton.

Parameters
nameThe name of the modulation source this button represents.

◆ ~ModulationButton()

ModulationButton::~ModulationButton ( )
virtual

Destructor.

Member Function Documentation

◆ addListener()

void ModulationButton::addListener ( Listener * listener)

Adds a Listener to receive events from this ModulationButton.

Parameters
listenerThe listener to add.

◆ disconnectIndex()

void ModulationButton::disconnectIndex ( int index)

Disconnects a modulation connection at a given index in the popup menu.

Parameters
indexThe selected popup menu index.

◆ focusLost()

void ModulationButton::focusLost ( FocusChangeType cause)
override

Called when the component loses keyboard focus.

Parameters
causeThe reason for losing focus.

◆ getMeterBounds()

Rectangle< int > ModulationButton::getMeterBounds ( )

Gets the bounding area used for a modulation meter.

Returns
A rectangle defining the meter area.

◆ getModulationAmountBounds()

Rectangle< int > ModulationButton::getModulationAmountBounds ( int index,
int total )

Gets the bounds for a modulation amount knob at a given index.

Parameters
indexThe index of the knob.
totalThe total number of modulation knobs.
Returns
The bounds of the knob as a Rectangle.

◆ getModulationAreaBounds()

Rectangle< int > ModulationButton::getModulationAreaBounds ( )

Gets the bounding area used for modulation knobs.

Returns
A rectangle defining the modulation area.

◆ hasAnyModulation()

bool ModulationButton::hasAnyModulation ( )

Checks if this modulation source is currently connected to any parameters.

Returns
True if any connections exist, false otherwise.

◆ isActiveModulation()

bool ModulationButton::isActiveModulation ( ) const
inline

Checks if the modulation source is active.

Returns
True if active, false otherwise.

◆ isSelected()

bool ModulationButton::isSelected ( ) const
inline

Checks if the modulation button is currently selected.

Returns
True if selected, false otherwise.

◆ mouseDown()

void ModulationButton::mouseDown ( const MouseEvent & e)
override

Handles mouse down events to select or show disconnect menus.

Parameters
eThe mouse event.

◆ mouseDrag()

void ModulationButton::mouseDrag ( const MouseEvent & e)
override

Handles mouse drag events to start modulation mapping or continue dragging.

Parameters
eThe mouse event.

◆ mouseEnter()

void ModulationButton::mouseEnter ( const MouseEvent & e)
override

Handles mouse enter events to show the drag-drop overlay.

Parameters
eThe mouse event.

◆ mouseExit()

void ModulationButton::mouseExit ( const MouseEvent & e)
override

Handles mouse exit events to hide the drag-drop overlay.

Parameters
eThe mouse event.

◆ mouseUp()

void ModulationButton::mouseUp ( const MouseEvent & e)
override

Handles mouse up events to finalize selection or modulation mappings.

Parameters
eThe mouse event.

◆ mouseWheelMove()

void ModulationButton::mouseWheelMove ( const MouseEvent & e,
const MouseWheelDetails & wheel )
override

Handles mouse wheel events to adjust modulation parameters.

Parameters
eThe mouse event.
wheelDetails of the wheel movement.

◆ overrideText()

void ModulationButton::overrideText ( String text)
inline

Overrides the displayed text on the modulation button.

Parameters
textThe new text to display.

◆ paintBackground()

void ModulationButton::paintBackground ( Graphics & g)
overridevirtual

Paints the background of the button, including meter areas and text.

Parameters
gThe Graphics context.

Reimplemented from OpenGlImageComponent.

◆ parentHierarchyChanged()

void ModulationButton::parentHierarchyChanged ( )
overridevirtual

Called when the component's parent hierarchy changes.

Used to find the parent SynthGuiInterface and enable/disable modulation sources accordingly.

Reimplemented from OpenGlComponent.

◆ render()

void ModulationButton::render ( OpenGlWrapper & open_gl,
bool animate )
overridevirtual

Renders the drag-drop shape overlay using OpenGL.

Parameters
open_glThe OpenGlWrapper.
animateWhether to animate changes.

Reimplemented from OpenGlImageComponent.

◆ resized()

void ModulationButton::resized ( )
overridevirtual

Called when the component is resized. Repositions internal sub-components.

Reimplemented from OpenGlComponent.

◆ select()

void ModulationButton::select ( bool select)

Selects or deselects this modulation source.

Parameters
selectTrue to select, false to deselect.

◆ setActiveModulation()

void ModulationButton::setActiveModulation ( bool active)

Sets whether this modulation source is actively modulating something.

Parameters
activeTrue if active, false otherwise.

◆ setConnectRight()

void ModulationButton::setConnectRight ( bool connect)
inline

Sets whether the modulation button should connect to the right edge.

Parameters
connectTrue if the button connects from the right, false otherwise.

◆ setDrawBorder()

void ModulationButton::setDrawBorder ( bool border)
inline

Sets whether a border should be drawn around the button.

Parameters
borderTrue to draw border, false otherwise.

◆ setFontSize()

void ModulationButton::setFontSize ( float size)
inline

Sets the font size for the modulation source text.

Parameters
sizeThe font size in points.

◆ setForceEnableModulationSource()

void ModulationButton::setForceEnableModulationSource ( )

Forces the enable state of this modulation source in the parent synthesizer interface.

Member Data Documentation

◆ kFontAreaHeightRatio

float ModulationButton::kFontAreaHeightRatio = 0.3f
staticconstexpr

Ratio of the component's width used to display the text (font area).

◆ kMaxModulationKnobs

int ModulationButton::kMaxModulationKnobs = kModulationKnobRows * kModulationKnobColumns
staticconstexpr

Maximum number of modulation knobs displayed.

◆ kMeterAreaRatio

float ModulationButton::kMeterAreaRatio = 0.05f
staticconstexpr

Ratio of the meter area to the total width.

◆ kModulationKnobColumns

int ModulationButton::kModulationKnobColumns = 3
staticconstexpr

Number of modulation knob columns.

◆ kModulationKnobRows

int ModulationButton::kModulationKnobRows = 2
staticconstexpr

Number of modulation knob rows.


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