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

Manages the overall color and value theme (or "skin") of the user interface. More...

#include <skin.h>

Public Types

enum  SectionOverride {
  kNone , kLogo , kHeader , kOverlay ,
  kOscillator , kSample , kSub , kFilter ,
  kEnvelope , kLfo , kRandomLfo , kVoice ,
  kMacro , kKeyboard , kAllEffects , kChorus ,
  kCompressor , kDelay , kDistortion , kEqualizer ,
  kFxFilter , kFlanger , kPhaser , kReverb ,
  kModulationDragDrop , kModulationMatrix , kPresetBrowser , kPopupBrowser ,
  kAdvanced , kWavetableEditor , kNumSectionOverrides
}
 Identifiers for different UI sections that can have color or value overrides. More...
 
enum  ValueId {
  kBodyRounding , kLabelHeight , kLabelBackgroundHeight , kLabelBackgroundRounding ,
  kLabelOffset , kTextComponentLabelOffset , kRotaryOptionXOffset , kRotaryOptionYOffset ,
  kRotaryOptionWidth , kTitleWidth , kPadding , kLargePadding ,
  kSliderWidth , kTextComponentHeight , kTextComponentOffset , kTextComponentFontSize ,
  kTextButtonHeight , kButtonFontSize , kKnobArcSize , kKnobArcThickness ,
  kKnobBodySize , kKnobHandleLength , kKnobModAmountArcSize , kKnobModAmountArcThickness ,
  kKnobModMeterArcSize , kKnobModMeterArcThickness , kKnobOffset , kKnobSectionHeight ,
  kKnobShadowWidth , kKnobShadowOffset , kModulationButtonWidth , kModulationFontSize ,
  kWidgetMargin , kWidgetRoundedCorner , kWidgetLineWidth , kWidgetLineBoost ,
  kWidgetFillCenter , kWidgetFillFade , kWidgetFillBoost , kWavetableHorizontalAngle ,
  kWavetableVerticalAngle , kWavetableDrawWidth , kWavetableWaveHeight , kWavetableYOffset ,
  kNumSkinValueIds , kFrequencyDisplay = kNumSkinValueIds , kNumAllValueIds
}
 Identifiers for various UI scaling/spacing values and configuration constants. More...
 
enum  ColorId {
  kInitialColor = 0x42345678 , kBackground = kInitialColor , kBody , kBodyHeading ,
  kHeadingText , kPresetText , kBodyText , kBorder ,
  kLabelBackground , kLabelConnection , kPowerButtonOn , kPowerButtonOff ,
  kOverlayScreen , kLightenScreen , kShadow , kPopupSelectorBackground ,
  kPopupBackground , kPopupBorder , kTextComponentBackground , kTextComponentText ,
  kRotaryArc , kRotaryArcDisabled , kRotaryArcUnselected , kRotaryArcUnselectedDisabled ,
  kRotaryHand , kRotaryBody , kRotaryBodyBorder , kLinearSlider ,
  kLinearSliderDisabled , kLinearSliderUnselected , kLinearSliderThumb , kLinearSliderThumbDisabled ,
  kWidgetCenterLine , kWidgetPrimary1 , kWidgetPrimary2 , kWidgetPrimaryDisabled ,
  kWidgetSecondary1 , kWidgetSecondary2 , kWidgetSecondaryDisabled , kWidgetAccent1 ,
  kWidgetAccent2 , kWidgetBackground , kModulationMeter , kModulationMeterLeft ,
  kModulationMeterRight , kModulationMeterControl , kModulationButtonSelected , kModulationButtonDragging ,
  kModulationButtonUnselected , kIconSelectorIcon , kIconButtonOff , kIconButtonOffHover ,
  kIconButtonOffPressed , kIconButtonOn , kIconButtonOnHover , kIconButtonOnPressed ,
  kUiButton , kUiButtonText , kUiButtonHover , kUiButtonPressed ,
  kUiActionButton , kUiActionButtonHover , kUiActionButtonPressed , kTextEditorBackground ,
  kTextEditorBorder , kTextEditorCaret , kTextEditorSelection , kFinalColor
}
 Identifiers for all colors used in the UI. More...
 

Public Member Functions

 Skin ()
 Constructs a Skin with default or loaded settings.
 
void setComponentColors (Component *component) const
 Applies all component colors to a given component.
 
void setComponentColors (Component *component, SectionOverride section_override, bool top_level=false) const
 Applies section-specific color overrides to a component.
 
void setComponentValues (SynthSection *component) const
 Applies all default values to a SynthSection.
 
void setComponentValues (SynthSection *component, SectionOverride section_override, bool top_level=false) const
 Applies section-specific value overrides to a SynthSection.
 
void setColor (ColorId color_id, const Colour &color)
 Sets a color for a global ColorId.
 
Colour getColor (ColorId color_id) const
 Retrieves a globally defined color.
 
Colour getColor (int section, ColorId color_id) const
 Retrieves a color possibly overridden by a section.
 
bool overridesColor (int section, ColorId color_id) const
 Checks if a given section overrides a specific color.
 
bool overridesValue (int section, ValueId value_id) const
 Checks if a given section overrides a specific value.
 
void copyValuesToLookAndFeel (LookAndFeel *look_and_feel) const
 Copies global skin values into a LookAndFeel instance.
 
void setValue (ValueId value_id, float value)
 Sets a global UI value.
 
float getValue (ValueId value_id) const
 Gets a global UI value.
 
float getValue (int section, ValueId value_id) const
 Gets a value with a possible section override.
 
void addOverrideColor (int section, ColorId color_id, Colour color)
 Adds a color override for a given section.
 
void removeOverrideColor (int section, ColorId color_id)
 Removes a color override from a section.
 
void addOverrideValue (int section, ValueId value_id, float value)
 Adds a value override for a given section.
 
void removeOverrideValue (int section, ValueId value_id)
 Removes a value override from a section.
 
json stateToJson ()
 Converts the current skin state to JSON.
 
String stateToString ()
 Converts the current skin state to a string (JSON representation).
 
void saveToFile (File destination)
 Saves the current skin to a file.
 
json updateJson (json data)
 Updates JSON data to a newer format or version if needed.
 
void jsonToState (json skin_var)
 Loads skin state from JSON data.
 
bool stringToState (String skin_string)
 Loads skin state from a JSON string.
 
bool loadFromFile (File source)
 Loads skin state from a file.
 
void loadDefaultSkin ()
 Loads a default built-in skin.
 
void clearSkin ()
 Clears all overrides, returning to a clean default state.
 

Static Public Member Functions

static bool shouldScaleValue (ValueId value_id)
 Checks if a certain ValueId should be scaled by the display ratio.
 

Static Public Attributes

static constexpr int kNumColors = kFinalColor - kInitialColor
 

Protected Attributes

Colour colors_ [kNumColors]
 Array of global colors.
 
float values_ [kNumSkinValueIds]
 Array of global float values.
 
std::map< ColorId, Colour > color_overrides_ [kNumSectionOverrides]
 Per-section color overrides.
 
std::map< ValueId, float > value_overrides_ [kNumSectionOverrides]
 Per-section value overrides.
 

Detailed Description

Manages the overall color and value theme (or "skin") of the user interface.

The Skin class stores a variety of colors and values that determine the appearance and layout of UI components. It supports section-based overrides, allowing different interface sections (e.g., Oscillator, Filter, Envelope) to have unique colors or values if desired.

The skin information can be serialized to and from JSON, allowing customization and saving of user-defined skins. It also integrates with JUCE's LookAndFeel system, applying colors and values to components and ensuring consistent UI styling.

Member Enumeration Documentation

◆ ColorId

Identifiers for all colors used in the UI.

Each color maps to a JUCE ColourId on components or is used directly when drawing.

Enumerator
kInitialColor 
kBackground 
kBody 
kBodyHeading 
kHeadingText 
kPresetText 
kBodyText 
kBorder 
kLabelBackground 
kLabelConnection 
kPowerButtonOn 
kPowerButtonOff 
kOverlayScreen 
kLightenScreen 
kShadow 
kPopupSelectorBackground 
kPopupBackground 
kPopupBorder 
kTextComponentBackground 
kTextComponentText 
kRotaryArc 
kRotaryArcDisabled 
kRotaryArcUnselected 
kRotaryArcUnselectedDisabled 
kRotaryHand 
kRotaryBody 
kRotaryBodyBorder 
kLinearSlider 
kLinearSliderDisabled 
kLinearSliderUnselected 
kLinearSliderThumb 
kLinearSliderThumbDisabled 
kWidgetCenterLine 
kWidgetPrimary1 
kWidgetPrimary2 
kWidgetPrimaryDisabled 
kWidgetSecondary1 
kWidgetSecondary2 
kWidgetSecondaryDisabled 
kWidgetAccent1 
kWidgetAccent2 
kWidgetBackground 
kModulationMeter 
kModulationMeterLeft 
kModulationMeterRight 
kModulationMeterControl 
kModulationButtonSelected 
kModulationButtonDragging 
kModulationButtonUnselected 
kIconSelectorIcon 
kIconButtonOff 
kIconButtonOffHover 
kIconButtonOffPressed 
kIconButtonOn 
kIconButtonOnHover 
kIconButtonOnPressed 
kUiButton 
kUiButtonText 
kUiButtonHover 
kUiButtonPressed 
kUiActionButton 
kUiActionButtonHover 
kUiActionButtonPressed 
kTextEditorBackground 
kTextEditorBorder 
kTextEditorCaret 
kTextEditorSelection 
kFinalColor 

◆ SectionOverride

Identifiers for different UI sections that can have color or value overrides.

Enumerator
kNone 
kLogo 
kHeader 
kOverlay 
kOscillator 
kSample 
kSub 
kFilter 
kEnvelope 
kLfo 
kRandomLfo 
kVoice 
kMacro 
kKeyboard 
kAllEffects 
kChorus 
kCompressor 
kDelay 
kDistortion 
kEqualizer 
kFxFilter 
kFlanger 
kPhaser 
kReverb 
kModulationDragDrop 
kModulationMatrix 
kPresetBrowser 
kPopupBrowser 
kAdvanced 
kWavetableEditor 
kNumSectionOverrides 

◆ ValueId

Identifiers for various UI scaling/spacing values and configuration constants.

These values control dimensions, rounding, padding, text sizes, knob sizes, etc.

Enumerator
kBodyRounding 
kLabelHeight 
kLabelBackgroundHeight 
kLabelBackgroundRounding 
kLabelOffset 
kTextComponentLabelOffset 
kRotaryOptionXOffset 
kRotaryOptionYOffset 
kRotaryOptionWidth 
kTitleWidth 
kPadding 
kLargePadding 
kSliderWidth 
kTextComponentHeight 
kTextComponentOffset 
kTextComponentFontSize 
kTextButtonHeight 
kButtonFontSize 
kKnobArcSize 
kKnobArcThickness 
kKnobBodySize 
kKnobHandleLength 
kKnobModAmountArcSize 
kKnobModAmountArcThickness 
kKnobModMeterArcSize 
kKnobModMeterArcThickness 
kKnobOffset 
kKnobSectionHeight 
kKnobShadowWidth 
kKnobShadowOffset 
kModulationButtonWidth 
kModulationFontSize 
kWidgetMargin 
kWidgetRoundedCorner 
kWidgetLineWidth 
kWidgetLineBoost 
kWidgetFillCenter 
kWidgetFillFade 
kWidgetFillBoost 
kWavetableHorizontalAngle 
kWavetableVerticalAngle 
kWavetableDrawWidth 
kWavetableWaveHeight 
kWavetableYOffset 
kNumSkinValueIds 
kFrequencyDisplay 
kNumAllValueIds 

Constructor & Destructor Documentation

◆ Skin()

Skin::Skin ( )

Constructs a Skin with default or loaded settings.

If a default skin file is found, it is loaded. Otherwise, a built-in default is used.

Member Function Documentation

◆ addOverrideColor()

void Skin::addOverrideColor ( int section,
ColorId color_id,
Colour color )

Adds a color override for a given section.

Parameters
sectionThe section ID.
color_idThe color to override.
colorThe override color.

◆ addOverrideValue()

void Skin::addOverrideValue ( int section,
ValueId value_id,
float value )

Adds a value override for a given section.

Parameters
sectionThe section ID.
value_idThe value to override.
valueThe override value.

◆ clearSkin()

void Skin::clearSkin ( )

Clears all overrides, returning to a clean default state.

◆ copyValuesToLookAndFeel()

void Skin::copyValuesToLookAndFeel ( LookAndFeel * look_and_feel) const

Copies global skin values into a LookAndFeel instance.

Parameters
look_and_feelThe LookAndFeel to populate.

◆ getColor() [1/2]

Colour Skin::getColor ( ColorId color_id) const
inline

Retrieves a globally defined color.

Parameters
color_idThe color identifier.
Returns
The Colour object for the given identifier.

◆ getColor() [2/2]

Colour Skin::getColor ( int section,
ColorId color_id ) const

Retrieves a color possibly overridden by a section.

Parameters
sectionThe section override ID.
color_idThe color identifier.
Returns
The Colour object for the given section and color ID.

◆ getValue() [1/2]

float Skin::getValue ( int section,
ValueId value_id ) const

Gets a value with a possible section override.

Parameters
sectionThe section override ID.
value_idThe value identifier.
Returns
The overridden or default value.

◆ getValue() [2/2]

float Skin::getValue ( ValueId value_id) const
inline

Gets a global UI value.

Parameters
value_idThe value identifier.
Returns
The current float value for that ID.

◆ jsonToState()

void Skin::jsonToState ( json skin_var)

Loads skin state from JSON data.

Parameters
skin_varThe JSON data describing the skin.

◆ loadDefaultSkin()

void Skin::loadDefaultSkin ( )

Loads a default built-in skin.

◆ loadFromFile()

bool Skin::loadFromFile ( File source)

Loads skin state from a file.

Parameters
sourceThe file containing the skin data.
Returns
True on success, false on failure.

◆ overridesColor()

bool Skin::overridesColor ( int section,
ColorId color_id ) const

Checks if a given section overrides a specific color.

Parameters
sectionThe section override ID.
color_idThe color identifier.
Returns
True if overridden, false otherwise.

◆ overridesValue()

bool Skin::overridesValue ( int section,
ValueId value_id ) const

Checks if a given section overrides a specific value.

Parameters
sectionThe section override ID.
value_idThe value identifier.
Returns
True if overridden, false otherwise.

◆ removeOverrideColor()

void Skin::removeOverrideColor ( int section,
ColorId color_id )

Removes a color override from a section.

Parameters
sectionThe section ID.
color_idThe color ID to remove override for.

◆ removeOverrideValue()

void Skin::removeOverrideValue ( int section,
ValueId value_id )

Removes a value override from a section.

Parameters
sectionThe section ID.
value_idThe value ID to remove override for.

◆ saveToFile()

void Skin::saveToFile ( File destination)

Saves the current skin to a file.

Parameters
destinationThe file to save to.

◆ setColor()

void Skin::setColor ( ColorId color_id,
const Colour & color )
inline

Sets a color for a global ColorId.

Parameters
color_idThe color identifier.
colorThe Colour to set.

◆ setComponentColors() [1/2]

void Skin::setComponentColors ( Component * component) const

Applies all component colors to a given component.

Parameters
componentThe component to colorize.

◆ setComponentColors() [2/2]

void Skin::setComponentColors ( Component * component,
SectionOverride section_override,
bool top_level = false ) const

Applies section-specific color overrides to a component.

Parameters
componentThe component to colorize.
section_overrideThe section whose overrides to apply.
top_levelIf true, applies all top-level colors instead of overrides.

◆ setComponentValues() [1/2]

void Skin::setComponentValues ( SynthSection * component) const

Applies all default values to a SynthSection.

Parameters
componentThe SynthSection to set values on.

◆ setComponentValues() [2/2]

void Skin::setComponentValues ( SynthSection * component,
SectionOverride section_override,
bool top_level = false ) const

Applies section-specific value overrides to a SynthSection.

Parameters
componentThe SynthSection to set values on.
section_overrideThe section whose overrides to apply.
top_levelIf true, applies all top-level values instead of overrides.

◆ setValue()

void Skin::setValue ( ValueId value_id,
float value )
inline

Sets a global UI value.

Parameters
value_idThe value identifier.
valueThe float value to set.

◆ shouldScaleValue()

bool Skin::shouldScaleValue ( ValueId value_id)
static

Checks if a certain ValueId should be scaled by the display ratio.

Parameters
value_idThe value identifier.
Returns
True if it should be scaled, false otherwise.

◆ stateToJson()

json Skin::stateToJson ( )

Converts the current skin state to JSON.

Returns
The skin data in JSON form.

◆ stateToString()

String Skin::stateToString ( )

Converts the current skin state to a string (JSON representation).

Returns
The skin state as a string.

◆ stringToState()

bool Skin::stringToState ( String skin_string)

Loads skin state from a JSON string.

Parameters
skin_stringThe JSON string.
Returns
True on success, false on parse errors.

◆ updateJson()

json Skin::updateJson ( json data)

Updates JSON data to a newer format or version if needed.

Parameters
dataThe JSON data to update.
Returns
The updated JSON data.

Member Data Documentation

◆ color_overrides_

std::map<ColorId, Colour> Skin::color_overrides_[kNumSectionOverrides]
protected

Per-section color overrides.

◆ colors_

Colour Skin::colors_[kNumColors]
protected

Array of global colors.

◆ kNumColors

int Skin::kNumColors = kFinalColor - kInitialColor
staticconstexpr

◆ value_overrides_

std::map<ValueId, float> Skin::value_overrides_[kNumSectionOverrides]
protected

Per-section value overrides.

◆ values_

float Skin::values_[kNumSkinValueIds]
protected

Array of global float values.


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