Vital
Loading...
Searching...
No Matches
OpenGlShapeButtonComponent Class Reference

A specialized OpenGL component for rendering a shape-based button. More...

#include <synth_button.h>

Inheritance diagram for OpenGlShapeButtonComponent:
OpenGlComponent

Public Member Functions

 OpenGlShapeButtonComponent (Button *button)
 
void parentHierarchyChanged () override
 Called when the parent hierarchy changes, for example when the component is moved in the UI.
 
void setColors ()
 Sets the colors used for this shape button based on the current Skin.
 
void incrementHover ()
 Increments or decrements the hover amount, smoothing the hover transitions.
 
virtual void init (OpenGlWrapper &open_gl) override
 
virtual void render (OpenGlWrapper &open_gl, bool animate) override
 
virtual void destroy (OpenGlWrapper &open_gl) override
 
void redoImage ()
 Redraws the image of the shape, useful after size or color changes.
 
void setShape (const Path &shape)
 
void useOnColors (bool use)
 
void setDown (bool down)
 
void setHover (bool hover)
 
- Public Member Functions inherited from OpenGlComponent
 OpenGlComponent (String name="")
 Constructs an OpenGlComponent.
 
virtual ~OpenGlComponent ()
 Destructor.
 
virtual void resized () override
 Called when the component is resized.
 
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 kHoverInc = 0.2f
 The amount of change in hover transition per frame.
 

Additional Inherited Members

- Static Public Member Functions inherited from OpenGlComponent
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 inherited from OpenGlComponent
bool setViewPort (OpenGlWrapper &open_gl)
 Sets the viewport for this component using the current OpenGlWrapper.
 
- Protected Attributes inherited from OpenGlComponent
std::unique_ptr< OpenGlCornerscorners_
 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 SynthSectionparent_
 Pointer to parent SynthSection for skin lookups.
 
Skin::SectionOverride skin_override_
 Skin override for custom appearance.
 
const vital::StatusOutputnum_voices_readout_
 StatusOutput for voice count lookups.
 

Detailed Description

A specialized OpenGL component for rendering a shape-based button.

This component displays a shape (path) that changes color and appearance based on hover and pressed states. It is intended to be used in conjunction with a JUCE Button.

Constructor & Destructor Documentation

◆ OpenGlShapeButtonComponent()

OpenGlShapeButtonComponent::OpenGlShapeButtonComponent ( Button * button)
inline

Constructor.

Parameters
buttonThe JUCE Button associated with this shape component.

Member Function Documentation

◆ destroy()

virtual void OpenGlShapeButtonComponent::destroy ( OpenGlWrapper & open_gl)
inlineoverridevirtual

Destroys OpenGL resources associated with this component.

Parameters
open_glThe OpenGlWrapper managing OpenGL state.

Reimplemented from OpenGlComponent.

◆ incrementHover()

void OpenGlShapeButtonComponent::incrementHover ( )

Increments or decrements the hover amount, smoothing the hover transitions.

Smoothly increments or decrements the hover amount to create a fade effect.

◆ init()

virtual void OpenGlShapeButtonComponent::init ( OpenGlWrapper & open_gl)
inlineoverridevirtual

Initializes the OpenGL resources for this component.

Parameters
open_glThe OpenGlWrapper managing OpenGL state.

Reimplemented from OpenGlComponent.

◆ parentHierarchyChanged()

void OpenGlShapeButtonComponent::parentHierarchyChanged ( )
inlineoverridevirtual

Called when the parent hierarchy changes, for example when the component is moved in the UI.

Reimplemented from OpenGlComponent.

◆ redoImage()

void OpenGlShapeButtonComponent::redoImage ( )
inline

Redraws the image of the shape, useful after size or color changes.

◆ render()

void OpenGlShapeButtonComponent::render ( OpenGlWrapper & open_gl,
bool animate )
overridevirtual

Renders the shape component.

Parameters
open_glThe OpenGlWrapper managing OpenGL state.
animateIf true, animates transitions like hover.

Renders the OpenGlShapeButtonComponent using current hover and pressed states.

Parameters
open_glThe OpenGlWrapper managing OpenGL state.
animateIf true, animates transitions.

Implements OpenGlComponent.

◆ setColors()

void OpenGlShapeButtonComponent::setColors ( )
inline

Sets the colors used for this shape button based on the current Skin.

◆ setDown()

void OpenGlShapeButtonComponent::setDown ( bool down)
inline

Sets the pressed state.

Parameters
downTrue if the button is pressed down.

◆ setHover()

void OpenGlShapeButtonComponent::setHover ( bool hover)
inline

Sets the hover state.

Parameters
hoverTrue if the mouse is hovering over the button.

◆ setShape()

void OpenGlShapeButtonComponent::setShape ( const Path & shape)
inline

Sets the shape (path) to be rendered by this component.

Parameters
shapeThe new path representing the shape.

◆ useOnColors()

void OpenGlShapeButtonComponent::useOnColors ( bool use)
inline

Toggles whether the "on" colors should be used (for toggled states).

Parameters
useIf true, uses the on-colors, otherwise uses off-colors.

Member Data Documentation

◆ kHoverInc

float OpenGlShapeButtonComponent::kHoverInc = 0.2f
staticconstexpr

The amount of change in hover transition per frame.


The documentation for this class was generated from the following files: