11 setInterceptsMouseClicks(
true,
false);
17 last_edit_position_ = e.getPosition();
24 for (
Listener* listener : listeners_)
25 listener->phaseChanged(phase_,
true);
33void PhaseEditor::updatePhase(
const MouseEvent& e) {
34 int difference = e.getPosition().x - last_edit_position_.x;
36 phase_ += (2.0f *
vital::kPi * difference) / getWidth();
37 last_edit_position_ = e.getPosition();
39 for (Listener* listener : listeners_)
40 listener->phaseChanged(phase_,
false);
45void PhaseEditor::updatePositions() {
46 float width = 2.0f / getWidth();
50 fraction -= floorf(fraction);
52 float height = max_tick_height_ * 2.0f;
54 for (
int div = 2; div <
kNumLines; div *= 2) {
59 setQuad(i, 2.0f * fraction - 1.0f, -1.0f, width, height);
A component for rendering multiple quads using OpenGL, with customizable colors, rounding,...
Definition open_gl_multi_quad.h:16
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
Interface for receiving notifications when the phase value changes.
Definition phase_editor.h:26
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
static constexpr float kDefaultHeightPercent
Definition phase_editor.h:20
static constexpr int kNumLines
Definition phase_editor.h:18
Manages and provides access to vertex and fragment shaders used by the OpenGL rendering pipeline.
Definition shaders.h:19
constexpr mono_float kPi
Pi constant.
Definition common.h:36
Provides various utility functions, classes, and constants for audio, math, and general-purpose opera...