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

A graphical user interface component representing a filter section in the synthesizer. More...

#include <filter_section.h>

Inheritance diagram for FilterSection:
SynthSection PresetSelector::Listener SynthButton::ButtonListener

Classes

class  Listener
 An interface for objects that need to respond to changes in the FilterSection. More...
 

Public Member Functions

 FilterSection (String suffix, const vital::output_map &mono_modulations)
 Constructs a FilterSection with a given suffix for parameter naming, using only mono modulations.
 
 FilterSection (int index, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations)
 Constructs a FilterSection for a given index, using both mono and poly modulations.
 
 ~FilterSection ()
 Destructor.
 
void setFilterResponseSliders ()
 Connects the filter's sliders to the filter response display.
 
void paintBackground (Graphics &g) override
 Paints the background of the filter section.
 
void paintBackgroundShadow (Graphics &g) override
 Paints a background shadow for the filter section, if active.
 
void positionTopBottom ()
 Positions UI elements in a top-bottom orientation.
 
void positionLeftRight ()
 Positions UI elements in a left-right orientation.
 
void resized () override
 Called when the component is resized.
 
void buttonClicked (Button *clicked_button) override
 Called when a button is clicked.
 
void setAllValues (vital::control_map &controls) override
 Sets all parameter values for this filter section.
 
void prevClicked () override
 Called when the previous button on the preset selector is clicked.
 
void nextClicked () override
 Called when the next button on the preset selector is clicked.
 
void textMouseDown (const MouseEvent &e) override
 Called when the user interacts with the text component of the preset selector.
 
Path getLeftMorphPath ()
 Returns a path that represents the left morph shape icon based on the current model/style.
 
Path getRightMorphPath ()
 Returns a path that represents the right morph shape icon based on the current model/style.
 
void setActive (bool active) override
 Sets the active state of this filter section.
 
void addListener (Listener *listener)
 Adds a listener to be notified of filter section events.
 
void setFilterSelected (int menu_id)
 Sets the filter model and style based on a given menu ID.
 
void clearFilterInput ()
 Clears the internal filter input toggle state.
 
void setOscillatorInput (int oscillator_index, bool input)
 Sets the oscillator input state for a given oscillator index.
 
void setSampleInput (bool input)
 Sets the sample input state.
 
- Public Member Functions inherited from SynthSection
 SynthSection (const String &name)
 Constructs a SynthSection with a given name.
 
virtual ~SynthSection ()=default
 
void setParent (const SynthSection *parent)
 Sets the parent SynthSection.
 
float findValue (Skin::ValueId value_id) const
 Finds a value in the skin overrides or from the parent if not found locally.
 
virtual void reset ()
 Resets the section and all sub-sections.
 
virtual void paint (Graphics &g) override
 Called when the component should paint itself.
 
virtual void paintSidewaysHeadingText (Graphics &g)
 Paints the section name heading text vertically if sideways_heading_ is true.
 
virtual void paintHeadingText (Graphics &g)
 Paints the heading text for this section, either sideways or horizontally.
 
virtual void setSkinValues (const Skin &skin, bool top_level)
 Sets skin values (colors, sizes) and applies them to sub-sections.
 
void setSkinOverride (Skin::SectionOverride skin_override)
 
virtual void repaintBackground ()
 Requests a repaint of the background.
 
void showPopupBrowser (SynthSection *owner, Rectangle< int > bounds, std::vector< File > directories, String extensions, std::string passthrough_name, std::string additional_folders_name)
 Shows a file browser popup (e.g., for loading samples or wavetables).
 
void updatePopupBrowser (SynthSection *owner)
 Updates the currently visible popup browser if any.
 
void showPopupSelector (Component *source, Point< int > position, const PopupItems &options, std::function< void(int)> callback, std::function< void()> cancel={ })
 Shows a popup selector with options.
 
void showDualPopupSelector (Component *source, Point< int > position, int width, const PopupItems &options, std::function< void(int)> callback)
 Shows a dual popup selector for hierarchical selection.
 
void showPopupDisplay (Component *source, const std::string &text, BubbleComponent::BubblePlacement placement, bool primary)
 Shows a brief popup display (like a tooltip).
 
void hidePopupDisplay (bool primary)
 Hides the currently shown popup display.
 
virtual void loadFile (const File &file)
 Loads a file (e.g., a sample or wavetable). Overridden by subclasses.
 
virtual File getCurrentFile ()
 Gets the currently loaded file. Overridden by subclasses.
 
virtual std::string getFileName ()
 Gets the name of the currently loaded file. Overridden by subclasses.
 
virtual std::string getFileAuthor ()
 Gets the author metadata of the currently loaded file. Overridden by subclasses.
 
virtual void paintContainer (Graphics &g)
 Paints the container background, body, heading, etc.
 
virtual void paintBody (Graphics &g, Rectangle< int > bounds)
 Paints the body background within given bounds.
 
virtual void paintBorder (Graphics &g, Rectangle< int > bounds)
 Paints the border around given bounds.
 
virtual void paintBody (Graphics &g)
 Paints the section body background using the entire component area.
 
virtual void paintBorder (Graphics &g)
 Paints the border around the entire component.
 
int getComponentShadowWidth ()
 Gets the width of shadow around components.
 
virtual void paintTabShadow (Graphics &g)
 Paints a tab-like shadow effect around the component.
 
void paintTabShadow (Graphics &g, Rectangle< int > bounds)
 Paints a tab shadow effect within specified bounds.
 
virtual void setSizeRatio (float ratio)
 Sets the size ratio for scaling UI elements.
 
void paintKnobShadows (Graphics &g)
 Paints knob shadows for all sliders.
 
Font getLabelFont ()
 Gets a suitable font for label text.
 
void setLabelFont (Graphics &g)
 Sets the Graphics context font and color for labels.
 
void drawLabelConnectionForComponents (Graphics &g, Component *left, Component *right)
 Draws a rectangular connection between labels of two components.
 
void drawLabelBackground (Graphics &g, Rectangle< int > bounds, bool text_component=false)
 Draws a background for a label area.
 
void drawLabelBackgroundForComponent (Graphics &g, Component *component)
 Draws label background for a specific component.
 
Rectangle< int > getDividedAreaBuffered (Rectangle< int > full_area, int num_sections, int section, int buffer)
 Divides an area into equal sections with buffering, returns the specified section.
 
Rectangle< int > getDividedAreaUnbuffered (Rectangle< int > full_area, int num_sections, int section, int buffer)
 Divides an area into equal sections without extra buffering, returns the specified section.
 
Rectangle< int > getLabelBackgroundBounds (Rectangle< int > bounds, bool text_component=false)
 Gets the background bounds for a label.
 
Rectangle< int > getLabelBackgroundBounds (Component *component, bool text_component=false)
 Gets the label background bounds for a component.
 
void drawLabel (Graphics &g, String text, Rectangle< int > component_bounds, bool text_component=false)
 Draws a label text below a component.
 
void drawLabelForComponent (Graphics &g, String text, Component *component, bool text_component=false)
 Draws a label for a given component.
 
void drawTextBelowComponent (Graphics &g, String text, Component *component, int space, int padding=0)
 Draws text below a component with optional padding.
 
virtual void paintChildrenShadows (Graphics &g)
 Paints shadows for child sections.
 
void paintChildrenBackgrounds (Graphics &g)
 Paints the backgrounds for all child sections.
 
void paintOpenGlChildrenBackgrounds (Graphics &g)
 Paints the backgrounds for all OpenGL child components.
 
void paintChildBackground (Graphics &g, SynthSection *child)
 Paints a child's background specifically.
 
void paintChildShadow (Graphics &g, SynthSection *child)
 Paints a child's shadow specifically.
 
void paintOpenGlBackground (Graphics &g, OpenGlComponent *child)
 Paints the background of an OpenGlComponent child.
 
void drawTextComponentBackground (Graphics &g, Rectangle< int > bounds, bool extend_to_label)
 Draws a background for a text component area.
 
void drawTempoDivider (Graphics &g, Component *sync)
 Draws a divider line for tempo-related controls.
 
virtual void initOpenGlComponents (OpenGlWrapper &open_gl)
 Initializes all OpenGL components in this section and sub-sections.
 
virtual void renderOpenGlComponents (OpenGlWrapper &open_gl, bool animate)
 Renders all OpenGL components in this section and sub-sections.
 
virtual void destroyOpenGlComponents (OpenGlWrapper &open_gl)
 Destroys all OpenGL components in this section and sub-sections.
 
virtual void sliderValueChanged (Slider *moved_slider) override
 Called when a slider value changes. Updates the synth parameter accordingly.
 
virtual void guiChanged (SynthButton *button) override
 Called when a SynthButton state changes (GUI interaction).
 
std::map< std::string, SynthSlider * > getAllSliders ()
 Gets all sliders registered in this section.
 
std::map< std::string, ToggleButton * > getAllButtons ()
 Gets all toggle buttons registered in this section.
 
std::map< std::string, ModulationButton * > getAllModulationButtons ()
 Gets all modulation buttons registered in this section.
 
bool isActive () const
 Checks if the section is currently active.
 
virtual void animate (bool animate)
 Triggers animation state change in sub-sections if needed.
 
virtual void setValue (const std::string &name, vital::mono_float value, NotificationType notification)
 Sets a single parameter value for a known control.
 
void addModulationButton (ModulationButton *button, bool show=true)
 Adds a modulation button to this section.
 
void addSubSection (SynthSection *section, bool show=true)
 Adds a subsection (another SynthSection) as a child.
 
void removeSubSection (SynthSection *section)
 Removes a previously added subsection.
 
virtual void setScrollWheelEnabled (bool enabled)
 Enables or disables scroll wheel support for this section and sub-sections.
 
ToggleButton * activator () const
 Gets the activator toggle button if any.
 
void setSkinValues (std::map< Skin::ValueId, float > values)
 Sets custom skin values for this section.
 
void setSkinValue (Skin::ValueId id, float value)
 Sets a single skin value override.
 
float getTitleWidth ()
 
float getPadding ()
 
float getPowerButtonOffset () const
 
float getKnobSectionHeight ()
 
float getSliderWidth ()
 
float getSliderOverlap ()
 
float getSliderOverlapWithSpace ()
 
float getTextComponentHeight ()
 
float getStandardKnobSize ()
 
float getTotalKnobHeight ()
 
float getTextSectionYOffset ()
 
float getModButtonWidth ()
 
float getModFontSize ()
 
float getWidgetMargin ()
 
float getWidgetRounding ()
 
float getSizeRatio () const
 
int getPopupWidth () const
 
int getDualPopupWidth () const
 
- Public Member Functions inherited from SynthButton::ButtonListener
virtual ~ButtonListener ()
 Virtual destructor.
 
- Public Member Functions inherited from PresetSelector::Listener
virtual ~Listener ()
 Virtual destructor for proper cleanup.
 
virtual void textMouseUp (const MouseEvent &e)
 

Static Public Attributes

static constexpr int kBlendLabelPaddingY = 4
 Vertical padding used for label placement relative to the blend slider.
 
- Static Public Attributes inherited from SynthSection
static constexpr int kDefaultPowerButtonOffset = 0
 
static constexpr float kPowerButtonPaddingPercent = 0.29f
 
static constexpr float kTransposeHeightPercent = 0.5f
 
static constexpr float kTuneHeightPercent = 0.4f
 
static constexpr float kJointModulationRadiusPercent = 0.1f
 
static constexpr float kJointModulationExtensionPercent = 0.6666f
 
static constexpr float kPitchLabelPercent = 0.33f
 
static constexpr float kJointLabelHeightPercent = 0.4f
 
static constexpr double kTransposeMouseSensitivity = 0.2
 
static constexpr float kJointLabelBorderRatioX = 0.05f
 
static constexpr int kDefaultBodyRounding = 4
 
static constexpr int kDefaultLabelHeight = 10
 
static constexpr int kDefaultLabelBackgroundHeight = 16
 
static constexpr int kDefaultLabelBackgroundWidth = 56
 
static constexpr int kDefaultLabelBackgroundRounding = 4
 
static constexpr int kDefaultPadding = 2
 
static constexpr int kDefaultPopupMenuWidth = 150
 
static constexpr int kDefaultDualPopupMenuWidth = 340
 
static constexpr int kDefaultStandardKnobSize = 32
 
static constexpr int kDefaultKnobThickness = 2
 
static constexpr float kDefaultKnobModulationAmountThickness = 2.0f
 
static constexpr int kDefaultKnobModulationMeterSize = 43
 
static constexpr int kDefaultKnobModulationMeterThickness = 4
 
static constexpr int kDefaultModulationButtonWidth = 64
 
static constexpr int kDefaultModFontSize = 10
 
static constexpr int kDefaultKnobSectionHeight = 64
 
static constexpr int kDefaultSliderWidth = 24
 
static constexpr int kDefaultTextWidth = 80
 
static constexpr int kDefaultTextHeight = 24
 
static constexpr int kDefaultWidgetMargin = 6
 
static constexpr float kDefaultWidgetFillFade = 0.3f
 
static constexpr float kDefaultWidgetLineWidth = 4.0f
 
static constexpr float kDefaultWidgetFillCenter = 0.0f
 

Additional Inherited Members

- Protected Member Functions inherited from SynthSection
void setSliderHasHzAlternateDisplay (SynthSlider *slider)
 
void setSidewaysHeading (bool sideways)
 
void addToggleButton (ToggleButton *button, bool show)
 
void addButton (OpenGlToggleButton *button, bool show=true)
 
void addButton (OpenGlShapeButton *button, bool show=true)
 
void addSlider (SynthSlider *slider, bool show=true, bool listen=true)
 
void addOpenGlComponent (OpenGlComponent *open_gl_component, bool to_beginning=false)
 
void setActivator (SynthButton *activator)
 
void createOffOverlay ()
 
void setPresetSelector (PresetSelector *preset_selector, bool half=false)
 
void paintJointControlSliderBackground (Graphics &g, int x, int y, int width, int height)
 
void paintJointControlBackground (Graphics &g, int x, int y, int width, int height)
 
void paintJointControl (Graphics &g, int x, int y, int width, int height, const std::string &name)
 
void placeJointControls (int x, int y, int width, int height, SynthSlider *left, SynthSlider *right, Component *widget=nullptr)
 
void placeTempoControls (int x, int y, int width, int height, SynthSlider *tempo, SynthSlider *sync)
 
void placeRotaryOption (Component *option, SynthSlider *rotary)
 
void placeKnobsInArea (Rectangle< int > area, std::vector< Component * > knobs)
 
void lockCriticalSection ()
 
void unlockCriticalSection ()
 
Rectangle< int > getPresetBrowserBounds ()
 
int getTitleTextRight ()
 
Rectangle< int > getPowerButtonBounds ()
 
Rectangle< int > getTitleBounds ()
 
float getDisplayScale () const
 
virtual int getPixelMultiple () const
 
- Protected Attributes inherited from SynthSection
std::map< Skin::ValueId, float > value_lookup_
 
std::vector< SynthSection * > sub_sections_
 
std::vector< OpenGlComponent * > open_gl_components_
 
std::map< std::string, SynthSlider * > slider_lookup_
 
std::map< std::string, Button * > button_lookup_
 
std::map< std::string, ModulationButton * > modulation_buttons_
 
std::map< std::string, SynthSlider * > all_sliders_
 
std::map< std::string, ToggleButton * > all_buttons_
 
std::map< std::string, ModulationButton * > all_modulation_buttons_
 
const SynthSectionparent_
 
SynthButtonactivator_
 
PresetSelectorpreset_selector_
 
bool preset_selector_half_width_
 
std::unique_ptr< OffOverlayoff_overlay_
 
Skin::SectionOverride skin_override_
 
float size_ratio_
 
bool active_
 
bool sideways_heading_
 

Detailed Description

A graphical user interface component representing a filter section in the synthesizer.

The FilterSection displays and manages a variety of filter parameters, including filter models, styles, cutoff, resonance, and other filter-related controls. It can show different filter types (analog, ladder, digital, formant, comb, etc.) and dynamically adapts its UI to the selected filter model and style.

This class also manages input routing controls (oscillator inputs, sample input, serial filtering input) when necessary, and integrates with the preset selector for choosing different filter models and styles.

Constructor & Destructor Documentation

◆ FilterSection() [1/2]

FilterSection::FilterSection ( String suffix,
const vital::output_map & mono_modulations )

Constructs a FilterSection with a given suffix for parameter naming, using only mono modulations.

Parameters
suffixA suffix string used to identify unique parameter names for this filter.
mono_modulationsA map of mono modulation outputs from the synthesizer.

◆ FilterSection() [2/2]

FilterSection::FilterSection ( int index,
const vital::output_map & mono_modulations,
const vital::output_map & poly_modulations )

Constructs a FilterSection for a given index, using both mono and poly modulations.

Parameters
indexThe filter index (e.g., for multiple filters in a chain).
mono_modulationsA map of mono modulation outputs from the synthesizer.
poly_modulationsA map of poly modulation outputs from the synthesizer.

◆ ~FilterSection()

FilterSection::~FilterSection ( )

Destructor.

Member Function Documentation

◆ addListener()

void FilterSection::addListener ( Listener * listener)
inline

Adds a listener to be notified of filter section events.

Parameters
listenerA pointer to the listener to add.

◆ buttonClicked()

void FilterSection::buttonClicked ( Button * clicked_button)
overridevirtual

Called when a button is clicked.

Parameters
clicked_buttonThe button that was clicked.

Reimplemented from SynthSection.

◆ clearFilterInput()

void FilterSection::clearFilterInput ( )
inline

Clears the internal filter input toggle state.

◆ getLeftMorphPath()

Path FilterSection::getLeftMorphPath ( )

Returns a path that represents the left morph shape icon based on the current model/style.

Returns
A Path object representing the left morph shape.

◆ getRightMorphPath()

Path FilterSection::getRightMorphPath ( )

Returns a path that represents the right morph shape icon based on the current model/style.

Returns
A Path object representing the right morph shape.

◆ nextClicked()

void FilterSection::nextClicked ( )
overridevirtual

Called when the next button on the preset selector is clicked.

This cycles to the next filter model/style combination.

Implements PresetSelector::Listener.

◆ paintBackground()

void FilterSection::paintBackground ( Graphics & g)
overridevirtual

Paints the background of the filter section.

Parameters
gThe graphics context used for rendering.

Reimplemented from SynthSection.

◆ paintBackgroundShadow()

void FilterSection::paintBackgroundShadow ( Graphics & g)
inlineoverridevirtual

Paints a background shadow for the filter section, if active.

Parameters
gThe graphics context used for rendering.

Reimplemented from SynthSection.

◆ positionLeftRight()

void FilterSection::positionLeftRight ( )

Positions UI elements in a left-right orientation.

Used when the filter section does not specify input routing.

◆ positionTopBottom()

void FilterSection::positionTopBottom ( )

Positions UI elements in a top-bottom orientation.

Used when the filter section is specifying input routing and thus may need a different layout.

◆ prevClicked()

void FilterSection::prevClicked ( )
overridevirtual

Called when the previous button on the preset selector is clicked.

This cycles to the previous filter model/style combination.

Implements PresetSelector::Listener.

◆ resized()

void FilterSection::resized ( )
overridevirtual

Called when the component is resized.

This method updates the layout of all child components (sliders, buttons, etc.) based on the current size.

Reimplemented from SynthSection.

◆ setActive()

void FilterSection::setActive ( bool active)
overridevirtual

Sets the active state of this filter section.

Parameters
activeTrue if the section should be active; false otherwise.

Reimplemented from SynthSection.

◆ setAllValues()

void FilterSection::setAllValues ( vital::control_map & controls)
overridevirtual

Sets all parameter values for this filter section.

Parameters
controlsA map of control values used to update the filter parameters.

Reimplemented from SynthSection.

◆ setFilterResponseSliders()

void FilterSection::setFilterResponseSliders ( )

Connects the filter's sliders to the filter response display.

This method links the various SynthSlider components (cutoff, resonance, etc.) to the FilterResponse so that the filter response graph visually represents the current slider values.

◆ setFilterSelected()

void FilterSection::setFilterSelected ( int menu_id)

Sets the filter model and style based on a given menu ID.

Parameters
menu_idThe ID selected from the popup menu for filters/styles.

◆ setOscillatorInput()

void FilterSection::setOscillatorInput ( int oscillator_index,
bool input )

Sets the oscillator input state for a given oscillator index.

Parameters
oscillator_indexThe index of the oscillator (0, 1, or 2).
inputTrue to enable the oscillator input, false to disable.

◆ setSampleInput()

void FilterSection::setSampleInput ( bool input)

Sets the sample input state.

Parameters
inputTrue to enable the sample input, false to disable.

◆ textMouseDown()

void FilterSection::textMouseDown ( const MouseEvent & e)
overridevirtual

Called when the user interacts with the text component of the preset selector.

Parameters
eThe mouse event information.

Reimplemented from PresetSelector::Listener.

Member Data Documentation

◆ kBlendLabelPaddingY

int FilterSection::kBlendLabelPaddingY = 4
staticconstexpr

Vertical padding used for label placement relative to the blend slider.


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