Vital
Loading...
Searching...
No Matches
modulation_tab_selector.h
Go to the documentation of this file.
1#pragma once
2
3#include "JuceHeader.h"
4#include "modulation_button.h"
5
17public:
22 class Listener {
23 public:
24 virtual ~Listener() = default;
25
31 virtual void modulationSelected(ModulationTabSelector* selector, int index) = 0;
32 };
33
39 ModulationTabSelector(std::string prefix, int number);
40
47 ModulationTabSelector(String name, int number, const char** names);
48
53
58 void paintBackground(Graphics& g) override;
59
64 void paintTabShadow(Graphics& g) override;
65
71 void resized() override;
72
77 void checkNumShown(bool should_repaint);
78
84 void reset() override;
85
90 void modulationClicked(ModulationButton* source) override;
91
95 void modulationConnectionChanged() override;
96
100 void endModulationMap() override;
101
105 void modulationCleared() override;
106
111 void addListener(Listener* listener) { listeners_.push_back(listener); }
112
117 void registerModulationButtons(SynthSection* synth_section);
118
123 void setFontSize(float font_size);
124
129 void setVertical(bool vertical) { vertical_ = vertical; }
130
134 void enableSelections() { selections_enabled_ = true; modulation_buttons_[0]->select(true); }
135
140 void setMinModulationsShown(int num) { min_modulations_shown_ = num; }
141
146 void connectRight(bool connect) {
147 for (auto& modulation_button : modulation_buttons_)
148 modulation_button->setConnectRight(connect);
149 }
150
156 ModulationButton* getButton(int index) { return modulation_buttons_[index].get(); }
157
162 void drawBorders(bool draw) {
163 for (auto& button : modulation_buttons_)
164 button->setDrawBorder(draw);
165 }
166
167private:
173 int getModulationIndex(String name);
174
179 int getNumModulationsToShow();
180
181 std::vector<std::unique_ptr<ModulationButton>> modulation_buttons_;
182 std::vector<Listener*> listeners_;
183 bool vertical_;
184 bool selections_enabled_;
185 int min_modulations_shown_;
186 int num_shown_;
187
188 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulationTabSelector)
189};
Interface for receiving notifications about modulation events from the ModulationButton.
Definition modulation_button.h:60
A component representing a modulation source or connection button.
Definition modulation_button.h:21
Interface for objects interested in ModulationTabSelector events.
Definition modulation_tab_selector.h:22
virtual void modulationSelected(ModulationTabSelector *selector, int index)=0
Called when a modulation source within this selector is selected.
A section of the GUI providing multiple modulation sources as tabs.
Definition modulation_tab_selector.h:16
void modulationConnectionChanged() override
Called when a modulation connection changes (e.g., a new connection added or removed).
Definition modulation_tab_selector.cpp:131
virtual ~ModulationTabSelector()
Destructor.
ModulationButton * getButton(int index)
Gets a pointer to a specific ModulationButton by index.
Definition modulation_tab_selector.h:156
ModulationTabSelector(std::string prefix, int number)
Constructs a ModulationTabSelector with a given prefix and number of tabs.
Definition modulation_tab_selector.cpp:6
void drawBorders(bool draw)
Enables or disables border drawing for each tab.
Definition modulation_tab_selector.h:162
void addListener(Listener *listener)
Registers a listener to receive events from this ModulationTabSelector.
Definition modulation_tab_selector.h:111
void reset() override
Resets the tab selector to its default state.
Definition modulation_tab_selector.cpp:96
void setVertical(bool vertical)
Sets whether tabs should be arranged vertically.
Definition modulation_tab_selector.h:129
void paintBackground(Graphics &g) override
Paints the component background and tab shadows.
Definition modulation_tab_selector.cpp:27
void checkNumShown(bool should_repaint)
Checks the number of modulations that should be displayed and updates the layout.
Definition modulation_tab_selector.cpp:63
void connectRight(bool connect)
Configures whether the tabs should connect visually to the right.
Definition modulation_tab_selector.h:146
void resized() override
Called when the component is resized.
Definition modulation_tab_selector.cpp:59
void paintTabShadow(Graphics &g) override
Paints a shadow behind the tabs.
Definition modulation_tab_selector.cpp:49
void setMinModulationsShown(int num)
Sets the minimum number of modulations to show before revealing additional ones.
Definition modulation_tab_selector.h:140
void registerModulationButtons(SynthSection *synth_section)
Registers all modulation buttons with a given SynthSection.
Definition modulation_tab_selector.cpp:141
void modulationClicked(ModulationButton *source) override
Called when a modulation button within this selector is clicked.
Definition modulation_tab_selector.cpp:112
void modulationCleared() override
Called when all modulations for a source have been cleared.
Definition modulation_tab_selector.cpp:136
void enableSelections()
Enables the ability for one of the tabs to remain selected.
Definition modulation_tab_selector.h:134
void setFontSize(float font_size)
Sets the font size used for the modulation button labels.
Definition modulation_tab_selector.cpp:146
void endModulationMap() override
Called when modulation mapping ends.
Definition modulation_tab_selector.cpp:126
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193