Vital
Loading...
Searching...
No Matches
phase_editor.h
Go to the documentation of this file.
1#pragma once
2
3#include "JuceHeader.h"
5#include "common.h"
6
16public:
18 static constexpr int kNumLines = 16;
20 static constexpr float kDefaultHeightPercent = 0.2f;
21
26 class Listener {
27 public:
28 virtual ~Listener() { }
29
36 virtual void phaseChanged(float phase, bool mouse_up) = 0;
37 };
38
43
47 virtual ~PhaseEditor();
48
55 virtual void render(OpenGlWrapper& open_gl, bool animate) override {
56 OpenGlMultiQuad::render(open_gl, animate);
57 }
58
66 void mouseDown(const MouseEvent& e) override;
67
75 void mouseUp(const MouseEvent& e) override;
76
84 void mouseDrag(const MouseEvent& e) override;
85
91 void addListener(Listener* listener) { listeners_.push_back(listener); }
92
98 void setPhase(float phase);
99
105 void setMaxTickHeight(float height) { max_tick_height_ = height; }
106
107private:
115 void updatePhase(const MouseEvent& e);
116
122 void updatePositions();
123
124 std::vector<Listener*> listeners_;
125 Point<int> last_edit_position_;
126
127 float phase_;
128 float max_tick_height_;
129
130 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PhaseEditor)
131};
A component for rendering multiple quads using OpenGL, with customizable colors, rounding,...
Definition open_gl_multi_quad.h:16
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the quads using OpenGL.
Definition open_gl_multi_quad.cpp:92
Interface for receiving notifications when the phase value changes.
Definition phase_editor.h:26
virtual void phaseChanged(float phase, bool mouse_up)=0
Called when the phase value has been changed by user interaction.
virtual ~Listener()
Definition phase_editor.h:28
A UI component for interactively editing a phase value using a horizontal dragging gesture.
Definition phase_editor.h:15
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the tick lines representing the current phase.
Definition phase_editor.h:55
virtual ~PhaseEditor()
Destructor.
Definition phase_editor.cpp:14
void setPhase(float phase)
Sets the current phase value and updates the display.
Definition phase_editor.cpp:63
void mouseDrag(const MouseEvent &e) override
Called while the mouse is dragged horizontally.
Definition phase_editor.cpp:28
void mouseUp(const MouseEvent &e) override
Called when the mouse is released after interaction.
Definition phase_editor.cpp:20
void mouseDown(const MouseEvent &e) override
Called when the mouse is pressed down on the component.
Definition phase_editor.cpp:16
PhaseEditor()
Constructs a PhaseEditor.
Definition phase_editor.cpp:8
void setMaxTickHeight(float height)
Sets the maximum tick line height relative to the component height.
Definition phase_editor.h:105
static constexpr float kDefaultHeightPercent
Definition phase_editor.h:20
void addListener(Listener *listener)
Adds a listener to be notified when the phase changes.
Definition phase_editor.h:91
static constexpr int kNumLines
Definition phase_editor.h:18
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174