Vital
|
A base component class that integrates JUCE's Component with OpenGL rendering. More...
#include <open_gl_component.h>
Public Member Functions | |
OpenGlComponent (String name="") | |
Constructs an OpenGlComponent. | |
virtual | ~OpenGlComponent () |
Destructor. | |
virtual void | resized () override |
Called when the component is resized. | |
virtual void | parentHierarchyChanged () override |
Called when the component's parent hierarchy changes. | |
void | addRoundedCorners () |
Adds rounded corners to the component's edges. | |
void | addBottomRoundedCorners () |
Adds rounded corners only at the bottom of the component. | |
virtual void | init (OpenGlWrapper &open_gl) |
Initializes any OpenGL-specific resources needed by the component. | |
virtual void | render (OpenGlWrapper &open_gl, bool animate)=0 |
Pure virtual function to render the component using OpenGL. | |
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 | destroy (OpenGlWrapper &open_gl) |
Destroys any OpenGL-specific resources allocated by this component. | |
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 Member Functions | |
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. | |
Protected Member Functions | |
bool | setViewPort (OpenGlWrapper &open_gl) |
Sets the viewport for this component using the current OpenGlWrapper. | |
Protected Attributes | |
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 base component class that integrates JUCE's Component with OpenGL rendering.
The OpenGlComponent class acts as a foundation for GUI elements that require OpenGL rendering. It provides utility functions to set the viewport and scissor bounds, handle parent hierarchy changes, manage OpenGL corners (rounded rectangles), and integrate skin values from a parent SynthSection. Derived classes can override the rendering functions to draw custom visuals using OpenGL.
OpenGlComponent::OpenGlComponent | ( | String | name = "" | ) |
Constructs an OpenGlComponent.
name | Optional name for the component. |
|
virtual |
Destructor.
void OpenGlComponent::addBottomRoundedCorners | ( | ) |
Adds rounded corners only at the bottom of the component.
void OpenGlComponent::addRoundedCorners | ( | ) |
Adds rounded corners to the component's edges.
|
inline |
Checks for and asserts that there are no OpenGL errors.
|
virtual |
Destroys any OpenGL-specific resources allocated by this component.
open_gl | The OpenGlWrapper with the current OpenGL context. |
Reimplemented in BarEditor, BarRenderer, CompressorEditor, DistortionFilterResponse, EnvelopeEditor, EqualizerResponse, FilterResponse, FlangerResponse, LineEditor, MidiKeyboard, OpenGlButtonComponent, OpenGlImageComponent, OpenGlLineRenderer, OpenGlMultiImage, OpenGlMultiQuad, OpenGlShapeButtonComponent, OverlayBackgroundRenderer, PeakMeterViewer, PhaserResponse, RandomViewer, SampleViewer, WaveSourceEditor, Wavetable3d, and WaveWindowEditor.
float OpenGlComponent::findValue | ( | Skin::ValueId | value_id | ) |
Finds a float value from the skin associated with this component's parent.
value_id | The Skin::ValueId to lookup. |
|
inlinestatic |
Retrieves an attribute from the shader program if it exists.
open_gl | The OpenGlWrapper containing the GL context. |
program | The shader program to query. |
name | The name of the attribute variable. |
|
inline |
Retrieves the component's body color.
|
inlinestatic |
Retrieves a uniform from the shader program if it exists.
open_gl | The OpenGlWrapper containing the GL context. |
program | The shader program to query. |
name | The name of the uniform variable. |
|
virtual |
Initializes any OpenGL-specific resources needed by the component.
open_gl | The OpenGlWrapper with the current OpenGL context and shaders. |
Reimplemented in BarEditor, BarRenderer, CompressorEditor, DistortionFilterResponse, EnvelopeEditor, EqualizerResponse, FilterResponse, FlangerResponse, LineEditor, MidiKeyboard, OpenGlButtonComponent, OpenGlImageComponent, OpenGlLineRenderer, OpenGlMultiImage, OpenGlMultiQuad, OpenGlShapeButtonComponent, OpenGlSliderQuad, OverlayBackgroundRenderer, PeakMeterViewer, PhaserResponse, RandomViewer, SampleViewer, WaveSourceEditor, Wavetable3d, and WaveWindowEditor.
|
virtual |
Paints a standard background for the component.
g | The graphics context. |
Reimplemented in CompressorEditor, EnvelopeEditor, EqualizerResponse, FilterResponse, MidiKeyboard, ModulationButton, ModulationMeterReadouts, OpenGlButtonComponent, OpenGlImageComponent, OpenGlMultiImage, OpenGlMultiQuad, OpenGlSliderQuad, OverlayBackgroundRenderer, PeakMeterViewer, RandomViewer, Spectrogram, SpreadVisualizer, SynthSection::OffOverlay, TransposeQuantizeButton, WaveSourceEditor, Wavetable3d, and WaveWindowEditor.
|
overridevirtual |
Called when the component's parent hierarchy changes.
Used to retrieve parent references (like num_voices_readout_ from SynthGuiInterface).
Reimplemented in ChorusViewer, CompressorEditor, EnvelopeEditor, LfoEditor, LineMapEditor, MidiKeyboard, ModulationButton, ModulationMeterReadouts, OpenGlShapeButtonComponent, and RandomViewer.
|
pure virtual |
Pure virtual function to render the component using OpenGL.
open_gl | The OpenGlWrapper with the current OpenGL context. |
animate | If true, the rendering might include animations. |
Implemented in BarEditor, BarRenderer, ChorusViewer, CompressorEditor, DelayFilterViewer, DelayViewer, DistortionFilterResponse, DistortionViewer, EnvelopeEditor, EqualizerResponse, FilterResponse, FlangerResponse, LfoEditor, LineEditor, LineMapEditor, LoadingWheel, MidiKeyboard, ModulationButton, ModulationMeterReadouts, OpenGlButtonComponent, OpenGlImageComponent, OpenGlLineRenderer, OpenGlMultiImage, OpenGlMultiQuad, OpenGlScrollQuad, OpenGlShapeButtonComponent, Oscilloscope, OverlayBackgroundRenderer, PeakMeterViewer, PhaseEditor, PhaserResponse, RandomViewer, SampleViewer, Spectrogram, SpreadVisualizer, UnisonViewer, WaveSourceEditor, Wavetable3d, and WaveWindowEditor.
void OpenGlComponent::renderCorners | ( | OpenGlWrapper & | open_gl, |
bool | animate ) |
Renders corners with default body color and rounding.
open_gl | The OpenGlWrapper for OpenGL context. |
animate | If true, enable animated rendering. |
void OpenGlComponent::renderCorners | ( | OpenGlWrapper & | open_gl, |
bool | animate, | ||
Colour | color, | ||
float | rounding ) |
Renders the corner shapes using the given color and rounding amount.
open_gl | The OpenGlWrapper for OpenGL context. |
animate | If true, enable animated rendering. |
color | The color to draw the corners. |
rounding | The rounding radius for corners. |
void OpenGlComponent::repaintBackground | ( | ) |
Requests a repaint of the component's background on the OpenGL layer.
|
overridevirtual |
Called when the component is resized.
Adjusts internal states or sub-components (like corners).
Reimplemented in BarEditor, CompressorEditor, EnvelopeEditor, EqualizerResponse, LineEditor, LoadingWheel, MidiKeyboard, ModulationButton, OpenGlMultiImage, OpenGlMultiQuad, PeakMeterViewer, PlainTextComponent, RandomViewer, SampleViewer, TransposeQuantizeButton, WaveSourceEditor, Wavetable3d, and WaveWindowEditor.
|
inline |
Sets the background color of the component for painting operations.
color | The new background color. |
|
inline |
Sets a pointer to the parent SynthSection for skin value lookups.
parent | The parent SynthSection. |
|
static |
Sets the OpenGL scissor region to the entire component's local bounds.
component | The component for which the scissor is being set. |
open_gl | The OpenGlWrapper with the OpenGL context. |
|
static |
Sets the OpenGL scissor region to a specified rectangle within a component.
component | The component for which the scissor is being set. |
bounds | The local bounds to restrict rendering to. |
open_gl | The OpenGlWrapper with the OpenGL context. |
|
inline |
Sets a skin override to control the component's color scheme.
skin_override | The skin override enum value. |
|
inline |
Applies the skin overrides to this component's colors.
skin | The Skin object containing color definitions. |
|
static |
Convenience overload that sets the viewport for the entire component's local bounds.
component | The component to set the viewport for. |
open_gl | The OpenGlWrapper with the OpenGL context. |
|
static |
Sets the OpenGL viewport to match a specified rectangle within a component.
This function calculates the global position of the given bounds inside the component's hierarchy and sets the OpenGL viewport and scissor regions accordingly.
component | The component for which the viewport is being set. |
bounds | The local bounds within the component to set as the viewport. |
open_gl | The OpenGlWrapper that holds the OpenGL context and scaling factors. |
|
protected |
Sets the viewport for this component using the current OpenGlWrapper.
open_gl | The OpenGlWrapper providing the OpenGL context. |
|
inlinestatic |
Translates a fragment shader code snippet to be compatible with the current GL version.
code | The original shader code. |
|
inlinestatic |
Translates a vertex shader code snippet to be compatible with the current GL version.
code | The original shader code. |
|
protected |
The background color of the component.
|
protected |
The body color of the component.
|
protected |
Optional corners for rounded edges.
|
protected |
StatusOutput for voice count lookups.
|
protected |
Flag to round only the bottom corners.
|
protected |
Pointer to parent SynthSection for skin lookups.
|
protected |
Skin override for custom appearance.