12 if (component_list ==
nullptr)
25 if (component_list ==
nullptr)
39 SynthSection(
"component list"), wavetable_creator_(wavetable_creator),
40 component_backgrounds_(kMaxRows,
Shaders::kRoundedRectangleFragment), row_height_(0) {
66 plus_icons_[i] = std::make_unique<PlainShapeComponent>(
"plus");
67 plus_icons_[i]->setJustification(Justification::centredLeft);
76 viewport_.setScrollBarsShown(
false,
false,
true,
false);
87 names_[i] = std::make_unique<PlainTextComponent>(String(i),
"");
89 names_[i]->setInterceptsMouseClicks(
false,
false);
90 names_[i]->setJustification(Justification::centredLeft);
91 names_[i]->setScissor(
true);
95 menu_buttons_[i] = std::make_unique<OpenGlShapeButton>(String(i));
124 static constexpr float kScrollBarWidth = 13.0f;
134 for (
int i = 0; i < num_groups; ++i) {
138 for (
int n = 0; n < num_components; ++n) {
141 names_[index]->setText(name);
152 viewport_.setBounds(0, 0, getWidth(), getHeight());
159 for (
int i = 0; i < num_groups; ++i)
171 int width = getWidth();
172 float source_gl_x = (
row_height_ - rounding) * 2.0f / width - 1.0f;
173 float modifier_gl_x = (2.0f *
row_height_ - rounding) * 2.0f / width - 1.0f;
174 float gl_width = 2.0f +
row_height_ * 2.0f / width;
176 float gl_height = 2.0f * cell_height / container_height;
181 for (
int i = 0; i < num_groups; ++i) {
185 for (
int n = 0; n < num_components; ++n) {
187 float gl_y = 1.0f - y * 2.0f / container_height - gl_height;
189 menu_buttons_[index]->setBounds(width - cell_height, y, cell_height, cell_height);
199 names_[index]->setVisible(
true);
200 names_[index]->redrawImage(
false);
226 for (
int i = index; i <
kMaxRows; ++i) {
227 names_[i]->setVisible(
false);
241 int index = row_index;
242 for (
int i = 0; i < num_groups; ++i) {
245 if (index < num_components)
248 index -= num_components;
270 showPopupSelector(
this, Point<int>(button->getX(), button->getBottom()), options,
271 [=](
int selection) { componentRowGroupCallback(selection, this); });
272 button->setState(Button::buttonNormal);
292 showPopupSelector(
this, Point<int>(button->getX(), button->getBottom()), options,
293 [=](
int selection) { componentRowCallback(selection, this); });
294 button->setState(Button::buttonNormal);
314 showPopupSelector(
this, Point<int>(button->getX(), button->getBottom()), options,
315 [=](
int selection) { addComponent(selection); });
327 [=](
int selection) { addSource(selection); });
341 for (
int i = 0; i <
kMaxRows; ++i) {
350 int offset =
viewport_.getVerticalScrollBar().getCurrentRangeStart();
352 listener->componentsScrolled(-offset);
358 viewport_.setViewPosition({ 0, (int)range_start });
422 for (
int i = 0; i < num_components; ++i)
472 listener->componentAdded(component);
478 listener->componentRemoved(component);
483 listener->componentsReordered();
489 listener->componentsChanged();
void setQuad(int i, float x, float y, float w, float h)
Sets the position and size of a quad in normalized device space.
Definition open_gl_multi_quad.h:313
void setTargetComponent(Component *target_component)
Sets a target component to help position the quads.
Definition open_gl_multi_quad.h:358
void setNumQuads(int num_quads)
Sets how many quads will actually be drawn (up to max_quads).
Definition open_gl_multi_quad.h:92
force_inline void setColor(Colour color)
Sets the base color for the quads.
Definition open_gl_multi_quad.h:102
void setRounding(float rounding)
Sets the rounding radius of the quads.
Definition open_gl_multi_quad.h:347
static Path plus(int width)
Definition paths.h:305
static Path menu()
Creates a menu icon path (three horizontal lines).
Definition paths.h:271
@ kLight
Definition open_gl_image_component.h:309
Manages and provides access to vertex and fragment shaders used by the OpenGL rendering pipeline.
Definition shaders.h:19
@ kLabelBackgroundRounding
Definition skin.h:74
@ kUiButtonText
Definition skin.h:193
@ kLightenScreen
Definition skin.h:141
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
std::vector< OpenGlComponent * > open_gl_components_
Definition synth_section.h:804
void paintOpenGlChildrenBackgrounds(Graphics &g)
Paints the backgrounds for all OpenGL child components.
Definition synth_section.cpp:267
virtual void resized() override
Called when the component is resized. Arranges layout of child components.
Definition synth_section.cpp:35
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
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
void addOpenGlComponent(OpenGlComponent *open_gl_component, bool to_beginning=false)
Definition synth_section.cpp:489
static WavetableComponent * createComponent(ComponentType type)
Creates a new WavetableComponent instance of a given enumerated type.
Definition wavetable_component_factory.cpp:19
ComponentType
Enumerates all known WavetableComponents, including sources and modifiers.
Definition wavetable_component_factory.h:28
@ kBeginModifierTypes
Definition wavetable_component_factory.h:35
static ComponentType getModifierType(int type)
Converts an integer index to a modifier ComponentType.
Definition wavetable_component_factory.h:104
static ComponentType getSourceType(int type)
Converts an integer index to a source ComponentType.
Definition wavetable_component_factory.h:96
static int numSourceTypes()
Returns the number of source types defined.
Definition wavetable_component_factory.h:57
static std::string getComponentName(ComponentType type)
Gets the human-readable name of a component from its enumerated type.
Definition wavetable_component_factory.cpp:75
static int numModifierTypes()
Returns the number of modifier types defined.
Definition wavetable_component_factory.h:64
A base class representing a component in a wavetable synthesis chain.
Definition wavetable_component.h:32
void reset()
Clears all keyframes and inserts a default one at position 0.
Definition wavetable_component.cpp:62
WavetableKeyframe * insertNewKeyframe(int position)
Inserts a new keyframe at the given position, creating and sorting it into the array.
Definition wavetable_component.cpp:8
virtual WavetableComponentFactory::ComponentType getType()=0
Returns the type of this WavetableComponent.
Interface for objects wanting to know when the component list changes.
Definition wavetable_component_list.h:86
A UI component that lists and manages the wavetable sources and modifiers.
Definition wavetable_component_list.h:65
void paintBackground(Graphics &g) override
Overridden to paint the background and related elements.
Definition wavetable_component_list.cpp:111
std::unique_ptr< OpenGlToggleButton > add_modifier_buttons_[kMaxSources]
Buttons to add modifiers.
Definition wavetable_component_list.h:330
void moveModifierUp()
Moves the currently selected modifier up in its group.
Definition wavetable_component_list.cpp:450
int current_component_index_
The currently selected component index.
Definition wavetable_component_list.h:324
std::unique_ptr< PlainShapeComponent > plus_icons_[kMaxSources+1]
Plus icons next to buttons.
Definition wavetable_component_list.h:331
int numGroups()
Returns the number of groups in the wavetable.
Definition wavetable_component_list.h:262
int row_height_
Height of each row in pixels.
Definition wavetable_component_list.h:332
WavetableComponentViewport viewport_
Viewport for scrolling the component list.
Definition wavetable_component_list.h:318
void modifierMenuClicked(int row_index)
Displays a menu for the modifier row at the given index.
Definition wavetable_component_list.cpp:275
void addComponent(int type)
Adds a new component (modifier) of the given type.
Definition wavetable_component_list.cpp:383
void positionGroups()
Positions the groups and modifiers in the scrollable list.
Definition wavetable_component_list.cpp:150
std::unique_ptr< OpenGlScrollBar > scroll_bar_
A custom scrollbar for vertical scrolling.
Definition wavetable_component_list.h:320
void moveModifierDown()
Moves the currently selected modifier down in its group.
Definition wavetable_component_list.cpp:459
std::unique_ptr< OpenGlShapeButton > menu_buttons_[kMaxRows]
Menu buttons for each row.
Definition wavetable_component_list.h:328
void menuClicked(int row_index)
Displays a general menu for the given row index, determining if it's a group or modifier.
Definition wavetable_component_list.cpp:297
void buttonClicked(Button *button) override
Overridden to handle button clicks (menus, add source/modifier).
Definition wavetable_component_list.cpp:330
WavetableComponentList(WavetableCreator *wavetable_creator)
Constructs a WavetableComponentList for managing sources and modifiers.
Definition wavetable_component_list.cpp:38
std::unique_ptr< PlainTextComponent > names_[kMaxRows]
Text labels for each component row.
Definition wavetable_component_list.h:327
void removeGroup(int index)
Removes a source group by index.
Definition wavetable_component_list.cpp:374
void groupMenuClicked(int row_index)
Displays a menu for the group row at the given index.
Definition wavetable_component_list.cpp:253
void init()
Initializes the component list after construction.
Definition wavetable_component_list.cpp:107
static constexpr int kMaxSources
Maximum number of source groups.
Definition wavetable_component_list.h:68
std::vector< Listener * > listeners_
Listeners for changes in the component list.
Definition wavetable_component_list.h:325
void addSource(int index)
Adds a new source of the given index (maps to a component type).
Definition wavetable_component_list.cpp:361
void removeGroup()
Removes the currently selected group.
Definition wavetable_component_list.cpp:418
void componentsScrolled() override
Called when the components are scrolled.
Definition wavetable_component_list.cpp:349
WavetableCreator * wavetable_creator_
The wavetable creator managing group/components.
Definition wavetable_component_list.h:322
void notifyComponentAdded(WavetableComponent *component)
Notifies listeners that a component was added.
Definition wavetable_component_list.cpp:469
void addModifierClicked(int group_index)
Called when the "Add Modifier" button is clicked for a particular group.
Definition wavetable_component_list.cpp:304
Component component_container_
Container holding all UI elements for the list.
Definition wavetable_component_list.h:319
void removeComponent()
Removes the currently selected component.
Definition wavetable_component_list.cpp:397
void moveGroupUp()
Moves the currently selected group up in the list.
Definition wavetable_component_list.cpp:432
std::unique_ptr< OpenGlToggleButton > create_component_button_
Button to add a new source.
Definition wavetable_component_list.h:329
void notifyComponentRemoved(WavetableComponent *component)
Notifies listeners that a component was removed.
Definition wavetable_component_list.cpp:475
OpenGlMultiQuad component_backgrounds_
Background rectangles for each row.
Definition wavetable_component_list.h:326
std::pair< int, int > getIndicesForRow(int row_index)
Retrieves the group and component indices for a given row index.
Definition wavetable_component_list.cpp:239
void setScrollBarRange()
Sets the scrollbar range based on content size.
Definition wavetable_component_list.cpp:234
int current_group_index_
The currently selected group index.
Definition wavetable_component_list.h:323
void moveGroupDown()
Moves the currently selected group down in the list.
Definition wavetable_component_list.cpp:441
static constexpr int kMaxRows
Maximum number of rows for components.
Definition wavetable_component_list.h:67
void resetGroups()
Resets the display of groups and modifiers in the UI.
Definition wavetable_component_list.cpp:131
void addSourceClicked()
Called when the "Add Source" button is clicked.
Definition wavetable_component_list.cpp:318
void notifyComponentsReordered()
Notifies listeners that components have been reordered.
Definition wavetable_component_list.cpp:481
void resized() override
Overridden to layout and refresh the UI.
Definition wavetable_component_list.cpp:123
void scrollBarMoved(ScrollBar *scroll_bar, double range_start) override
Called when the scroll bar moves.
Definition wavetable_component_list.cpp:357
void clear()
Clears the list of sources and modifiers.
Definition wavetable_component_list.cpp:103
void notifyComponentsChanged()
Notifies listeners that components have changed.
Definition wavetable_component_list.cpp:487
@ kMoveUp
Definition wavetable_component_list.h:77
@ kReset
Definition wavetable_component_list.h:76
@ kRemove
Definition wavetable_component_list.h:79
@ kMoveDown
Definition wavetable_component_list.h:78
void resetComponent()
Resets the currently selected component to default state.
Definition wavetable_component_list.cpp:407
void addListener(Listener *listener)
Adds a listener that will be notified on scroll events.
Definition wavetable_component_list.h:39
A class responsible for creating complete wavetables from groups of wavetable components.
Definition wavetable_creator.h:27
void removeGroup(int index)
Definition wavetable_creator.cpp:51
WavetableGroup * getGroup(int index) const
Retrieves a WavetableGroup by index.
Definition wavetable_creator.h:71
void moveUp(int index)
Definition wavetable_creator.cpp:37
void addGroup(WavetableGroup *group)
Definition wavetable_creator.h:53
void moveDown(int index)
Definition wavetable_creator.cpp:44
A class representing a group of WavetableComponents combined to form part of a wavetable.
Definition wavetable_group.h:24
void addComponent(WavetableComponent *component)
Adds a new WavetableComponent to this group.
Definition wavetable_group.h:44
WavetableComponent * getComponent(int index) const
Retrieves a component by index.
Definition wavetable_group.h:92
void moveUp(int index)
Moves a component one position up in the ordering.
Definition wavetable_group.cpp:20
void removeComponent(int index)
Removes a component at a given index.
Definition wavetable_group.cpp:36
int numComponents() const
Gets the number of WavetableComponents in this group.
Definition wavetable_group.h:84
void moveDown(int index)
Moves a component one position down in the ordering.
Definition wavetable_group.cpp:28