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

A UI overlay for saving presets or other files. More...

#include <save_section.h>

Inheritance diagram for SaveSection:
Overlay SynthSection SynthButton::ButtonListener

Classes

class  Listener
 Interface for objects interested in the result of the save action. More...
 

Public Member Functions

 SaveSection (String name)
 Constructs a SaveSection with a given name.
 
virtual ~SaveSection ()=default
 
void resized () override
 Called when the component is resized. Updates layout and positions of all elements.
 
void setVisible (bool should_be_visible) override
 Sets the visibility of this overlay. Adjusts layout when becoming visible.
 
void setSaveBounds ()
 Sets the layout and components for the normal save mode (not overwrite).
 
void setOverwriteBounds ()
 Sets the layout and components for the overwrite confirmation mode.
 
void setTextColors (OpenGlTextEditor *editor, String empty_string)
 Configures text editor colors and placeholder text.
 
void textEditorReturnKeyPressed (TextEditor &editor) override
 Called when the return key is pressed in any text editor.
 
void buttonClicked (Button *clicked_button) override
 Called when a button is clicked.
 
void mouseUp (const MouseEvent &e) override
 Called when the mouse is released. Used to close the overlay if clicked outside.
 
void setFileType (const String &type)
 Sets the file type label shown in the dialog.
 
void setFileExtension (const String &extension)
 Sets the file extension to use when saving.
 
void setDirectory (const File &directory)
 Sets the directory where the file will be saved.
 
void setFileData (const json &data)
 Sets the data to be saved (if not saving a preset).
 
void setIsPreset (bool preset)
 Configures the section for saving a preset (true) or another file type.
 
Rectangle< int > getSaveRect ()
 Gets the rectangle bounds of the main save dialog.
 
Rectangle< int > getOverwriteRect ()
 Gets the rectangle bounds of the overwrite confirmation dialog.
 
void addSaveListener (Listener *listener)
 Adds a listener to be notified when saving occurs.
 
- Public Member Functions inherited from Overlay
 Overlay (String name)
 Constructs an Overlay with a given name.
 
virtual ~Overlay ()
 Destructor.
 
void setVisible (bool should_be_visible) override
 Sets the visibility of the overlay and notifies listeners.
 
virtual void paintBackground (Graphics &g) override
 Paints the background using OpenGL-rendered children.
 
void addOverlayListener (Listener *listener)
 Adds a listener to be notified of overlay visibility changes.
 
void removeOverlayListener (Listener *listener)
 Removes a previously added overlay listener.
 
void setSizeRatio (float ratio) override
 Sets the size ratio for the overlay, used in some layouts.
 
- 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 paintBackgroundShadow (Graphics &g)
 Stub for painting background shadows. Overridden by subclasses if needed.
 
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.
 
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 setAllValues (vital::control_map &controls)
 Sets values for all known parameters from a control map.
 
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.
 

Static Public Attributes

static constexpr int kSaveWidth = 630
 Base width of the save dialog.
 
static constexpr int kSavePresetHeight = 450
 Base height of the preset save dialog.
 
static constexpr int kStylePaddingX = 4
 Horizontal padding for style buttons.
 
static constexpr int kStylePaddingY = 4
 Vertical padding for style buttons.
 
static constexpr int kStyleButtonHeight = 24
 Height of each style button.
 
static constexpr int kOverwriteWidth = 340
 Width of overwrite confirmation dialog.
 
static constexpr int kOverwriteHeight = 160
 Height of overwrite confirmation dialog.
 
static constexpr int kTextEditorHeight = 37
 Height of each text editor component.
 
static constexpr int kLabelHeight = 15
 Height of labels.
 
static constexpr int kButtonHeight = 40
 Height of buttons.
 
static constexpr int kAddFolderHeight = 20
 Height for additional spacing.
 
static constexpr int kDivision = 150
 Horizontal division for layout.
 
static constexpr int kPaddingX = 25
 Horizontal padding inside the dialog.
 
static constexpr int kPaddingY = 20
 Vertical padding inside the dialog.
 
static constexpr int kExtraTopPadding = 10
 Extra top padding inside the dialog.
 
- 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 Overlay
float size_ratio_
 A scaling factor for the overlay size.
 
std::set< Listener * > listeners_
 Registered overlay listeners.
 
OverlayBackgroundRenderer background_
 Renders the overlay background.
 
- 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 UI overlay for saving presets or other files.

This class provides a dialog overlay allowing the user to specify a file name, author, style, and comments before saving a preset or other file. It also supports prompting the user when a file already exists (overwrite confirmation).

Constructor & Destructor Documentation

◆ SaveSection()

SaveSection::SaveSection ( String name)

Constructs a SaveSection with a given name.

Parameters
nameThe name of this overlay section.

◆ ~SaveSection()

virtual SaveSection::~SaveSection ( )
virtualdefault

Member Function Documentation

◆ addSaveListener()

void SaveSection::addSaveListener ( Listener * listener)
inline

Adds a listener to be notified when saving occurs.

Parameters
listenerThe listener to add.

◆ buttonClicked()

void SaveSection::buttonClicked ( Button * clicked_button)
overridevirtual

Called when a button is clicked.

Parameters
clicked_buttonThe button that was clicked.

Reimplemented from SynthSection.

◆ getOverwriteRect()

Rectangle< int > SaveSection::getOverwriteRect ( )

Gets the rectangle bounds of the overwrite confirmation dialog.

Returns
The rectangle bounds.

◆ getSaveRect()

Rectangle< int > SaveSection::getSaveRect ( )

Gets the rectangle bounds of the main save dialog.

Returns
The rectangle bounds.

◆ mouseUp()

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

Called when the mouse is released. Used to close the overlay if clicked outside.

Parameters
eThe MouseEvent details.

◆ resized()

void SaveSection::resized ( )
overridevirtual

Called when the component is resized. Updates layout and positions of all elements.

Reimplemented from Overlay.

◆ setDirectory()

void SaveSection::setDirectory ( const File & directory)
inline

Sets the directory where the file will be saved.

Parameters
directoryThe target directory.

◆ setFileData()

void SaveSection::setFileData ( const json & data)
inline

Sets the data to be saved (if not saving a preset).

Parameters
dataA JSON object containing file data.

◆ setFileExtension()

void SaveSection::setFileExtension ( const String & extension)
inline

Sets the file extension to use when saving.

Parameters
extensionThe extension (without dot) for the saved file (e.g., "vital").

◆ setFileType()

void SaveSection::setFileType ( const String & type)
inline

Sets the file type label shown in the dialog.

Parameters
typeThe type of file being saved (e.g., "Preset").

◆ setIsPreset()

void SaveSection::setIsPreset ( bool preset)
inline

Configures the section for saving a preset (true) or another file type.

Parameters
presetTrue if saving a preset, false otherwise.

◆ setOverwriteBounds()

void SaveSection::setOverwriteBounds ( )

Sets the layout and components for the overwrite confirmation mode.

◆ setSaveBounds()

void SaveSection::setSaveBounds ( )

Sets the layout and components for the normal save mode (not overwrite).

◆ setTextColors()

void SaveSection::setTextColors ( OpenGlTextEditor * editor,
String empty_string )

Configures text editor colors and placeholder text.

Parameters
editorPointer to the OpenGlTextEditor to configure.
empty_stringThe placeholder text to show when empty.

◆ setVisible()

void SaveSection::setVisible ( bool should_be_visible)
override

Sets the visibility of this overlay. Adjusts layout when becoming visible.

Parameters
should_be_visibleTrue to show the overlay, false to hide.

◆ textEditorReturnKeyPressed()

void SaveSection::textEditorReturnKeyPressed ( TextEditor & editor)
override

Called when the return key is pressed in any text editor.

Parameters
editorReference to the text editor that triggered the event.

Member Data Documentation

◆ kAddFolderHeight

int SaveSection::kAddFolderHeight = 20
staticconstexpr

Height for additional spacing.

◆ kButtonHeight

int SaveSection::kButtonHeight = 40
staticconstexpr

Height of buttons.

◆ kDivision

int SaveSection::kDivision = 150
staticconstexpr

Horizontal division for layout.

◆ kExtraTopPadding

int SaveSection::kExtraTopPadding = 10
staticconstexpr

Extra top padding inside the dialog.

◆ kLabelHeight

int SaveSection::kLabelHeight = 15
staticconstexpr

Height of labels.

◆ kOverwriteHeight

int SaveSection::kOverwriteHeight = 160
staticconstexpr

Height of overwrite confirmation dialog.

◆ kOverwriteWidth

int SaveSection::kOverwriteWidth = 340
staticconstexpr

Width of overwrite confirmation dialog.

◆ kPaddingX

int SaveSection::kPaddingX = 25
staticconstexpr

Horizontal padding inside the dialog.

◆ kPaddingY

int SaveSection::kPaddingY = 20
staticconstexpr

Vertical padding inside the dialog.

◆ kSavePresetHeight

int SaveSection::kSavePresetHeight = 450
staticconstexpr

Base height of the preset save dialog.

◆ kSaveWidth

int SaveSection::kSaveWidth = 630
staticconstexpr

Base width of the save dialog.

◆ kStyleButtonHeight

int SaveSection::kStyleButtonHeight = 24
staticconstexpr

Height of each style button.

◆ kStylePaddingX

int SaveSection::kStylePaddingX = 4
staticconstexpr

Horizontal padding for style buttons.

◆ kStylePaddingY

int SaveSection::kStylePaddingY = 4
staticconstexpr

Vertical padding for style buttons.

◆ kTextEditorHeight

int SaveSection::kTextEditorHeight = 37
staticconstexpr

Height of each text editor component.


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