19 last_position_ = e.position;
21 MouseInputSource source = e.source;
22 if (source.isMouse() && source.canDoUnboundedMovement()) {
24 source.enableUnboundedMouseMovement(
true);
25 mouse_down_position_ = e.getScreenPosition();
32 MouseInputSource source = e.source;
33 if (source.isMouse() && source.canDoUnboundedMovement()) {
34 source.showMouseCursor(MouseCursor::NormalCursor);
35 source.enableUnboundedMouseMovement(
false);
36 source.setScreenPosition(mouse_down_position_.toFloat());
41 Point<float> position = e.position;
42 Point<float> delta_position = position - last_position_;
43 last_position_ = position;
45 for (
Listener* listener : listeners_)
46 listener->magnifyDragged(delta_position);
48 OpenGlShapeButton::mouseDrag(e);
52 for (
Listener* listener : listeners_)
53 listener->magnifyDoubleClicked();
55 OpenGlShapeButton::mouseDoubleClick(e);
61 delay_ = std::make_unique<SynthSlider>(value_prepend +
"_delay");
63 delay_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
64 delay_->setPopupPlacement(BubbleComponent::below);
66 attack_ = std::make_unique<SynthSlider>(value_prepend +
"_attack");
68 attack_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
69 attack_->setPopupPlacement(BubbleComponent::below);
71 attack_power_ = std::make_unique<SynthSlider>(value_prepend +
"_attack_power");
73 attack_power_->setVisible(
false);
75 hold_ = std::make_unique<SynthSlider>(value_prepend +
"_hold");
77 hold_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
78 hold_->setPopupPlacement(BubbleComponent::below);
80 decay_ = std::make_unique<SynthSlider>(value_prepend +
"_decay");
82 decay_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
83 decay_->setPopupPlacement(BubbleComponent::below);
85 decay_power_ = std::make_unique<SynthSlider>(value_prepend +
"_decay_power");
87 decay_power_->setVisible(
false);
89 release_ = std::make_unique<SynthSlider>(value_prepend +
"_release");
91 release_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
92 release_->setPopupPlacement(BubbleComponent::below);
94 release_power_ = std::make_unique<SynthSlider>(value_prepend +
"_release_power");
96 release_power_->setVisible(
false);
98 sustain_ = std::make_unique<SynthSlider>(value_prepend +
"_sustain");
100 sustain_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
101 sustain_->setPopupPlacement(BubbleComponent::below);
103 envelope_ = std::make_unique<EnvelopeEditor>(value_prepend, mono_modulations, poly_modulations);
105 envelope_->setName(value_prepend);
106 envelope_->setDelaySlider(delay_.get());
107 envelope_->setAttackSlider(attack_.get());
108 envelope_->setAttackPowerSlider(attack_power_.get());
109 envelope_->setHoldSlider(hold_.get());
110 envelope_->setDecaySlider(decay_.get());
111 envelope_->setDecayPowerSlider(decay_power_.get());
112 envelope_->setSustainSlider(sustain_.get());
113 envelope_->setReleaseSlider(release_.get());
114 envelope_->setReleasePowerSlider(release_power_.get());
115 envelope_->resetEnvelopeLine(-1);
117 drag_magnifying_glass_ = std::make_unique<DragMagnifyingGlass>();
118 drag_magnifying_glass_->addListener(
this);
119 addAndMakeVisible(drag_magnifying_glass_.get());
140 static constexpr float kMagnifyingHeightRatio = 0.2f;
142 int knob_y = getHeight() - knob_section_height;
145 int envelope_height = knob_y - widget_margin;
146 envelope_->setBounds(widget_margin, widget_margin, getWidth() - 2 * widget_margin, envelope_height);
148 Rectangle<int> knobs_area(0, knob_y, getWidth(), knob_section_height);
150 decay_.get(), sustain_.get(), release_.get() });
154 int magnify_height = envelope_->getHeight() * kMagnifyingHeightRatio;
155 drag_magnifying_glass_->setBounds(envelope_->getRight() - magnify_height, envelope_->getY(),
156 magnify_height, magnify_height);
160 envelope_->resetPositions();
165 envelope_->magnifyZoom(delta);
169 envelope_->magnifyReset();
Interface for objects that need to respond to magnification changes.
Definition envelope_section.h:21
void mouseUp(const MouseEvent &e) override
Definition envelope_section.cpp:29
void mouseDrag(const MouseEvent &e) override
Definition envelope_section.cpp:40
void mouseDown(const MouseEvent &e) override
Definition envelope_section.cpp:17
void mouseDoubleClick(const MouseEvent &e) override
Definition envelope_section.cpp:51
DragMagnifyingGlass()
Constructor.
Definition envelope_section.cpp:13
EnvelopeSection(String name, std::string value_prepend, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations)
Definition envelope_section.cpp:58
void magnifyDoubleClicked() override
Called when the magnifying glass is double-clicked. Resets envelope zoom.
Definition envelope_section.cpp:168
virtual ~EnvelopeSection()
Destructor.
Definition envelope_section.cpp:124
void reset() override
Resets the envelope editor to its default positions.
Definition envelope_section.cpp:159
void resized() override
Resizes and lays out child components, including the envelope editor and sliders.
Definition envelope_section.cpp:139
void magnifyDragged(Point< float > delta) override
Definition envelope_section.cpp:164
void paintBackground(Graphics &g) override
Definition envelope_section.cpp:126
static Path magnifyingGlass()
Definition paths.h:588
@ kWidgetMargin
Definition skin.h:103
@ kEnvelope
Definition skin.h:39
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
void placeKnobsInArea(Rectangle< int > area, std::vector< Component * > knobs)
Definition synth_section.cpp:601
void addSlider(SynthSlider *slider, bool show=true, bool listen=true)
Definition synth_section.cpp:445
virtual void resized() override
Called when the component is resized. Arranges layout of child components.
Definition synth_section.cpp:35
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 drawLabelForComponent(Graphics &g, String text, Component *component, bool text_component=false)
Draws a label for a given component.
Definition synth_section.h:548
void setLabelFont(Graphics &g)
Sets the Graphics context font and color for labels.
Definition synth_section.cpp:740
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
float getKnobSectionHeight()
Definition synth_section.cpp:633
void addOpenGlComponent(OpenGlComponent *open_gl_component, bool to_beginning=false)
Definition synth_section.cpp:489
float getSizeRatio() const
Definition synth_section.h:765
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
Declares the EnvelopeSection class, which provides a UI for configuring ADSR-type envelopes.
std::map< std::string, Output * > output_map
Maps parameter names to Output pointers, representing output signals from various modules.
Definition synth_types.h:229
Declares the SynthSlider and related classes, providing various slider styles and functionality in th...