Vital
|
A specialized LineEditor that visualizes and optionally animates a line-to-value mapping. More...
#include <line_map_editor.h>
Public Member Functions | |
LineMapEditor (LineGenerator *line_source, String name) | |
Constructs the LineMapEditor. | |
virtual | ~LineMapEditor () |
Destructor. | |
void | parentHierarchyChanged () override |
Called when the component’s parent hierarchy changes. | |
virtual void | render (OpenGlWrapper &open_gl, bool animate) override |
Renders the line map with optional animation. | |
void | setAnimate (bool animate) |
Enables or disables animation in the line map editor. | |
![]() | |
LineEditor (LineGenerator *line_source) | |
Constructs the LineEditor. | |
virtual | ~LineEditor () |
Destructor. | |
void | resetWavePath () |
Resets the wave path, recalculating positions based on current points and powers. | |
void | resized () override |
Called when the component is resized. | |
float | padY (float y) |
Pads a Y coordinate to fit the drawing area with vertical padding. | |
float | unpadY (float y) |
Removes padding from a padded Y coordinate. | |
float | padX (float x) |
Pads an X coordinate to fit the drawing area with horizontal padding. | |
float | unpadX (float x) |
Removes padding from a padded X coordinate. | |
virtual void | mouseDown (const MouseEvent &e) override |
virtual void | mouseDoubleClick (const MouseEvent &e) override |
virtual void | mouseMove (const MouseEvent &e) override |
virtual void | mouseDrag (const MouseEvent &e) override |
virtual void | mouseUp (const MouseEvent &e) override |
virtual void | respondToCallback (int point, int power, int option) |
Responds to a callback triggered by a menu option or action. | |
bool | hasMatchingSystemClipboard () |
Checks if the system clipboard contains a compatible line data JSON. | |
void | paintLine (const MouseEvent &e) |
Paints the line by adding points according to a pattern when in paint mode. | |
void | drawDown (const MouseEvent &e) |
Handles the initial mouse press (not in paint mode) for dragging points or powers. | |
void | drawDrag (const MouseEvent &e) |
Handles mouse dragging to move points or adjust powers. | |
void | drawUp (const MouseEvent &e) |
Handles mouse release to finalize point or power positions. | |
void | mouseWheelMove (const MouseEvent &e, const MouseWheelDetails &wheel) override |
void | mouseExit (const MouseEvent &e) override |
void | clearActiveMouseActions () |
void | renderGrid (OpenGlWrapper &open_gl, bool animate) |
Renders the grid lines that show snapping lines or painting sections. | |
void | renderPoints (OpenGlWrapper &open_gl, bool animate) |
Renders the points and power handles on the curve. | |
void | init (OpenGlWrapper &open_gl) override |
Initializes OpenGL resources for rendering the line. | |
void | destroy (OpenGlWrapper &open_gl) override |
Destroys OpenGL resources allocated by this line renderer. | |
void | setSizeRatio (float ratio) |
Sets the size ratio, scaling UI elements accordingly. | |
float | sizeRatio () const |
Gets the current size ratio. | |
void | setLoop (bool loop) |
Enables or disables looping of the line at the edges. | |
void | setSmooth (bool smooth) |
Enables or disables smoothing of the curve. | |
bool | getSmooth () const |
Checks if smoothing is enabled. | |
void | setPaint (bool paint) |
Enables or disables paint mode. | |
void | setPaintPattern (std::vector< std::pair< float, float > > pattern) |
Sets a pattern of points used when painting the line. | |
virtual void | setGridSizeX (int size) |
Sets the horizontal grid size. | |
virtual void | setGridSizeY (int size) |
Sets the vertical grid size. | |
int | getGridSizeX () |
Gets the current horizontal grid size. | |
int | getGridSizeY () |
Gets the current vertical grid size. | |
void | setModel (LineGenerator *model) |
Sets the LineGenerator model defining the curve. | |
LineGenerator * | getModel () |
Gets the current LineGenerator model. | |
void | showTextEntry () |
Shows the text editor for entering a precise value or phase. | |
void | hideTextEntry () |
Hides the text entry editor. | |
void | textEditorReturnKeyPressed (TextEditor &editor) override |
void | textEditorFocusLost (TextEditor &editor) override |
void | textEditorEscapeKeyPressed (TextEditor &editor) override |
void | setSliderPositionFromText () |
Sets the position of the selected point/power from the text field. | |
void | setAllowFileLoading (bool allow) |
Allows or disallows file loading actions (copy/paste from files). | |
void | addListener (Listener *listener) |
Adds a listener for line editor events. | |
void | setActive (bool active) |
Sets whether the line editor is active (enabled). | |
force_inline void | resetPositions () |
Marks positions as needing recalculation on next render. | |
OpenGlComponent * | getTextEditorComponent () |
Gets the OpenGlComponent for text editing (if any). | |
![]() | |
OpenGlLineRenderer (int num_points, bool loop=false) | |
Constructs an OpenGlLineRenderer for a given number of points. | |
virtual | ~OpenGlLineRenderer () |
Destructor. | |
force_inline void | setColor (Colour color) |
Sets the line color. | |
force_inline void | setLineWidth (float width) |
Sets the line width in pixels. | |
force_inline void | setBoost (float boost) |
Sets a global boost value affecting line thickness. | |
force_inline float | boostLeftAt (int index) const |
Gets the left-side boost at a given point index. | |
force_inline float | boostRightAt (int index) const |
Gets the right-side boost at a given point index. | |
force_inline float | yAt (int index) const |
Gets the y-coordinate of a point at a given index. | |
force_inline float | xAt (int index) const |
Gets the x-coordinate of a point at a given index. | |
force_inline void | setBoostLeft (int index, float val) |
Sets the left-side boost for a point, marking data as dirty. | |
force_inline void | setBoostRight (int index, float val) |
Sets the right-side boost for a point, marking data as dirty. | |
force_inline void | setYAt (int index, float val) |
Sets the y-coordinate of a point, marking data as dirty. | |
force_inline void | setXAt (int index, float val) |
Sets the x-coordinate of a point, marking data as dirty. | |
void | setFillVertices (bool left) |
Sets fill vertices according to the current line and boost data. | |
void | setLineVertices (bool left) |
Sets line vertices according to the current line and boost data. | |
force_inline void | setFill (bool fill) |
Enables or disables filling below the line. | |
force_inline void | setFillColor (Colour fill_color) |
Sets a uniform fill color if only one color is needed. | |
force_inline void | setFillColors (Colour fill_color_from, Colour fill_color_to) |
Sets a gradient fill from one color to another. | |
force_inline void | setFillCenter (float fill_center) |
Sets the vertical center for the fill area. | |
force_inline void | setFit (bool fit) |
Enables fitting the line inside the available area. | |
force_inline void | setBoostAmount (float boost_amount) |
Sets the boost amount that affects line thickness. | |
force_inline void | setFillBoostAmount (float boost_amount) |
Sets the boost amount that affects fill thickness. | |
force_inline void | setIndex (int index) |
Sets an index used for custom behavior (e.g., multiple line sets). | |
void | boostLeftRange (float start, float end, int buffer_vertices, float min) |
Boosts left-side range of the line. | |
void | boostRightRange (float start, float end, int buffer_vertices, float min) |
Boosts right-side range of the line. | |
void | boostRange (float *boosts, float start, float end, int buffer_vertices, float min) |
Boosts a range for the given boost array. | |
void | boostRange (vital::poly_float start, vital::poly_float end, int buffer_vertices, vital::poly_float min) |
Boosts left and right arrays using poly_float parameters. | |
void | decayBoosts (vital::poly_float mult) |
Decays all boosts by a multiplicative factor, allowing animated damping. | |
void | enableBackwardBoost (bool enable) |
Enables backward boost calculation for symmetrical line deformation. | |
force_inline int | numPoints () const |
Gets the number of points in the line. | |
force_inline Colour | color () const |
Gets the current line color. | |
void | drawLines (OpenGlWrapper &open_gl, bool left) |
Draws the line and optional fill using OpenGL. | |
bool | anyBoostValue () |
Checks if any boost value is set. | |
![]() | |
OpenGlComponent (String name="") | |
Constructs an OpenGlComponent. | |
virtual | ~OpenGlComponent () |
Destructor. | |
void | addRoundedCorners () |
Adds rounded corners to the component's edges. | |
void | addBottomRoundedCorners () |
Adds rounded corners only at the bottom of the component. | |
void | renderCorners (OpenGlWrapper &open_gl, bool animate, Colour color, float rounding) |
Renders the corner shapes using the given color and rounding amount. | |
void | renderCorners (OpenGlWrapper &open_gl, bool animate) |
Renders corners with default body color and rounding. | |
virtual void | paintBackground (Graphics &g) |
Paints a standard background for the component. | |
void | repaintBackground () |
Requests a repaint of the component's background on the OpenGL layer. | |
Colour | getBodyColor () const |
Retrieves the component's body color. | |
void | setParent (const SynthSection *parent) |
Sets a pointer to the parent SynthSection for skin value lookups. | |
float | findValue (Skin::ValueId value_id) |
Finds a float value from the skin associated with this component's parent. | |
void | setSkinValues (const Skin &skin) |
Applies the skin overrides to this component's colors. | |
void | setSkinOverride (Skin::SectionOverride skin_override) |
Sets a skin override to control the component's color scheme. | |
force_inline void | checkGlError () |
Checks for and asserts that there are no OpenGL errors. | |
void | setBackgroundColor (const Colour &color) |
Sets the background color of the component for painting operations. | |
Static Public Attributes | |
static constexpr float | kTailDecay = 0.93f |
Decay factor for reducing line boost effects over time (for animation smoothing). | |
![]() | |
static constexpr float | kPositionWidth = 9.0f |
Width in pixels for main position markers. | |
static constexpr float | kPowerWidth = 7.0f |
Width in pixels for power markers (curve shaping handles). | |
static constexpr float | kRingThickness = 0.45f |
Fractional thickness for marker ring rendering. | |
static constexpr float | kGrabRadius = 12.0f |
Radius in pixels for detecting grabbing a point or power handle. | |
static constexpr float | kDragRadius = 20.0f |
Radius in pixels for dragging a point or power handle. | |
static constexpr int | kResolution = 64 |
Resolution used for intermediate line calculations. | |
static constexpr int | kNumWrapPoints = 8 |
Number of wrap points for looping lines. | |
static constexpr int | kDrawPoints = kResolution + LineGenerator::kMaxPoints |
Number of points drawn: resolution plus max points from LineGenerator. | |
static constexpr int | kTotalPoints = kDrawPoints + 2 * kNumWrapPoints |
Total points including wrap-around. | |
static constexpr int | kMaxGridSizeX = 32 |
Maximum grid sizes for horizontal and vertical lines. | |
static constexpr int | kMaxGridSizeY = 24 |
static constexpr float | kPaddingY = 6.0f |
Vertical padding in pixels. | |
static constexpr float | kPaddingX = 0.0f |
Horizontal padding in pixels. | |
static constexpr float | kPowerMouseMultiplier = 9.0f |
Multiplier for mouse movements when adjusting power handles. | |
static constexpr float | kMinPointDistanceForPower = 3.0f |
Minimum horizontal distance (in pixels) between points to show power handles. | |
![]() | |
static constexpr int | kLineFloatsPerVertex = 3 |
Floats per vertex in the line data (x, y, and potentially others). | |
static constexpr int | kFillFloatsPerVertex = 4 |
Floats per vertex in the fill data (x, y, and boost value). | |
static constexpr int | kLineVerticesPerPoint = 6 |
Number of vertices per point in the line representation. | |
static constexpr int | kFillVerticesPerPoint = 2 |
Number of vertices per point in the fill representation. | |
static constexpr int | kLineFloatsPerPoint = kLineVerticesPerPoint * kLineFloatsPerVertex |
Floats per point in the line data (6 vertices * 3 floats each). | |
static constexpr int | kFillFloatsPerPoint = kFillVerticesPerPoint * kFillFloatsPerVertex |
Floats per point in the fill data (2 vertices * 4 floats each). | |
Additional Inherited Members | |
![]() | |
enum | MenuOptions { kCancel , kCopy , kPaste , kSave , kEnterPhase , kEnterValue , kResetPower , kRemovePoint , kInit , kFlipHorizontal , kFlipVertical , kNumMenuOptions } |
Context menu options available in the line editor. More... | |
![]() | |
static bool | setViewPort (Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl) |
Sets the OpenGL viewport to match a specified rectangle within a component. | |
static bool | setViewPort (Component *component, OpenGlWrapper &open_gl) |
Convenience overload that sets the viewport for the entire component's local bounds. | |
static void | setScissor (Component *component, OpenGlWrapper &open_gl) |
Sets the OpenGL scissor region to the entire component's local bounds. | |
static void | setScissorBounds (Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl) |
Sets the OpenGL scissor region to a specified rectangle within a component. | |
static std::unique_ptr< OpenGLShaderProgram::Uniform > | getUniform (const OpenGlWrapper &open_gl, const OpenGLShaderProgram &program, const char *name) |
Retrieves a uniform from the shader program if it exists. | |
static std::unique_ptr< OpenGLShaderProgram::Attribute > | getAttribute (const OpenGlWrapper &open_gl, const OpenGLShaderProgram &program, const char *name) |
Retrieves an attribute from the shader program if it exists. | |
static String | translateFragmentShader (const String &code) |
Translates a fragment shader code snippet to be compatible with the current GL version. | |
static String | translateVertexShader (const String &code) |
Translates a vertex shader code snippet to be compatible with the current GL version. | |
![]() | |
void | drawPosition (OpenGlWrapper &open_gl, Colour color, float fraction_x) |
Draws a position marker at a specific fraction of the X-axis. | |
void | setEditingCircleBounds () |
Sets bounds for the editing circles (hover and drag indicators). | |
void | setGridPositions () |
Calculates and sets positions for grid lines. | |
void | setPointPositions () |
Calculates and sets positions for point and power handle quads. | |
void | setGlPositions () |
Updates OpenGL buffers with the latest positions if needed. | |
int | getActivePoint () |
Gets the currently active point index. | |
int | getActivePower () |
Gets the currently active power handle index. | |
int | getActiveGridSection () |
Gets the currently active grid section index for painting. | |
bool | isPainting () |
Checks if painting mode is currently active. | |
bool | isPaintEnabled () |
Checks if paint mode is globally enabled. | |
vital::poly_float | adjustBoostPhase (vital::poly_float phase) |
Adjusts a given phase value for boost calculations. | |
virtual void | enableTemporaryPaintToggle (bool toggle) |
Temporarily enables or disables paint mode using a toggle (e.g., via a modifier key). | |
![]() | |
bool | setViewPort (OpenGlWrapper &open_gl) |
Sets the viewport for this component using the current OpenGlWrapper. | |
![]() | |
bool | active_ |
std::vector< Listener * > | listeners_ |
![]() | |
std::unique_ptr< OpenGlCorners > | corners_ |
Optional corners for rounded edges. | |
bool | only_bottom_corners_ |
Flag to round only the bottom corners. | |
Colour | background_color_ |
The background color of the component. | |
Colour | body_color_ |
The body color of the component. | |
const SynthSection * | parent_ |
Pointer to parent SynthSection for skin lookups. | |
Skin::SectionOverride | skin_override_ |
Skin override for custom appearance. | |
const vital::StatusOutput * | num_voices_readout_ |
StatusOutput for voice count lookups. | |
A specialized LineEditor that visualizes and optionally animates a line-to-value mapping.
The LineMapEditor displays a mapping function or curve and can animate it in real-time based on an input signal (for instance, a parameter or modulation source). It inherits from LineEditor and adds phase-based animation, allowing the visual curve to show a current position indicator that moves along the curve according to an input value.
LineMapEditor::LineMapEditor | ( | LineGenerator * | line_source, |
String | name ) |
Constructs the LineMapEditor.
line_source | The LineGenerator that provides the underlying line data. |
name | A name to identify this editor instance. |
|
virtual |
Destructor.
|
overridevirtual |
Called when the component’s parent hierarchy changes.
Used to find the parent SynthGuiInterface and locate the status output for raw input values, enabling the editor to animate according to that input.
Reimplemented from OpenGlComponent.
|
overridevirtual |
Renders the line map with optional animation.
open_gl | The OpenGL wrapper. |
animate | Whether to animate the line position based on incoming input. |
Reimplemented from LineEditor.
|
inline |
Enables or disables animation in the line map editor.
animate | True to animate; false otherwise. |
|
staticconstexpr |
Decay factor for reducing line boost effects over time (for animation smoothing).