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

A specialized OpenGL component for rendering various styles of buttons. More...

#include <synth_button.h>

Inheritance diagram for OpenGlButtonComponent:
OpenGlComponent

Public Types

enum  ButtonStyle {
  kTextButton , kJustText , kPowerButton , kUiButton ,
  kLightenButton , kNumButtonStyles
}
 Enumeration of different button styles. More...
 

Public Member Functions

 OpenGlButtonComponent (Button *button)
 
virtual void init (OpenGlWrapper &open_gl) override
 
void setColors ()
 Sets the colors based on the current style and Skin.
 
void renderTextButton (OpenGlWrapper &open_gl, bool animate)
 
void renderPowerButton (OpenGlWrapper &open_gl, bool animate)
 
void renderUiButton (OpenGlWrapper &open_gl, bool animate)
 
void renderLightenButton (OpenGlWrapper &open_gl, bool animate)
 
void incrementHover ()
 Increments or decrements the hover amount, smoothing the hover transitions.
 
virtual void render (OpenGlWrapper &open_gl, bool animate) override
 
void setText ()
 Sets the text displayed on the button.
 
void setDown (bool down)
 
void setHover (bool hover)
 
virtual void destroy (OpenGlWrapper &open_gl) override
 
void setJustification (Justification justification)
 
void setStyle (ButtonStyle style)
 
void setShowOnColors (bool show)
 
void setPrimaryUiButton (bool primary)
 
void paintBackground (Graphics &g) override
 Overrides the default background painting, does nothing as we paint with OpenGL.
 
OpenGlQuadbackground ()
 
PlainTextComponenttext ()
 
ButtonStyle style ()
 
- 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.
 
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.
 
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.
 
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.
 

Protected Attributes

ButtonStyle style_
 Current button style.
 
Button * button_
 Associated JUCE Button.
 
bool show_on_colors_
 True if showing on-colors when toggled on.
 
bool primary_ui_button_
 True if this is a primary UI button.
 
bool down_
 True if the button is pressed.
 
bool hover_
 True if the mouse is hovering over the button.
 
float hover_amount_
 A smoothed value for hover transitions.
 
OpenGlQuad background_
 Background quad for rendering button body.
 
PlainTextComponent text_
 Text component for rendering button label.
 
Colour on_color_
 
Colour on_pressed_color_
 
Colour on_hover_color_
 
Colour off_color_
 
Colour off_pressed_color_
 
Colour off_hover_color_
 
Colour background_color_
 
Colour body_color_
 
- 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.
 

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.
 

Detailed Description

A specialized OpenGL component for rendering various styles of buttons.

This component supports multiple styles (text button, just text, power button, UI button, lighten button) and changes its appearance based on hover, press, toggle state, and other parameters.

Member Enumeration Documentation

◆ ButtonStyle

Enumeration of different button styles.

Enumerator
kTextButton 
kJustText 
kPowerButton 
kUiButton 
kLightenButton 
kNumButtonStyles 

Constructor & Destructor Documentation

◆ OpenGlButtonComponent()

OpenGlButtonComponent::OpenGlButtonComponent ( Button * button)
inline

Constructor.

Parameters
buttonThe JUCE Button associated with this OpenGlButtonComponent.

Member Function Documentation

◆ background()

OpenGlQuad & OpenGlButtonComponent::background ( )
inline

Gets the background quad component.

Returns
A reference to the OpenGlQuad used for the button background.

◆ destroy()

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

Destroys the OpenGL resources associated with this component.

Parameters
open_glThe OpenGlWrapper managing OpenGL state.

Reimplemented from OpenGlComponent.

◆ incrementHover()

void OpenGlButtonComponent::incrementHover ( )

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

Smoothly increments or decrements the hover amount for OpenGlButtonComponent.

◆ init()

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

Initializes the OpenGL resources for this component.

Parameters
open_glThe OpenGlWrapper for managing OpenGL state.

Reimplemented from OpenGlComponent.

◆ paintBackground()

void OpenGlButtonComponent::paintBackground ( Graphics & g)
inlineoverridevirtual

Overrides the default background painting, does nothing as we paint with OpenGL.

Reimplemented from OpenGlComponent.

◆ render()

virtual void OpenGlButtonComponent::render ( OpenGlWrapper & open_gl,
bool animate )
inlineoverridevirtual

Renders the button based on its current style.

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

Implements OpenGlComponent.

◆ renderLightenButton()

void OpenGlButtonComponent::renderLightenButton ( OpenGlWrapper & open_gl,
bool animate )

Renders the button as a lighten button.

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

Renders a lighten button.

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

◆ renderPowerButton()

void OpenGlButtonComponent::renderPowerButton ( OpenGlWrapper & open_gl,
bool animate )

Renders the button as a power button.

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

Renders a power button.

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

◆ renderTextButton()

void OpenGlButtonComponent::renderTextButton ( OpenGlWrapper & open_gl,
bool animate )

Renders the button as a text button.

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

Renders a text-based button.

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

◆ renderUiButton()

void OpenGlButtonComponent::renderUiButton ( OpenGlWrapper & open_gl,
bool animate )

Renders the button as a UI button.

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

Renders a UI button.

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

◆ setColors()

void OpenGlButtonComponent::setColors ( )

Sets the colors based on the current style and Skin.

Sets colors for the OpenGlButtonComponent based on its style and the current Skin.

◆ setDown()

void OpenGlButtonComponent::setDown ( bool down)
inline

Sets the pressed state.

Parameters
downTrue if the button is currently pressed.

◆ setHover()

void OpenGlButtonComponent::setHover ( bool hover)
inline

Sets the hover state.

Parameters
hoverTrue if the mouse is hovering over the button.

◆ setJustification()

void OpenGlButtonComponent::setJustification ( Justification justification)
inline

Sets the text justification mode.

Parameters
justificationThe JUCE Justification mode.

◆ setPrimaryUiButton()

void OpenGlButtonComponent::setPrimaryUiButton ( bool primary)
inline

Sets whether this is a primary UI button.

Parameters
primaryTrue if primary, otherwise false.

◆ setShowOnColors()

void OpenGlButtonComponent::setShowOnColors ( bool show)
inline

Toggles whether to show on-colors when toggled on.

Parameters
showTrue to show on-colors, false otherwise.

◆ setStyle()

void OpenGlButtonComponent::setStyle ( ButtonStyle style)
inline

Sets the button style.

Parameters
styleThe style to use.

◆ setText()

void OpenGlButtonComponent::setText ( )
inline

Sets the text displayed on the button.

◆ style()

ButtonStyle OpenGlButtonComponent::style ( )
inline

Gets the current button style.

Returns
The current ButtonStyle.

◆ text()

PlainTextComponent & OpenGlButtonComponent::text ( )
inline

Gets the text component.

Returns
A reference to the PlainTextComponent used for the button text.

Member Data Documentation

◆ background_

OpenGlQuad OpenGlButtonComponent::background_
protected

Background quad for rendering button body.

◆ background_color_

Colour OpenGlButtonComponent::background_color_
protected

◆ body_color_

Colour OpenGlButtonComponent::body_color_
protected

◆ button_

Button* OpenGlButtonComponent::button_
protected

Associated JUCE Button.

◆ down_

bool OpenGlButtonComponent::down_
protected

True if the button is pressed.

◆ hover_

bool OpenGlButtonComponent::hover_
protected

True if the mouse is hovering over the button.

◆ hover_amount_

float OpenGlButtonComponent::hover_amount_
protected

A smoothed value for hover transitions.

◆ kHoverInc

float OpenGlButtonComponent::kHoverInc = 0.2f
staticconstexpr

The amount of change in hover transition per frame.

◆ off_color_

Colour OpenGlButtonComponent::off_color_
protected

◆ off_hover_color_

Colour OpenGlButtonComponent::off_hover_color_
protected

◆ off_pressed_color_

Colour OpenGlButtonComponent::off_pressed_color_
protected

◆ on_color_

Colour OpenGlButtonComponent::on_color_
protected

◆ on_hover_color_

Colour OpenGlButtonComponent::on_hover_color_
protected

◆ on_pressed_color_

Colour OpenGlButtonComponent::on_pressed_color_
protected

◆ primary_ui_button_

bool OpenGlButtonComponent::primary_ui_button_
protected

True if this is a primary UI button.

◆ show_on_colors_

bool OpenGlButtonComponent::show_on_colors_
protected

True if showing on-colors when toggled on.

◆ style_

ButtonStyle OpenGlButtonComponent::style_
protected

Current button style.

◆ text_

PlainTextComponent OpenGlButtonComponent::text_
protected

Text component for rendering button label.


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