Vital
|
A user interface section that displays and controls an LFO (Low Frequency Oscillator) in the synthesizer. More...
#include <lfo_section.h>
Public Types | |
enum | PaintPattern { kStep , kHalf , kDown , kUp , kTri , kNumPaintPatterns } |
Enumerates the paint patterns used for LFO shape painting. More... | |
Public Member Functions | |
LfoSection (String name, std::string value_prepend, LineGenerator *lfo_source, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations) | |
Constructs a new LfoSection. | |
~LfoSection () | |
Destructor. | |
void | paintBackground (Graphics &g) override |
Paints the background of the LFO section. | |
void | resized () override |
Called when the component is resized. | |
void | reset () override |
Resets all LFO settings to their default states. | |
void | setAllValues (vital::control_map &controls) override |
Updates all control values in this section from the given map of controls. | |
void | sliderValueChanged (Slider *changed_slider) override |
Responds to a slider value change event. | |
void | buttonClicked (Button *clicked_button) override |
Responds to a button click event. | |
void | setPhase (float phase) override |
Sets the LFO phase. | |
void | lineEditorScrolled (const MouseEvent &e, const MouseWheelDetails &wheel) override |
Responds to scrolling events in the line editor component. | |
void | togglePaintMode (bool enabled, bool temporary_switch) override |
Toggles paint mode for the LFO editor. | |
void | importLfo () override |
Imports an LFO from a user-selected file. | |
void | exportLfo () override |
Exports the current LFO configuration to a user-selected file. | |
void | fileLoaded () override |
Called when an LFO file has been successfully loaded. | |
void | loadFile (const File &file) override |
Loads the LFO configuration from the specified file. | |
File | getCurrentFile () override |
Retrieves the current LFO file. | |
void | prevClicked () override |
Loads the previous LFO preset. | |
void | nextClicked () override |
Loads the next LFO preset. | |
void | textMouseDown (const MouseEvent &e) override |
Handles mouse-down events on the text component, usually to open a file browser. | |
void | setSmoothModeSelected (int result) |
Sets the selected smooth mode. | |
![]() | |
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 | 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 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 | paintBackgroundShadow (Graphics &g) |
Stub for painting background shadows. Overridden by subclasses if needed. | |
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 | 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. | |
virtual void | setActive (bool active) |
Sets the active state of this section and sub-sections. | |
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 |
![]() | |
virtual | ~ButtonListener () |
Virtual destructor. | |
![]() | |
virtual | ~Listener () |
Virtual destructor for proper cleanup. | |
virtual void | textMouseUp (const MouseEvent &e) |
![]() | |
virtual | ~Listener () |
virtual void | pointChanged (int index, Point< float > position, bool mouse_up) |
Called when a point's position changes. | |
virtual void | powersChanged (bool mouse_up) |
Called when the curve powers have changed. | |
virtual void | pointAdded (int index, Point< float > position) |
Called when a point is added to the curve. | |
virtual void | pointRemoved (int index) |
Called when a point is removed from the curve. | |
virtual void | pointsAdded (int index, int num_points_added) |
Called when multiple points are added at once. | |
virtual void | pointsRemoved (int index, int num_points_removed) |
Called when multiple points are removed at once. | |
Static Public Member Functions | |
static std::vector< std::pair< float, float > > | getPaintPattern (int pattern) |
Retrieves a paint pattern as a vector of (x, y) pairs. | |
Additional Inherited Members | |
![]() | |
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 |
![]() | |
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 |
![]() | |
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 SynthSection * | parent_ |
SynthButton * | activator_ |
PresetSelector * | preset_selector_ |
bool | preset_selector_half_width_ |
std::unique_ptr< OffOverlay > | off_overlay_ |
Skin::SectionOverride | skin_override_ |
float | size_ratio_ |
bool | active_ |
bool | sideways_heading_ |
A user interface section that displays and controls an LFO (Low Frequency Oscillator) in the synthesizer.
The LfoSection provides controls for editing LFO shapes, timing, smoothing, paint patterns, and preset management. It integrates an LfoEditor for graphical editing and supports loading and saving LFO configurations (presets).
In addition to providing UI controls like sliders, text selectors, and toggle buttons, the LfoSection supports painting LFO shapes directly in the editor, synchronizing frequencies with tempo, and browsing through different LFO presets.
It inherits from SynthSection, and implements PresetSelector::Listener and LineEditor::Listener to react to changes in presets and manual line editing.
Enumerates the paint patterns used for LFO shape painting.
LfoSection::LfoSection | ( | String | name, |
std::string | value_prepend, | ||
LineGenerator * | lfo_source, | ||
const vital::output_map & | mono_modulations, | ||
const vital::output_map & | poly_modulations ) |
Constructs a new LfoSection.
Constructs the LfoSection.
name | The display name of the LFO section. |
value_prepend | A prefix for parameter names, used to differentiate parameters of multiple LFOs. |
lfo_source | A pointer to a LineGenerator that provides the LFO data model. |
mono_modulations | A map of available monophonic modulations. |
poly_modulations | A map of available polyphonic modulations. |
Initializes all sliders, buttons, text components, and the LfoEditor. Sets up default values for parameters like grid size, paint patterns, and smoothing modes. Also registers listeners for the editor and preset selector.
|
default |
Destructor.
|
overridevirtual |
Responds to a button click event.
Handles button click events.
clicked_button | A pointer to the clicked button. |
Toggles paint mode, smooth mode, and possibly opens popup selectors for smooth modes. Also calls SynthSection's button handling for other button types.
clicked_button | The button that was clicked. |
Reimplemented from SynthSection.
|
overridevirtual |
Exports the current LFO configuration to a user-selected file.
Opens a file chooser to export the current LFO settings to a file.
Implements LineEditor::Listener.
|
overridevirtual |
Called when an LFO file has been successfully loaded.
Called after an LFO file has been loaded.
Updates UI elements (such as toggling smoothing) based on the newly loaded file.
Implements LineEditor::Listener.
|
inlineoverridevirtual |
Retrieves the current LFO file.
Reimplemented from SynthSection.
|
inlinestatic |
Retrieves a paint pattern as a vector of (x, y) pairs.
pattern | The pattern identifier. |
|
overridevirtual |
Imports an LFO from a user-selected file.
Opens a file chooser to import an LFO preset from the user's filesystem.
Implements LineEditor::Listener.
|
overridevirtual |
Responds to scrolling events in the line editor component.
Called when the line editor is scrolled.
e | The mouse event. |
wheel | The mouse wheel details. |
Allows scrolling through paint patterns or grid sizes depending on whether paint mode is active.
e | The mouse event associated with the scroll. |
wheel | The mouse wheel details (direction, increments). |
Implements LineEditor::Listener.
|
overridevirtual |
Loads the LFO configuration from the specified file.
Loads an LFO configuration from a specified file.
file | The file to load from. |
Parses the JSON data, updates the LfoEditor model, and updates the UI accordingly.
file | The file to load. |
Reimplemented from SynthSection.
|
overridevirtual |
Loads the next LFO preset.
Loads the next LFO preset in the directory sequence.
Implements PresetSelector::Listener.
|
overridevirtual |
Paints the background of the LFO section.
g | The JUCE Graphics context to use for drawing. |
This method draws the UI elements behind the LFO editor and control widgets.
Draws text component backgrounds, dividers, and labels for various parameters. Also invokes child background painting to ensure a consistent UI.
g | The JUCE Graphics context. |
Reimplemented from SynthSection.
|
overridevirtual |
Loads the previous LFO preset.
Loads the previous LFO preset in the directory sequence.
Implements PresetSelector::Listener.
|
overridevirtual |
Resets all LFO settings to their default states.
Resets all LFO parameters and the editor state to their default values.
Reimplemented from SynthSection.
|
overridevirtual |
Called when the component is resized.
Recomputes the layout of all sliders, buttons, and the LfoEditor area.
Repositions all UI elements, including sliders, selectors, and the LfoEditor. Adjusts layout to maintain a usable interface at different sizes.
Reimplemented from SynthSection.
|
overridevirtual |
Updates all control values in this section from the given map of controls.
Sets all LFO-related values from a given map of controls.
controls | A map of parameter names to their current values. |
controls | A reference to the map containing parameter names and values. |
Reimplemented from SynthSection.
|
inlineoverridevirtual |
Sets the LFO phase.
phase | A float representing the new LFO phase. |
Implements LineEditor::Listener.
void LfoSection::setSmoothModeSelected | ( | int | result | ) |
Sets the selected smooth mode.
Sets the selected smooth mode and updates UI accordingly.
result | The selected smooth mode index. |
Shows or hides smoothing and fade sliders depending on the selected mode.
result | The selected smooth mode index. |
|
overridevirtual |
Responds to a slider value change event.
Handles slider value changes.
changed_slider | A pointer to the slider that changed value. |
This includes adjusting grid sizes, switching paint patterns, and passing other parameter changes to SynthSection's handling code.
changed_slider | The slider that changed its value. |
Reimplemented from SynthSection.
|
overridevirtual |
Handles mouse-down events on the text component, usually to open a file browser.
Handles mouse-down events on the text component.
e | The mouse event. |
Typically opens a popup browser to select LFO presets from a file list.
e | The mouse event. |
Reimplemented from PresetSelector::Listener.
|
overridevirtual |
Toggles paint mode for the LFO editor.
Toggles paint mode for editing the LFO shape.
enabled | Whether to enable or disable the paint mode. |
temporary_switch | If true, temporarily switches the mode rather than toggling permanently. |
enabled | True to enable paint mode, false to disable. |
temporary_switch | If true, makes a temporary mode switch rather than toggling permanently. |
Implements LineEditor::Listener.