24 setInterceptsMouseClicks(
false,
false);
53 void paint(Graphics& g)
override {
55 g.setFont(
Fonts::instance()->proportional_regular().withPointHeight(text_size_));
56 g.drawText(text_, 0, 0, getWidth(), getHeight(), Justification::centred,
false);
85 std::string number = std::to_string(index_ + 1);
86 std::string control_name =
"macro_control_" + number;
88 macro_knob_ = std::make_unique<SynthSlider>(control_name);
90 macro_knob_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
91 macro_knob_->setPopupPlacement(BubbleComponent::right);
93 macro_source_ = std::make_unique<ModulationButton>(control_name);
95 macro_source_->overrideText(
"");
97 macro_label_ = std::make_unique<MacroLabel>(
"Macro Label " + number,
"MACRO " + number);
100 edit_label_ = std::make_unique<OpenGlShapeButton>(
"Edit " + number);
101 addAndMakeVisible(edit_label_.get());
103 edit_label_->addListener(
this);
105 edit_label_->setTriggeredOnMouseDown(
true);
109#if !defined(NO_TEXT_ENTRY)
110 macro_label_editor_ = std::make_unique<OpenGlTextEditor>(
"Search");
111 macro_label_editor_->addListener(
this);
112 macro_label_editor_->setSelectAllWhenFocused(
true);
113 macro_label_editor_->setMultiLine(
false,
false);
114 macro_label_editor_->setJustification(Justification::centred);
115 addChildComponent(macro_label_editor_.get());
126 int knob_height = getHeight() / 2;
127 int button_height = getHeight() - knob_height;
128 int width = getWidth();
130 macro_knob_->setBounds(0, 0, width, knob_height);
133 macro_source_->setBounds(0, knob_height, width, button_height);
134 macro_source_->setFontSize(0);
170 Rectangle<int> bounds = getLocalArea(macro_source_.get(), macro_source_->getLocalBounds());
171 g.reduceClipRegion(bounds);
172 g.setOrigin(bounds.getTopLeft());
173 macro_source_->paintBackground(g);
183 if (macro_label_editor_) {
184 if (macro_label_editor_->isVisible()) {
189 Rectangle<int> bounds = macro_label_->getBounds();
191 macro_label_editor_->setFont(
Fonts::instance()->proportional_regular().withPointHeight(text_height));
192 macro_label_editor_->setText(macro_label_->getText());
193 macro_label_editor_->setBounds(bounds.translated(0, -1));
194 macro_label_editor_->setVisible(
true);
195 macro_label_editor_->grabKeyboardFocus();
205 macro_label_editor_->setVisible(
false);
206 String text = macro_label_editor_->getText().trim().toUpperCase();
210 macro_label_->setText(text);
212 SynthGuiInterface* synth_gui_interface = findParentComponentOfClass<SynthGuiInterface>();
213 if (synth_gui_interface)
243 macro_label_editor_->setVisible(
false);
250 SynthGuiInterface* synth_gui_interface = findParentComponentOfClass<SynthGuiInterface>();
251 if (synth_gui_interface ==
nullptr)
259 std::unique_ptr<SynthSlider> macro_knob_;
260 std::unique_ptr<ModulationButton> macro_source_;
261 std::unique_ptr<MacroLabel> macro_label_;
262 std::unique_ptr<OpenGlTextEditor> macro_label_editor_;
263 std::unique_ptr<OpenGlShapeButton> edit_label_;
267 setWantsKeyboardFocus(
true);
269 macros_[i] = std::make_unique<SingleMacroSection>(name + String(i), i);
286 int width = getWidth();
289 float next_y = (i + 1) * (2 * knob_section_height - widget_margin + padding);
290 macros_[i]->setBounds(0, y, width, next_y - y - padding);
295 macros_[
vital::kNumMacros - 1]->setBounds(0, last_y, width, getHeight() - last_y);
static Fonts * instance()
Gets the singleton instance of the Fonts class.
Definition fonts.h:52
MacroKnobSection(String name)
Constructs a new MacroKnobSection.
Definition macro_knob_section.cpp:266
void resized() override
Called when the component is resized.
Definition macro_knob_section.cpp:282
void paintBackground(Graphics &g) override
Paints the background of the macro knob section.
Definition macro_knob_section.cpp:278
~MacroKnobSection()
Destructor.
Definition macro_knob_section.cpp:276
A custom label for displaying macro names.
Definition macro_knob_section.cpp:15
void setTextSize(float size)
Sets the text size in point height.
Definition macro_knob_section.cpp:39
void paint(Graphics &g) override
Paints the label text.
Definition macro_knob_section.cpp:53
void setText(String text)
Sets the label text.
Definition macro_knob_section.cpp:32
String getText()
Gets the current text.
Definition macro_knob_section.cpp:46
MacroLabel(String name, String text)
Constructs a MacroLabel.
Definition macro_knob_section.cpp:23
A component that uses OpenGL to render a cached image of a JUCE component or custom drawing.
Definition open_gl_image_component.h:18
virtual void redrawImage(bool force)
Redraws the image if necessary, creating or updating the internal Image.
Definition open_gl_image_component.cpp:16
static Path pencil()
Definition paths.h:725
Represents a single macro knob and associated controls (label, edit button, source button).
Definition macro_knob_section.cpp:76
void reset() override
Resets the macro label to the current synthesizer's macro name.
Definition macro_knob_section.cpp:249
void textEditorReturnKeyPressed(TextEditor &text_editor) override
Called when the return key is pressed in the text editor.
Definition macro_knob_section.cpp:222
SingleMacroSection(String name, int index)
Constructs a SingleMacroSection.
Definition macro_knob_section.cpp:84
void paintMacroSourceBackground(Graphics &g)
Paints the background for the macro source area.
Definition macro_knob_section.cpp:168
void saveMacroLabel()
Saves the macro label name after editing.
Definition macro_knob_section.cpp:204
void buttonClicked(Button *clicked_button) override
Handles button click events, including toggling the label editor.
Definition macro_knob_section.cpp:182
void textEditorFocusLost(TextEditor &text_editor) override
Called when the text editor loses focus.
Definition macro_knob_section.cpp:231
void textEditorEscapeKeyPressed(TextEditor &editor) override
Called when the escape key is pressed in the text editor.
Definition macro_knob_section.cpp:242
void paintBackgroundShadow(Graphics &g) override
Paints a background shadow if needed.
Definition macro_knob_section.cpp:161
void resized() override
Called when the component is resized.
Definition macro_knob_section.cpp:125
void paintBackground(Graphics &g) override
Paints the background for the macro section.
Definition macro_knob_section.cpp:145
@ kLabelHeight
Definition skin.h:72
@ kBodyText
Definition skin.h:133
@ kMacro
Definition skin.h:43
void setMacroName(int index, const String ¯o_name)
Sets the name of a macro control by index.
Definition synth_base.cpp:697
String getMacroName(int index)
Gets the name of a macro control by index.
Definition synth_base.cpp:717
An interface class linking the Vital synthesizer backend (SynthBase) with a GUI.
Definition synth_gui_interface.h:56
SynthBase * getSynth()
Returns the SynthBase instance this interface is managing.
Definition synth_gui_interface.h:85
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
float getPadding()
Definition synth_section.cpp:660
void addSlider(SynthSlider *slider, bool show=true, bool listen=true)
Definition synth_section.cpp:445
void addSubSection(SynthSection *section, bool show=true)
Adds a subsection (another SynthSection) as a child.
Definition synth_section.cpp:457
virtual void resized() override
Called when the component is resized. Arranges layout of child components.
Definition synth_section.cpp:35
virtual void paintBody(Graphics &g, Rectangle< int > bounds)
Paints the body background within given bounds.
Definition synth_section.cpp:165
void paintChildrenBackgrounds(Graphics &g)
Paints the backgrounds for all child sections.
Definition synth_section.cpp:274
void paintKnobShadows(Graphics &g)
Paints knob shadows for all sliders.
Definition synth_section.cpp:253
void drawLabelBackgroundForComponent(Graphics &g, Component *component)
Draws label background for a specific component.
Definition synth_section.cpp:764
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
Rectangle< int > getLabelBackgroundBounds(Rectangle< int > bounds, bool text_component=false)
Gets the background bounds for a label.
Definition synth_section.cpp:782
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
float getKnobSectionHeight()
Definition synth_section.cpp:633
void addOpenGlComponent(OpenGlComponent *open_gl_component, bool to_beginning=false)
Definition synth_section.cpp:489
void placeRotaryOption(Component *option, SynthSlider *rotary)
Definition synth_section.cpp:593
virtual void reset()
Resets the section and all sub-sections.
Definition synth_section.cpp:30
void setSkinOverride(Skin::SectionOverride skin_override)
Definition synth_section.h:303
virtual void paintTabShadow(Graphics &g)
Paints a tab-like shadow effect around the component.
Definition synth_section.cpp:188
float getWidgetMargin()
Definition synth_section.cpp:676
constexpr int kNumMacros
Number of macro controls available.
Definition synth_constants.h:28
Declares the SynthSlider and related classes, providing various slider styles and functionality in th...