Vital
Loading...
Searching...
No Matches
synth_section.h
Go to the documentation of this file.
1#pragma once
2
3#include "JuceHeader.h"
4#include "fonts.h"
5#include "paths.h"
8#include "shaders.h"
9#include "skin.h"
10#include "synth_types.h"
11#include "synth_button.h"
12
13#include <functional>
14#include <map>
15#include <set>
16
18class OpenGlComponent;
19class PresetSelector;
20class SynthSlider;
21
29struct PopupItems {
30 int id;
31 std::string name;
32 bool selected;
33 std::vector<PopupItems> items;
34
35 PopupItems() : id(0), selected(false) { }
36 PopupItems(std::string name) : id(0), name(std::move(name)), selected(false) { }
37
38 PopupItems(int id, std::string name, bool selected, std::vector<PopupItems> items) {
39 this->id = id;
40 this->selected = selected;
41 this->name = std::move(name);
42 this->items = std::move(items);
43 }
44
51 void addItem(int sub_id, const std::string& sub_name, bool sub_selected = false) {
52 items.emplace_back(sub_id, sub_name, sub_selected, std::vector<PopupItems>());
53 }
54
59 void addItem(const PopupItems& item) { items.push_back(item); }
60
65 int size() const { return static_cast<int>(items.size()); }
66};
67
75class LoadingWheel : public OpenGlQuad {
76 public:
77 LoadingWheel() : OpenGlQuad(Shaders::kRotaryModulationFragment), tick_(0), complete_(false), complete_ticks_(0) {
78 setAlpha(1.0f);
79 }
80
81 void resized() override {
83
84 Colour color = findColour(Skin::kWidgetAccent1, true);
85 setColor(color);
86 setModColor(color);
87 setAltColor(color);
88 }
89
95 virtual void render(OpenGlWrapper& open_gl, bool animate) override {
96 static constexpr float kRotationMult = 0.05f;
97 static constexpr float kWidthFrequency = 0.025f;
98 static constexpr float kMinRads = 0.6f;
99 static constexpr float kMaxRads = 4.0f;
100 static constexpr float kRadRange = kMaxRads - kMinRads;
101 static constexpr float kCompleteSpeed = 0.15f;
102 static constexpr float kStartRads = -vital::kPi - 0.05f;
103
104 tick_++;
105 setStartPos(-tick_ * kRotationMult);
106
107 float width = (sinf(tick_ * kWidthFrequency) * 0.5f + 0.5f) * kRadRange + kMinRads;
108 if (complete_) {
109 complete_ticks_++;
110 width += kCompleteSpeed * complete_ticks_;
111 }
112
113 setShaderValue(0, kStartRads, 0);
114 setShaderValue(0, kStartRads + width, 1);
115 setShaderValue(0, kStartRads, 2);
116 setShaderValue(0, kStartRads + width, 3);
117
118 OpenGlQuad::render(open_gl, animate);
119 }
120
125 complete_ = true;
126 }
127
128 private:
129 int tick_;
130 bool complete_;
131 int complete_ticks_;
132};
133
141 public:
146 AppLogo(String name) : OpenGlImageComponent(std::move(name)) {
147 logo_letter_ = Paths::vitalV();
148 logo_ring_ = Paths::vitalRing();
149 }
150
155 void paint(Graphics& g) override {
156 const DropShadow shadow(findColour(Skin::kShadow, true), 10.0f, Point<int>(0, 0));
157
158 logo_letter_.applyTransform(logo_letter_.getTransformToScaleToFit(getLocalBounds().toFloat(), true));
159 logo_ring_.applyTransform(logo_ring_.getTransformToScaleToFit(getLocalBounds().toFloat(), true));
160
161 shadow.drawForPath(g, logo_letter_);
162 shadow.drawForPath(g, logo_ring_);
163
164 Colour letter_top_color = findColour(Skin::kWidgetSecondary1, true);
165 Colour letter_bottom_color = findColour(Skin::kWidgetSecondary2, true);
166 Colour ring_top_color = findColour(Skin::kWidgetPrimary1, true);
167 Colour ring_bottom_color = findColour(Skin::kWidgetPrimary2, true);
168 ColourGradient letter_gradient(letter_top_color, 0.0f, 12.0f, letter_bottom_color, 0.0f, 96.0f, false);
169 ColourGradient ring_gradient(ring_top_color, 0.0f, 12.0f, ring_bottom_color, 0.0f, 96.0f, false);
170 g.setGradientFill(letter_gradient);
171 g.fillPath(logo_letter_);
172
173 g.setGradientFill(ring_gradient);
174 g.fillPath(logo_ring_);
175 }
176
177 private:
178 Path logo_letter_;
179 Path logo_ring_;
180
181 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AppLogo)
182};
183
192class SynthSection : public Component, public Slider::Listener,
193 public Button::Listener, public SynthButton::ButtonListener {
194public:
195 // Constants controlling layout and behavior:
196 static constexpr int kDefaultPowerButtonOffset = 0;
197 static constexpr float kPowerButtonPaddingPercent = 0.29f;
198 static constexpr float kTransposeHeightPercent = 0.5f;
199 static constexpr float kTuneHeightPercent = 0.4f;
200 static constexpr float kJointModulationRadiusPercent = 0.1f;
201 static constexpr float kJointModulationExtensionPercent = 0.6666f;
202 static constexpr float kPitchLabelPercent = 0.33f;
203 static constexpr float kJointLabelHeightPercent = 0.4f;
204 static constexpr double kTransposeMouseSensitivity = 0.2;
205 static constexpr float kJointLabelBorderRatioX = 0.05f;
206
207 static constexpr int kDefaultBodyRounding = 4;
208 static constexpr int kDefaultLabelHeight = 10;
209 static constexpr int kDefaultLabelBackgroundHeight = 16;
210 static constexpr int kDefaultLabelBackgroundWidth = 56;
211 static constexpr int kDefaultLabelBackgroundRounding = 4;
212 static constexpr int kDefaultPadding = 2;
213 static constexpr int kDefaultPopupMenuWidth = 150;
214 static constexpr int kDefaultDualPopupMenuWidth = 340;
215 static constexpr int kDefaultStandardKnobSize = 32;
216 static constexpr int kDefaultKnobThickness = 2;
217 static constexpr float kDefaultKnobModulationAmountThickness = 2.0f;
218 static constexpr int kDefaultKnobModulationMeterSize = 43;
219 static constexpr int kDefaultKnobModulationMeterThickness = 4;
220 static constexpr int kDefaultModulationButtonWidth = 64;
221 static constexpr int kDefaultModFontSize = 10;
222 static constexpr int kDefaultKnobSectionHeight = 64;
223 static constexpr int kDefaultSliderWidth = 24;
224 static constexpr int kDefaultTextWidth = 80;
225 static constexpr int kDefaultTextHeight = 24;
226 static constexpr int kDefaultWidgetMargin = 6;
227 static constexpr float kDefaultWidgetFillFade = 0.3f;
228 static constexpr float kDefaultWidgetLineWidth = 4.0f;
229 static constexpr float kDefaultWidgetFillCenter = 0.0f;
230
235 class OffOverlay : public OpenGlQuad {
236 public:
237 OffOverlay() : OpenGlQuad(Shaders::kColorFragment) { }
238
239 void paintBackground(Graphics& g) override { }
240 };
241
246 SynthSection(const String& name);
247 virtual ~SynthSection() = default;
248
253 void setParent(const SynthSection* parent) { parent_ = parent; }
254
260 float findValue(Skin::ValueId value_id) const;
261
265 virtual void reset();
266
270 virtual void resized() override;
271
276 virtual void paint(Graphics& g) override;
277
282 virtual void paintSidewaysHeadingText(Graphics& g);
283
288 virtual void paintHeadingText(Graphics& g);
289
294 virtual void paintBackground(Graphics& g);
295
301 virtual void setSkinValues(const Skin& skin, bool top_level);
302
303 void setSkinOverride(Skin::SectionOverride skin_override) { skin_override_ = skin_override; }
304
308 virtual void repaintBackground();
309
319 void showPopupBrowser(SynthSection* owner, Rectangle<int> bounds, std::vector<File> directories,
320 String extensions, std::string passthrough_name, std::string additional_folders_name);
321
326 void updatePopupBrowser(SynthSection* owner);
327
336 void showPopupSelector(Component* source, Point<int> position, const PopupItems& options,
337 std::function<void(int)> callback, std::function<void()> cancel = { });
338
347 void showDualPopupSelector(Component* source, Point<int> position, int width,
348 const PopupItems& options, std::function<void(int)> callback);
349
357 void showPopupDisplay(Component* source, const std::string& text,
358 BubbleComponent::BubblePlacement placement, bool primary);
359
364 void hidePopupDisplay(bool primary);
365
370 virtual void loadFile(const File& file) { }
371
376 virtual File getCurrentFile() { return File(); }
377
382 virtual std::string getFileName() { return ""; }
383
388 virtual std::string getFileAuthor() { return ""; }
389
394 virtual void paintContainer(Graphics& g);
395
401 virtual void paintBody(Graphics& g, Rectangle<int> bounds);
402
408 virtual void paintBorder(Graphics& g, Rectangle<int> bounds);
409
414 virtual void paintBody(Graphics& g);
415
420 virtual void paintBorder(Graphics& g);
421
427
432 virtual void paintTabShadow(Graphics& g);
433
439 void paintTabShadow(Graphics& g, Rectangle<int> bounds);
440
445 virtual void paintBackgroundShadow(Graphics& g) { }
446
451 virtual void setSizeRatio(float ratio);
452
457 void paintKnobShadows(Graphics& g);
458
463 Font getLabelFont();
464
469 void setLabelFont(Graphics& g);
470
477 void drawLabelConnectionForComponents(Graphics& g, Component* left, Component* right);
478
485 void drawLabelBackground(Graphics& g, Rectangle<int> bounds, bool text_component = false);
486
492 void drawLabelBackgroundForComponent(Graphics& g, Component* component);
493
502 Rectangle<int> getDividedAreaBuffered(Rectangle<int> full_area, int num_sections, int section, int buffer);
503
512 Rectangle<int> getDividedAreaUnbuffered(Rectangle<int> full_area, int num_sections, int section, int buffer);
513
520 Rectangle<int> getLabelBackgroundBounds(Rectangle<int> bounds, bool text_component = false);
521
528 Rectangle<int> getLabelBackgroundBounds(Component* component, bool text_component = false) {
529 return getLabelBackgroundBounds(component->getBounds(), text_component);
530 }
531
539 void drawLabel(Graphics& g, String text, Rectangle<int> component_bounds, bool text_component = false);
540
548 void drawLabelForComponent(Graphics& g, String text, Component* component, bool text_component = false) {
549 drawLabel(g, std::move(text), component->getBounds(), text_component);
550 }
551
560 void drawTextBelowComponent(Graphics& g, String text, Component* component, int space, int padding = 0);
561
566 virtual void paintChildrenShadows(Graphics& g);
567
572 void paintChildrenBackgrounds(Graphics& g);
573
578 void paintOpenGlChildrenBackgrounds(Graphics& g);
579
585 void paintChildBackground(Graphics& g, SynthSection* child);
586
592 void paintChildShadow(Graphics& g, SynthSection* child);
593
599 void paintOpenGlBackground(Graphics& g, OpenGlComponent* child);
600
607 void drawTextComponentBackground(Graphics& g, Rectangle<int> bounds, bool extend_to_label);
608
614 void drawTempoDivider(Graphics& g, Component* sync);
615
620 virtual void initOpenGlComponents(OpenGlWrapper& open_gl);
621
627 virtual void renderOpenGlComponents(OpenGlWrapper& open_gl, bool animate);
628
633 virtual void destroyOpenGlComponents(OpenGlWrapper& open_gl);
634
639 virtual void sliderValueChanged(Slider* moved_slider) override;
640
645 virtual void buttonClicked(Button* clicked_button) override;
646
651 virtual void guiChanged(SynthButton* button) override;
652
657 std::map<std::string, SynthSlider*> getAllSliders() { return all_sliders_; }
658
663 std::map<std::string, ToggleButton*> getAllButtons() { return all_buttons_; }
664
669 std::map<std::string, ModulationButton*> getAllModulationButtons() {
671 }
672
677 virtual void setActive(bool active);
678
683 bool isActive() const { return active_; }
684
689 virtual void animate(bool animate);
690
695 virtual void setAllValues(vital::control_map& controls);
696
703 virtual void setValue(const std::string& name, vital::mono_float value, NotificationType notification);
704
710 void addModulationButton(ModulationButton* button, bool show = true);
711
717 void addSubSection(SynthSection* section, bool show = true);
718
723 void removeSubSection(SynthSection* section);
724
729 virtual void setScrollWheelEnabled(bool enabled);
730
735 ToggleButton* activator() const { return activator_; }
736
741 void setSkinValues(std::map<Skin::ValueId, float> values) { value_lookup_ = std::move(values); }
742
748 void setSkinValue(Skin::ValueId id, float value) { value_lookup_[id] = value; }
749
750 float getTitleWidth();
751 float getPadding();
753 float getKnobSectionHeight();
754 float getSliderWidth();
755 float getSliderOverlap();
758 float getStandardKnobSize();
760 float getTextSectionYOffset();
761 float getModButtonWidth();
762 float getModFontSize();
763 float getWidgetMargin();
764 float getWidgetRounding();
765 float getSizeRatio() const { return size_ratio_; }
768
769 protected:
771 void setSidewaysHeading(bool sideways) { sideways_heading_ = sideways; }
772 void addToggleButton(ToggleButton* button, bool show);
773 void addButton(OpenGlToggleButton* button, bool show = true);
774 void addButton(OpenGlShapeButton* button, bool show = true);
775 void addSlider(SynthSlider* slider, bool show = true, bool listen = true);
776 void addOpenGlComponent(OpenGlComponent* open_gl_component, bool to_beginning = false);
778 void createOffOverlay();
779 void setPresetSelector(PresetSelector* preset_selector, bool half = false) {
780 preset_selector_ = preset_selector;
782 }
783 void paintJointControlSliderBackground(Graphics& g, int x, int y, int width, int height);
784 void paintJointControlBackground(Graphics& g, int x, int y, int width, int height);
785 void paintJointControl(Graphics& g, int x, int y, int width, int height, const std::string& name);
786 void placeJointControls(int x, int y, int width, int height,
787 SynthSlider* left, SynthSlider* right, Component* widget = nullptr);
788 void placeTempoControls(int x, int y, int width, int height, SynthSlider* tempo, SynthSlider* sync);
789 void placeRotaryOption(Component* option, SynthSlider* rotary);
790 void placeKnobsInArea(Rectangle<int> area, std::vector<Component*> knobs);
791
792 void lockCriticalSection();
794 Rectangle<int> getPresetBrowserBounds();
795 int getTitleTextRight();
796 Rectangle<int> getPowerButtonBounds();
797 Rectangle<int> getTitleBounds();
798 float getDisplayScale() const;
799 virtual int getPixelMultiple() const;
800
801 std::map<Skin::ValueId, float> value_lookup_;
802
803 std::vector<SynthSection*> sub_sections_;
804 std::vector<OpenGlComponent*> open_gl_components_;
805
806 std::map<std::string, SynthSlider*> slider_lookup_;
807 std::map<std::string, Button*> button_lookup_;
808 std::map<std::string, ModulationButton*> modulation_buttons_;
809
810 std::map<std::string, SynthSlider*> all_sliders_;
811 std::map<std::string, ToggleButton*> all_buttons_;
812 std::map<std::string, ModulationButton*> all_modulation_buttons_;
813
818 std::unique_ptr<OffOverlay> off_overlay_;
819
824
825 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SynthSection)
826
827};
Displays the application's logo using paths and gradients.
Definition synth_section.h:140
void paint(Graphics &g) override
Paints the logo's letter and ring with gradients and shadows.
Definition synth_section.h:155
AppLogo(String name)
Constructs an AppLogo with a given name.
Definition synth_section.h:146
An OpenGlQuad subclass that displays a rotating "loading" animation.
Definition synth_section.h:75
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the loading animation, updating the arc width and position over time.
Definition synth_section.h:95
void completeRing()
Transitions the loading wheel to the "complete" state where it fully expands the arc.
Definition synth_section.h:124
void resized() override
Called when the component is resized.
Definition synth_section.h:81
LoadingWheel()
Definition synth_section.h:77
A component representing a modulation source or connection button.
Definition modulation_button.h:21
A base component class that integrates JUCE's Component with OpenGL rendering.
Definition open_gl_component.h:20
virtual void render(OpenGlWrapper &open_gl, bool animate)=0
Pure virtual function to render the component using OpenGL.
virtual void resized() override
Called when the component is resized.
Definition open_gl_component.cpp:121
A component that uses OpenGL to render a cached image of a JUCE component or custom drawing.
Definition open_gl_image_component.h:18
void setShaderValue(int i, float shader_value, int value_index=0)
Sets a shader value for all four vertices of a quad.
Definition open_gl_multi_quad.h:254
force_inline void setAltColor(Colour color)
Sets an alternate color, often used by custom shaders.
Definition open_gl_multi_quad.h:118
force_inline void setColor(Colour color)
Sets the base color for the quads.
Definition open_gl_multi_quad.h:102
force_inline void setStartPos(float pos)
Sets a starting position used by some shaders (e.g., arc start).
Definition open_gl_multi_quad.h:150
force_inline void setModColor(Colour color)
Sets a modulation color for custom effects in the shader.
Definition open_gl_multi_quad.h:126
void setAlpha(float alpha, bool reset=false)
Sets the alpha blending multiplier, can reset to this alpha.
Definition open_gl_multi_quad.h:382
A convenience class for a single quad rendered via OpenGL.
Definition open_gl_multi_quad.h:447
A ToggleButton that uses an OpenGlShapeButtonComponent for its rendering.
Definition synth_button.h:110
A ToggleButton that uses an OpenGlButtonComponent for its rendering.
Definition synth_button.h:342
static Path vitalV()
Creates the Vital 'V' logo path.
Definition paths.h:50
static Path vitalRing()
Creates the Vital ring logo path.
Definition paths.h:39
A UI component for selecting presets within the synthesizer.
Definition preset_selector.h:14
Manages and provides access to vertex and fragment shaders used by the OpenGL rendering pipeline.
Definition shaders.h:19
Manages the overall color and value theme (or "skin") of the user interface.
Definition skin.h:24
ValueId
Identifiers for various UI scaling/spacing values and configuration constants.
Definition skin.h:70
@ kWidgetAccent1
Definition skin.h:171
@ kWidgetPrimary2
Definition skin.h:166
@ kWidgetPrimary1
Definition skin.h:165
@ kWidgetSecondary1
Definition skin.h:168
@ kShadow
Definition skin.h:142
@ kWidgetSecondary2
Definition skin.h:169
SectionOverride
Identifiers for different UI sections that can have color or value overrides.
Definition skin.h:30
Interface for objects interested in changes to SynthButton state.
Definition synth_button.h:461
A specialized OpenGlToggleButton with additional functionality for the Vital synth.
Definition synth_button.h:450
A semi-transparent overlay shown when the section is inactive.
Definition synth_section.h:235
void paintBackground(Graphics &g) override
Paints a standard background for the component.
Definition synth_section.h:239
OffOverlay()
Definition synth_section.h:237
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
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.
Definition synth_section.cpp:776
std::map< std::string, ModulationButton * > modulation_buttons_
Definition synth_section.h:808
void drawTextComponentBackground(Graphics &g, Rectangle< int > bounds, bool extend_to_label)
Draws a background for a text component area.
Definition synth_section.cpp:319
static constexpr int kDefaultStandardKnobSize
Definition synth_section.h:215
virtual void guiChanged(SynthButton *button) override
Called when a SynthButton state changes (GUI interaction).
Definition synth_section.cpp:405
bool sideways_heading_
Definition synth_section.h:823
float getModFontSize()
Definition synth_section.cpp:672
virtual void buttonClicked(Button *clicked_button) override
Called when a button is clicked. Updates the synth parameter accordingly.
Definition synth_section.cpp:398
static constexpr float kDefaultWidgetFillFade
Definition synth_section.h:227
virtual void renderOpenGlComponents(OpenGlWrapper &open_gl, bool animate)
Renders all OpenGL components in this section and sub-sections.
Definition synth_section.cpp:357
float getPadding()
Definition synth_section.cpp:660
std::vector< OpenGlComponent * > open_gl_components_
Definition synth_section.h:804
static constexpr float kDefaultWidgetFillCenter
Definition synth_section.h:229
void drawLabelConnectionForComponents(Graphics &g, Component *left, Component *right)
Draws a rectangular connection between labels of two components.
Definition synth_section.cpp:745
void drawLabelBackground(Graphics &g, Rectangle< int > bounds, bool text_component=false)
Draws a background for a label area.
Definition synth_section.cpp:755
static constexpr float kJointModulationRadiusPercent
Definition synth_section.h:200
float getSliderWidth()
Definition synth_section.cpp:637
virtual ~SynthSection()=default
void placeKnobsInArea(Rectangle< int > area, std::vector< Component * > knobs)
Definition synth_section.cpp:601
virtual void paintBackgroundShadow(Graphics &g)
Stub for painting background shadows. Overridden by subclasses if needed.
Definition synth_section.h:445
void addSlider(SynthSlider *slider, bool show=true, bool listen=true)
Definition synth_section.cpp:445
PresetSelector * preset_selector_
Definition synth_section.h:816
void paintJointControl(Graphics &g, int x, int y, int width, int height, const std::string &name)
Definition synth_section.cpp:564
void createOffOverlay()
Definition synth_section.cpp:514
float getModButtonWidth()
Definition synth_section.cpp:668
virtual void animate(bool animate)
Triggers animation state change in sub-sections if needed.
Definition synth_section.cpp:822
void addSubSection(SynthSection *section, bool show=true)
Adds a subsection (another SynthSection) as a child.
Definition synth_section.cpp:457
void paintOpenGlChildrenBackgrounds(Graphics &g)
Paints the backgrounds for all OpenGL child components.
Definition synth_section.cpp:267
static constexpr int kDefaultKnobModulationMeterThickness
Definition synth_section.h:219
int getDualPopupWidth() const
Definition synth_section.h:767
void paintJointControlSliderBackground(Graphics &g, int x, int y, int width, int height)
Definition synth_section.cpp:525
float getTotalKnobHeight()
Definition synth_section.h:759
virtual std::string getFileName()
Gets the name of the currently loaded file. Overridden by subclasses.
Definition synth_section.h:382
void addToggleButton(ToggleButton *button, bool show)
Definition synth_section.cpp:420
void drawLabel(Graphics &g, String text, Rectangle< int > component_bounds, bool text_component=false)
Draws a label text below a component.
Definition synth_section.cpp:789
bool active_
Definition synth_section.h:822
virtual void setSkinValues(const Skin &skin, bool top_level)
Sets skin values (colors, sizes) and applies them to sub-sections.
Definition synth_section.cpp:86
static constexpr int kDefaultLabelBackgroundWidth
Definition synth_section.h:210
void drawTempoDivider(Graphics &g, Component *sync)
Draws a divider line for tempo-related controls.
Definition synth_section.cpp:339
void drawTextBelowComponent(Graphics &g, String text, Component *component, int space, int padding=0)
Draws text below a component with optional padding.
Definition synth_section.cpp:800
static constexpr int kDefaultKnobSectionHeight
Definition synth_section.h:222
void setSidewaysHeading(bool sideways)
Definition synth_section.h:771
void hidePopupDisplay(bool primary)
Hides the currently shown popup display.
Definition synth_section.cpp:140
int getComponentShadowWidth()
Gets the width of shadow around components.
Definition synth_section.cpp:184
static constexpr float kTuneHeightPercent
Definition synth_section.h:199
virtual File getCurrentFile()
Gets the currently loaded file. Overridden by subclasses.
Definition synth_section.h:376
static constexpr float kJointLabelHeightPercent
Definition synth_section.h:203
static constexpr float kJointModulationExtensionPercent
Definition synth_section.h:201
virtual void paint(Graphics &g) override
Called when the component should paint itself.
Definition synth_section.cpp:49
virtual void resized() override
Called when the component is resized. Arranges layout of child components.
Definition synth_section.cpp:35
void placeTempoControls(int x, int y, int width, int height, SynthSlider *tempo, SynthSlider *sync)
Definition synth_section.cpp:584
ToggleButton * activator() const
Gets the activator toggle button if any.
Definition synth_section.h:735
std::map< std::string, Button * > button_lookup_
Definition synth_section.h:807
virtual void paintBody(Graphics &g, Rectangle< int > bounds)
Paints the body background within given bounds.
Definition synth_section.cpp:165
std::map< std::string, ModulationButton * > getAllModulationButtons()
Gets all modulation buttons registered in this section.
Definition synth_section.h:669
std::vector< SynthSection * > sub_sections_
Definition synth_section.h:803
Rectangle< int > getTitleBounds()
Definition synth_section.cpp:709
float getWidgetRounding()
Definition synth_section.cpp:680
static constexpr double kTransposeMouseSensitivity
Definition synth_section.h:204
void paintChildBackground(Graphics &g, SynthSection *child)
Paints a child's background specifically.
Definition synth_section.cpp:292
void paintChildrenBackgrounds(Graphics &g)
Paints the backgrounds for all child sections.
Definition synth_section.cpp:274
static constexpr float kDefaultWidgetLineWidth
Definition synth_section.h:228
void updatePopupBrowser(SynthSection *owner)
Updates the currently visible popup browser if any.
Definition synth_section.cpp:113
virtual void paintChildrenShadows(Graphics &g)
Paints shadows for child sections.
Definition synth_section.cpp:260
void paintKnobShadows(Graphics &g)
Paints knob shadows for all sliders.
Definition synth_section.cpp:253
Font getLabelFont()
Gets a suitable font for label text.
Definition synth_section.cpp:735
virtual void setActive(bool active)
Sets the active state of this section and sub-sections.
Definition synth_section.cpp:806
Rectangle< int > getLabelBackgroundBounds(Component *component, bool text_component=false)
Gets the label background bounds for a component.
Definition synth_section.h:528
static constexpr int kDefaultKnobThickness
Definition synth_section.h:216
static constexpr int kDefaultModulationButtonWidth
Definition synth_section.h:220
static constexpr int kDefaultLabelBackgroundRounding
Definition synth_section.h:211
virtual int getPixelMultiple() const
Definition synth_section.cpp:729
void drawLabelForComponent(Graphics &g, String text, Component *component, bool text_component=false)
Draws a label for a given component.
Definition synth_section.h:548
void drawLabelBackgroundForComponent(Graphics &g, Component *component)
Draws label background for a specific component.
Definition synth_section.cpp:764
static constexpr float kPowerButtonPaddingPercent
Definition synth_section.h:197
static constexpr float kJointLabelBorderRatioX
Definition synth_section.h:205
void addModulationButton(ModulationButton *button, bool show=true)
Adds a modulation button to this section.
Definition synth_section.cpp:438
void setLabelFont(Graphics &g)
Sets the Graphics context font and color for labels.
Definition synth_section.cpp:740
static constexpr float kDefaultKnobModulationAmountThickness
Definition synth_section.h:217
virtual void destroyOpenGlComponents(OpenGlWrapper &open_gl)
Destroys all OpenGL components in this section and sub-sections.
Definition synth_section.cpp:383
static constexpr int kDefaultPopupMenuWidth
Definition synth_section.h:213
float getSliderOverlap()
Definition synth_section.cpp:641
virtual void setSizeRatio(float ratio)
Sets the size ratio for scaling UI elements.
Definition synth_section.cpp:246
virtual void paintSidewaysHeadingText(Graphics &g)
Paints the section name heading text vertically if sideways_heading_ is true.
Definition synth_section.cpp:51
virtual void paintHeadingText(Graphics &g)
Paints the heading text for this section, either sideways or horizontally.
Definition synth_section.cpp:66
virtual std::string getFileAuthor()
Gets the author metadata of the currently loaded file. Overridden by subclasses.
Definition synth_section.h:388
void unlockCriticalSection()
Definition synth_section.cpp:623
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.
Definition synth_section.cpp:119
float size_ratio_
Definition synth_section.h:821
void addButton(OpenGlToggleButton *button, bool show=true)
Definition synth_section.cpp:428
Rectangle< int > getLabelBackgroundBounds(Rectangle< int > bounds, bool text_component=false)
Gets the background bounds for a label.
Definition synth_section.cpp:782
static constexpr int kDefaultBodyRounding
Definition synth_section.h:207
SynthButton * activator_
Definition synth_section.h:815
int getPopupWidth() const
Definition synth_section.h:766
static constexpr float kPitchLabelPercent
Definition synth_section.h:202
std::map< Skin::ValueId, float > value_lookup_
Definition synth_section.h:801
float findValue(Skin::ValueId value_id) const
Finds a value in the skin overrides or from the parent if not found locally.
Definition synth_section.cpp:18
virtual void paintBorder(Graphics &g, Rectangle< int > bounds)
Paints the border around given bounds.
Definition synth_section.cpp:170
Skin::SectionOverride skin_override_
Definition synth_section.h:820
virtual void loadFile(const File &file)
Loads a file (e.g., a sample or wavetable). Overridden by subclasses.
Definition synth_section.h:370
int getTitleTextRight()
Definition synth_section.cpp:695
bool isActive() const
Checks if the section is currently active.
Definition synth_section.h:683
static constexpr int kDefaultTextWidth
Definition synth_section.h:224
static constexpr int kDefaultDualPopupMenuWidth
Definition synth_section.h:214
virtual void paintBackground(Graphics &g)
Paints the background of the section. Calls paintContainer, heading, knobs, children.
Definition synth_section.cpp:77
float getKnobSectionHeight()
Definition synth_section.cpp:633
void setActivator(SynthButton *activator)
Definition synth_section.cpp:504
SynthSection(const String &name)
Constructs a SynthSection with a given name.
Definition synth_section.cpp:11
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.
Definition synth_section.cpp:126
void paintChildShadow(Graphics &g, SynthSection *child)
Paints a child's shadow specifically.
Definition synth_section.cpp:301
static constexpr int kDefaultSliderWidth
Definition synth_section.h:223
float getStandardKnobSize()
Definition synth_section.cpp:656
static constexpr int kDefaultKnobModulationMeterSize
Definition synth_section.h:218
std::map< std::string, SynthSlider * > getAllSliders()
Gets all sliders registered in this section.
Definition synth_section.h:657
static constexpr int kDefaultTextHeight
Definition synth_section.h:225
static constexpr int kDefaultPowerButtonOffset
Definition synth_section.h:196
Rectangle< int > getPowerButtonBounds()
Definition synth_section.cpp:704
std::map< std::string, SynthSlider * > slider_lookup_
Definition synth_section.h:806
void addOpenGlComponent(OpenGlComponent *open_gl_component, bool to_beginning=false)
Definition synth_section.cpp:489
float getSizeRatio() const
Definition synth_section.h:765
std::map< std::string, ToggleButton * > all_buttons_
Definition synth_section.h:811
void paintJointControlBackground(Graphics &g, int x, int y, int width, int height)
Definition synth_section.cpp:542
std::map< std::string, ToggleButton * > getAllButtons()
Gets all toggle buttons registered in this section.
Definition synth_section.h:663
bool preset_selector_half_width_
Definition synth_section.h:817
virtual void sliderValueChanged(Slider *moved_slider) override
Called when a slider value changes. Updates the synth parameter accordingly.
Definition synth_section.cpp:391
float getTextComponentHeight()
Definition synth_section.cpp:652
virtual void setAllValues(vital::control_map &controls)
Sets values for all known parameters from a control map.
Definition synth_section.cpp:827
void placeRotaryOption(Component *option, SynthSlider *rotary)
Definition synth_section.cpp:593
void setSkinValues(std::map< Skin::ValueId, float > values)
Sets custom skin values for this section.
Definition synth_section.h:741
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.
Definition synth_section.cpp:768
virtual void reset()
Resets the section and all sub-sections.
Definition synth_section.cpp:30
void showPopupDisplay(Component *source, const std::string &text, BubbleComponent::BubblePlacement placement, bool primary)
Shows a brief popup display (like a tooltip).
Definition synth_section.cpp:133
static constexpr float kTransposeHeightPercent
Definition synth_section.h:198
void lockCriticalSection()
Definition synth_section.cpp:617
const SynthSection * parent_
Definition synth_section.h:814
float getTextSectionYOffset()
Definition synth_section.cpp:664
virtual void setValue(const std::string &name, vital::mono_float value, NotificationType notification)
Sets a single parameter value for a known control.
Definition synth_section.cpp:846
static constexpr int kDefaultLabelHeight
Definition synth_section.h:208
float getSliderOverlapWithSpace()
Definition synth_section.cpp:648
void setSliderHasHzAlternateDisplay(SynthSlider *slider)
Definition synth_section.cpp:410
void setPresetSelector(PresetSelector *preset_selector, bool half=false)
Definition synth_section.h:779
float getTitleWidth()
Definition synth_section.cpp:629
static constexpr int kDefaultPadding
Definition synth_section.h:212
virtual void setScrollWheelEnabled(bool enabled)
Enables or disables scroll wheel support for this section and sub-sections.
Definition synth_section.cpp:481
static constexpr int kDefaultModFontSize
Definition synth_section.h:221
void setSkinOverride(Skin::SectionOverride skin_override)
Definition synth_section.h:303
void setSkinValue(Skin::ValueId id, float value)
Sets a single skin value override.
Definition synth_section.h:748
static constexpr int kDefaultWidgetMargin
Definition synth_section.h:226
void setParent(const SynthSection *parent)
Sets the parent SynthSection.
Definition synth_section.h:253
std::map< std::string, ModulationButton * > all_modulation_buttons_
Definition synth_section.h:812
virtual void initOpenGlComponents(OpenGlWrapper &open_gl)
Initializes all OpenGL components in this section and sub-sections.
Definition synth_section.cpp:349
void removeSubSection(SynthSection *section)
Removes a previously added subsection.
Definition synth_section.cpp:475
float getDisplayScale() const
Definition synth_section.cpp:719
virtual void paintTabShadow(Graphics &g)
Paints a tab-like shadow effect around the component.
Definition synth_section.cpp:188
virtual void repaintBackground()
Requests a repaint of the background.
Definition synth_section.cpp:96
Rectangle< int > getPresetBrowserBounds()
Definition synth_section.cpp:684
void placeJointControls(int x, int y, int width, int height, SynthSlider *left, SynthSlider *right, Component *widget=nullptr)
Definition synth_section.cpp:572
float getPowerButtonOffset() const
Definition synth_section.h:752
virtual void paintContainer(Graphics &g)
Paints the container background, body, heading, etc.
Definition synth_section.cpp:146
void paintOpenGlBackground(Graphics &g, OpenGlComponent *child)
Paints the background of an OpenGlComponent child.
Definition synth_section.cpp:310
std::unique_ptr< OffOverlay > off_overlay_
Definition synth_section.h:818
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).
Definition synth_section.cpp:105
static constexpr int kDefaultLabelBackgroundHeight
Definition synth_section.h:209
std::map< std::string, SynthSlider * > all_sliders_
Definition synth_section.h:810
float getWidgetMargin()
Definition synth_section.cpp:676
A specialized slider with extended functionality for modulation, parameter control,...
Definition synth_slider.h:314
constexpr mono_float kPi
Pi constant.
Definition common.h:36
std::map< std::string, Value * > control_map
Maps parameter names to Value pointers representing synth control parameters.
Definition synth_types.h:214
float mono_float
Definition common.h:33
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174
A hierarchical structure of popup menu items for a selector component.
Definition synth_section.h:29
std::vector< PopupItems > items
Nested items for submenus or hierarchical choices.
Definition synth_section.h:33
void addItem(int sub_id, const std::string &sub_name, bool sub_selected=false)
Adds a new item as a submenu entry.
Definition synth_section.h:51
std::string name
The display name of this item.
Definition synth_section.h:31
int id
The numeric ID of this item.
Definition synth_section.h:30
PopupItems()
Definition synth_section.h:35
int size() const
Returns the number of nested items.
Definition synth_section.h:65
void addItem(const PopupItems &item)
Adds an existing PopupItems object as a submenu entry.
Definition synth_section.h:59
PopupItems(std::string name)
Definition synth_section.h:36
bool selected
Whether this item is currently selected.
Definition synth_section.h:32
PopupItems(int id, std::string name, bool selected, std::vector< PopupItems > items)
Definition synth_section.h:38
Declares classes for OpenGL-based buttons used in the Vital synth UI.