Sound Meter 0.9.0
Fully resizing logarithmic JUCE meter module.
Loading...
Searching...
No Matches
sd::SoundMeter::Fader Class Referencefinal

Class responsible for the fader. More...

#include <sd_MeterFader.h>

Public Member Functions

 Fader ()=default
 
void flash () noexcept
 Show the fader briefly and fade out (unless overridden and shown longer). More...
 
bool isVisible () const noexcept
 Check if the fader is visible. More...
 
void setVisible (bool visible=true) noexcept
 Show or hide the fader. More...
 
bool isEnabled () const noexcept
 Check if the 'fader' overlay is enabled. More...
 
void enable (bool enabled=true) noexcept
 Enable or disable the 'fader' overlay. More...
 
void setBounds (const juce::Rectangle< int > &bounds) noexcept
 Set the fader bounds. More...
 
juce::Rectangle< int > getBounds () const noexcept
 Get the fader bounds. More...
 
float getValue () const noexcept
 Get the value of the meter fader. More...
 
bool setValue (float value, NotificationOptions notificationOption=NotificationOptions::notify)
 Set fader value. More...
 
void setValueFromPos (int position, NotificationOptions notificationOption=NotificationOptions::notify)
 Set fader value according to a supplied mouse position. More...
 
bool isFading () const noexcept
 Check whether the fader is currently fading out. More...
 
void draw (juce::Graphics &g, const MeterColours &meterColours)
 Draw the fader. More...
 
bool needsRedrawing () noexcept
 Check if the fader needs redrawing. More...
 

Public Attributes

std::function< void()> onFaderValueChanged { nullptr }
 

Detailed Description

Class responsible for the fader.

The fader overlay displayed on top of the 'meter' part (in combination with the 'mute' buttons in the 'header' part) can be used by the user to control gain or any other parameter.

Constructor & Destructor Documentation

◆ Fader()

sd::SoundMeter::Fader::Fader ( )
default

Member Function Documentation

◆ flash()

void sd::SoundMeter::Fader::flash ( )
noexcept

Show the fader briefly and fade out (unless overridden and shown longer).

◆ isVisible()

bool sd::SoundMeter::Fader::isVisible ( ) const
noexcept

Check if the fader is visible.

Returns
True, if the meter is visible, otherwise the fader is hidden.
See also
setVisible, setEnabled, isEnabled

◆ setVisible()

void sd::SoundMeter::Fader::setVisible ( bool  visible = true)
noexcept

Show or hide the fader.

Parameters
visibleWhen set to true, show the fader. Otherwise hide it.
See also
isVisible, setEnabled, isEnabled

◆ isEnabled()

bool sd::SoundMeter::Fader::isEnabled ( ) const
noexcept

Check if the 'fader' overlay is enabled.

Returns
True, when the fader is enabled.
See also
setEnabled, isVisible, setVisible

◆ enable()

void sd::SoundMeter::Fader::enable ( bool  enabled = true)
noexcept

Enable or disable the 'fader' overlay.

Parameters
enabledTrue, when the fader needs to be enabled.
See also
isEnabled, isActive, setActive

◆ setBounds()

void sd::SoundMeter::Fader::setBounds ( const juce::Rectangle< int > &  bounds)
noexcept

Set the fader bounds.

Parameters
boundsThe bounds to use for the fader.
See also
getBounds

◆ getBounds()

juce::Rectangle< int > sd::SoundMeter::Fader::getBounds ( ) const
noexcept

Get the fader bounds.

Returns
Bounds used by the fader.
See also
setBounds

◆ getValue()

float sd::SoundMeter::Fader::getValue ( ) const
noexcept

Get the value of the meter fader.

Returns
The current fader value [0..1].
See also
setValueFromPos, setValue

Referenced by draw().

◆ setValue()

bool sd::SoundMeter::Fader::setValue ( float  value,
NotificationOptions  notificationOption = NotificationOptions::notify 
)

Set fader value.

Parameters
valueThe value [0..1] the fader needs to be set to.
notificationOptionSelect whether to notify the listeners.
Returns
True, if the value actually changed.
See also
setValueFromPos, getValue

References sd::SoundMeter::notify, and onFaderValueChanged.

Referenced by setValueFromPos().

◆ setValueFromPos()

void sd::SoundMeter::Fader::setValueFromPos ( int  position,
NotificationOptions  notificationOption = NotificationOptions::notify 
)

Set fader value according to a supplied mouse position.

Parameters
positionThe mouse position (y coordinate) to use to calculate the fader value.
notificationOptionSelect whether to notify the listeners.
See also
setValue

References setValue().

◆ isFading()

bool sd::SoundMeter::Fader::isFading ( ) const
noexcept

Check whether the fader is currently fading out.

Returns
True, if the fader is currently fading out.

Referenced by needsRedrawing().

◆ draw()

void sd::SoundMeter::Fader::draw ( juce::Graphics &  g,
const MeterColours meterColours 
)

Draw the fader.

Parameters
[in,out]gThe juce graphics context to use.
meterColoursColours to draw the fader with.

References sd::SoundMeter::MeterColours::faderColour, getValue(), sd::SoundMeter::Constants::kFaderAlphaMax, and sd::SoundMeter::Constants::kFaderFadeTime_ms.

◆ needsRedrawing()

bool sd::SoundMeter::Fader::needsRedrawing ( )
noexcept

Check if the fader needs redrawing.

References isFading().

Member Data Documentation

◆ onFaderValueChanged

std::function<void()> sd::SoundMeter::Fader::onFaderValueChanged { nullptr }

Referenced by setValue().


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