Vital
|
A specialized OpenGL component for rendering various styles of buttons. More...
#include <synth_button.h>
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. | |
OpenGlQuad & | background () |
PlainTextComponent & | text () |
ButtonStyle | style () |
![]() | |
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_ |
![]() | |
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. | |
Additional Inherited Members | |
![]() | |
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. | |
![]() | |
bool | setViewPort (OpenGlWrapper &open_gl) |
Sets the viewport for this component using the current OpenGlWrapper. | |
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.
|
inline |
Constructor.
button | The JUCE Button associated with this OpenGlButtonComponent. |
|
inline |
Gets the background quad component.
|
inlineoverridevirtual |
Destroys the OpenGL resources associated with this component.
open_gl | The OpenGlWrapper managing OpenGL state. |
Reimplemented from OpenGlComponent.
void OpenGlButtonComponent::incrementHover | ( | ) |
Increments or decrements the hover amount, smoothing the hover transitions.
Smoothly increments or decrements the hover amount for OpenGlButtonComponent.
|
inlineoverridevirtual |
Initializes the OpenGL resources for this component.
open_gl | The OpenGlWrapper for managing OpenGL state. |
Reimplemented from OpenGlComponent.
|
inlineoverridevirtual |
Overrides the default background painting, does nothing as we paint with OpenGL.
Reimplemented from OpenGlComponent.
|
inlineoverridevirtual |
Renders the button based on its current style.
open_gl | The OpenGlWrapper for managing OpenGL state. |
animate | If true, animates transitions. |
Implements OpenGlComponent.
void OpenGlButtonComponent::renderLightenButton | ( | OpenGlWrapper & | open_gl, |
bool | animate ) |
Renders the button as a lighten button.
open_gl | The OpenGlWrapper for managing OpenGL state. |
animate | If true, animates transitions. |
Renders a lighten button.
open_gl | The OpenGlWrapper for managing OpenGL state. |
animate | If true, animates transitions. |
void OpenGlButtonComponent::renderPowerButton | ( | OpenGlWrapper & | open_gl, |
bool | animate ) |
Renders the button as a power button.
open_gl | The OpenGlWrapper for managing OpenGL state. |
animate | If true, animates transitions. |
Renders a power button.
open_gl | The OpenGlWrapper for managing OpenGL state. |
animate | If true, animates transitions. |
void OpenGlButtonComponent::renderTextButton | ( | OpenGlWrapper & | open_gl, |
bool | animate ) |
Renders the button as a text button.
open_gl | The OpenGlWrapper for managing OpenGL state. |
animate | If true, animates transitions. |
Renders a text-based button.
open_gl | The OpenGlWrapper for managing OpenGL state. |
animate | If true, animates transitions. |
void OpenGlButtonComponent::renderUiButton | ( | OpenGlWrapper & | open_gl, |
bool | animate ) |
Renders the button as a UI button.
open_gl | The OpenGlWrapper for managing OpenGL state. |
animate | If true, animates transitions. |
Renders a UI button.
open_gl | The OpenGlWrapper for managing OpenGL state. |
animate | If true, animates transitions. |
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.
|
inline |
Sets the pressed state.
down | True if the button is currently pressed. |
|
inline |
Sets the hover state.
hover | True if the mouse is hovering over the button. |
|
inline |
Sets the text justification mode.
justification | The JUCE Justification mode. |
|
inline |
Sets whether this is a primary UI button.
primary | True if primary, otherwise false. |
|
inline |
Toggles whether to show on-colors when toggled on.
show | True to show on-colors, false otherwise. |
|
inline |
Sets the button style.
style | The style to use. |
|
inline |
Sets the text displayed on the button.
|
inline |
Gets the current button style.
|
inline |
Gets the text component.
|
protected |
Background quad for rendering button body.
|
protected |
|
protected |
|
protected |
Associated JUCE Button.
|
protected |
True if the button is pressed.
|
protected |
True if the mouse is hovering over the button.
|
protected |
A smoothed value for hover transitions.
|
staticconstexpr |
The amount of change in hover transition per frame.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
True if this is a primary UI button.
|
protected |
True if showing on-colors when toggled on.
|
protected |
Current button style.
|
protected |
Text component for rendering button label.