Vital
Loading...
Searching...
No Matches
wave_fold_overlay.cpp
Go to the documentation of this file.
1#include "wave_fold_overlay.h"
2
3#include "skin.h"
4#include "wave_frame.h"
5#include "synth_slider.h"
7
8WaveFoldOverlay::WaveFoldOverlay() : WavetableComponentOverlay("WAVE FOLDER"), wave_fold_modifier_(nullptr) {
9 current_frame_ = nullptr;
10
11 // Initialize wave fold amount slider
12 wave_fold_amount_ = std::make_unique<SynthSlider>("wave_fold_amount");
14 wave_fold_amount_->getImageComponent()->setAlwaysOnTop(true);
15 wave_fold_amount_->setAlwaysOnTop(true);
16 wave_fold_amount_->addListener(this);
17 wave_fold_amount_->setRange(1.0f, 32.0f);
18 wave_fold_amount_->setDoubleClickReturnValue(true, 1.0f);
20 wave_fold_amount_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
21
22 // Set control background titles
25}
26
28 if (keyframe == nullptr) {
29 current_frame_ = nullptr;
30 }
31
32 // Frame belongs to the wave fold modifier, update UI values
33 else if (keyframe->owner() == wave_fold_modifier_) {
35 wave_fold_amount_->setValue(current_frame_->getWaveFoldBoost(), dontSendNotification);
36 wave_fold_amount_->redoImage();
37 }
38}
39
40void WaveFoldOverlay::setEditBounds(Rectangle<int> bounds) {
41 static constexpr float kFoldWidthHeightRatio = 4.0f;
42
43 float width = bounds.getHeight() * kFoldWidthHeightRatio;
44 setControlsWidth(width);
45 int x = bounds.getX() + (bounds.getWidth() - width) / 2;
46
47 int title_height = bounds.getHeight() * WavetableComponentOverlay::kTitleHeightRatio;
48 Rectangle<int> slider_bounds(x, bounds.getY() + title_height, width, bounds.getHeight() - title_height);
50 wave_fold_amount_->setBounds(slider_bounds);
51
53 wave_fold_amount_->redoImage();
54}
55
56void WaveFoldOverlay::sliderValueChanged(Slider* moved_slider) {
57 if (current_frame_) {
58 // Update the current keyframe with the new fold amount
60 notifyChanged(false);
61 }
62}
63
64void WaveFoldOverlay::sliderDragEnded(Slider* moved_slider) {
65 // User finished interacting with the slider, commit changes
66 notifyChanged(true);
67}
void addSlider(SynthSlider *slider, bool show=true, bool listen=true)
Definition synth_section.cpp:445
static TextLookAndFeel * instance()
Singleton instance access.
Definition text_look_and_feel.h:106
void setWaveFoldBoost(float boost)
Sets a new wave fold boost factor.
Definition wave_fold_modifier.h:57
float getWaveFoldBoost()
Gets the current wave fold boost factor.
Definition wave_fold_modifier.h:48
WaveFoldModifierKeyframe * getKeyframe(int index)
Retrieves a WaveFoldModifierKeyframe at a given index.
Definition wave_fold_modifier.cpp:73
virtual void frameSelected(WavetableKeyframe *keyframe) override
Called when a new frame is selected in the wavetable editor.
Definition wave_fold_overlay.cpp:27
WaveFoldOverlay()
Constructor.
Definition wave_fold_overlay.cpp:8
WaveFoldModifier::WaveFoldModifierKeyframe * current_frame_
Currently selected frame data.
Definition wave_fold_overlay.h:73
void sliderDragEnded(Slider *moved_slider) override
Called when the user finishes interacting with the slider.
Definition wave_fold_overlay.cpp:64
void sliderValueChanged(Slider *moved_slider) override
Handles changes to the slider's value.
Definition wave_fold_overlay.cpp:56
WaveFoldModifier * wave_fold_modifier_
The associated WaveFoldModifier instance.
Definition wave_fold_overlay.h:72
std::unique_ptr< SynthSlider > wave_fold_amount_
Slider controlling the wave folding amount.
Definition wave_fold_overlay.h:75
virtual void setEditBounds(Rectangle< int > bounds) override
Sets the bounds of the editing area in the overlay.
Definition wave_fold_overlay.cpp:40
void setPositions()
Updates all OpenGL components and text positions after changes to lines or titles.
Definition wavetable_component_overlay.cpp:7
void addTitle(const std::string &title)
Adds a title string for the next control section.
Definition wavetable_component_overlay.h:94
void clearTitles()
Clears all control section titles.
Definition wavetable_component_overlay.h:82
A base overlay component for editing and interacting with a wavetable component's parameters.
Definition wavetable_component_overlay.h:22
void setControlsWidth(int width)
Sets the total width for controls in the overlay.
Definition wavetable_component_overlay.h:267
ControlsBackground controls_background_
Definition wavetable_component_overlay.h:300
virtual void setEditBounds(Rectangle< int > bounds)
Sets the editing bounds within which controls and titles are placed.
Definition wavetable_component_overlay.cpp:67
static constexpr float kTitleHeightRatio
Definition wavetable_component_overlay.h:32
void notifyChanged(bool mouse_up)
Notifies listeners that a change has occurred to the frame.
Definition wavetable_component_overlay.cpp:86
Represents a single state of a waveform at a specific position in a wavetable.
Definition wavetable_keyframe.h:35
int index()
Gets the index of this keyframe within its owner component.
Definition wavetable_keyframe.cpp:32
WavetableComponent * owner()
Gets the WavetableComponent that owns this keyframe.
Definition wavetable_keyframe.h:152
Declares the SynthSlider and related classes, providing various slider styles and functionality in th...