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

Class responsible for the meter's 'header' part. More...

#include <sd_MeterHeader.h>

Public Member Functions

 Header (juce::Font &font) noexcept
 Constructor. More...
 
 Header (juce::String name, const juce::AudioChannelSet::ChannelType &type, juce::Font &font) noexcept
 Constructor with channel identification. More...
 
void setType (const juce::AudioChannelSet::ChannelType &type)
 Set the channel type. More...
 
const juce::AudioChannelSet::ChannelType & getType () const noexcept
 Get the channel type. More...
 
void setName (const juce::String &name)
 Set the channel name. More...
 
juce::String getName () const noexcept
 Get the channel name. More...
 
float getNameWidth () const noexcept
 Get the width (in pixels) of the channel name. More...
 
float getTypeWidth () const noexcept
 Get the width (in pixels) of the channel description. More...
 
juce::String getInfo () const noexcept
 Get the info text displayed in the 'header'. More...
 
bool textFits (const juce::String &text, int widthAvailable) const
 Check whether a certain text will fit the width available using the meter's specified font. More...
 
void setFont (const juce::Font &font)
 Set the font used to display the info (and other text in the meter). More...
 
void setBounds (const juce::Rectangle< int > &bounds) noexcept
 Set the bounds of the 'header' part of the meter. More...
 
juce::Rectangle< int > getBounds () const noexcept
 Get the bounds of the 'header' part of the meter. More...
 
bool isMouseOver (int y) noexcept
 Check if the mouse is over the 'header' part of the meter. More...
 
bool isMouseOver () const noexcept
 Check if the mouse is over the 'header' part of the meter. More...
 
void resetMouseOver () noexcept
 Reset 'mouse over' status of the 'header' part of the meter. More...
 
void setReferredWidth (float referredWidth) noexcept
 Set the referred width (from other meters) used to decide what info to display. More...
 
void draw (juce::Graphics &g, bool meterActive, bool faderEnabled, const MeterColours &meterColours)
 Draw the 'header' part of the meter. More...
 

Detailed Description

Class responsible for the meter's 'header' part.

The 'header' part, is the part above the meter displaying the name (when supplied by the user), the type (left, right) or the abbreviated type if the other two do not fit.

The 'header' also doubles as a button which can de-activate (mute) or activate the meter.

Constructor & Destructor Documentation

◆ Header() [1/2]

sd::SoundMeter::Header::Header ( juce::Font &  font)
explicitnoexcept

Constructor.

Parameters
fontThe font to use in the header.

◆ Header() [2/2]

sd::SoundMeter::Header::Header ( juce::String  name,
const juce::AudioChannelSet::ChannelType &  type,
juce::Font &  font 
)
noexcept

Constructor with channel identification.

Parameters
nameChannel name to display in the header.
typeChannel type to display in the header.
fontThe font to use in the header.

Member Function Documentation

◆ setType()

void sd::SoundMeter::Header::setType ( const juce::AudioChannelSet::ChannelType &  type)

Set the channel type.

For instance: left, right, center, etc..

Parameters
typeThe channel type assigned to the meter.
See also
getType

Referenced by sd::SoundMeter::MeterChannel::setChannelType().

◆ getType()

const juce::AudioChannelSet::ChannelType & sd::SoundMeter::Header::getType ( ) const
noexcept

Get the channel type.

For instance: left, right, center, etc..

Returns
The channel type assigned to the meter.
See also
setType

◆ setName()

void sd::SoundMeter::Header::setName ( const juce::String &  name)

Set the channel name.

Can be anything the user sets (mid, side, etc..).

Parameters
nameThe channel name assigned to the meter.
See also
getName

Referenced by sd::SoundMeter::MeterChannel::setChannelName().

◆ getName()

juce::String sd::SoundMeter::Header::getName ( ) const
noexcept

Get the channel name.

Can be anything the user sets (mid, side, etc..).

Returns
The channel name assigned to the meter.
See also
setName

◆ getNameWidth()

float sd::SoundMeter::Header::getNameWidth ( ) const
noexcept

Get the width (in pixels) of the channel name.

Returns
The width (in pixels) taken by the channel name.
See also
getTypeWidth, textFits

Referenced by sd::SoundMeter::MeterChannel::getChannelNameWidth().

◆ getTypeWidth()

float sd::SoundMeter::Header::getTypeWidth ( ) const
noexcept

Get the width (in pixels) of the channel description.

Returns
The width (in pixels) taken by the channel description.
See also
getNameWdith, textFits

Referenced by sd::SoundMeter::MeterChannel::getChannelTypeWidth().

◆ getInfo()

juce::String sd::SoundMeter::Header::getInfo ( ) const
noexcept

Get the info text displayed in the 'header'.

This can be either the channel name (when set by the user), the channel type description (left, right, etc..) or the abbreviated channel type description when the other two do not fit.

Returns
The info text displayed in the 'header'.
See also
getName, getType

Referenced by draw().

◆ textFits()

bool sd::SoundMeter::Header::textFits ( const juce::String &  text,
int  widthAvailable 
) const

Check whether a certain text will fit the width available using the meter's specified font.

Parameters
textThe info text to check the width of.
widthAvailableThe width available in the 'header' part.
See also
getInfo, getTypeWidth, getNameWidth

Referenced by sd::SoundMeter::MeterChannel::nameFits().

◆ setFont()

void sd::SoundMeter::Header::setFont ( const juce::Font &  font)

Set the font used to display the info (and other text in the meter).

Font to be used for the header, value and label strip.

Parameters
fontThe font to use.
See also
getFont

Referenced by sd::SoundMeter::MeterChannel::setFont().

◆ setBounds()

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

Set the bounds of the 'header' part of the meter.

Parameters
boundsThe bounds to use for the 'header' part of the meter.
See also
getBounds

Referenced by sd::SoundMeter::MeterChannel::resized().

◆ getBounds()

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

Get the bounds of the 'header' part of the meter.

Returns
The bounds of the 'header' part of the meter.
See also
setBounds

Referenced by sd::SoundMeter::MeterChannel::getLabelStripBounds(), sd::SoundMeter::MeterChannel::paint(), sd::SoundMeter::MeterChannel::setChannelName(), and sd::SoundMeter::MeterChannel::showHeader().

◆ isMouseOver() [1/2]

bool sd::SoundMeter::Header::isMouseOver ( int  y)
noexcept

Check if the mouse is over the 'header' part of the meter.

Parameters
yThe coordinate to use to check whether the mouse is over the 'header' part.
Returns
True, when the mouse is over the 'header' part of the meter, using the supplied y coordinate.
See also
resetMouseOver

◆ isMouseOver() [2/2]

bool sd::SoundMeter::Header::isMouseOver ( ) const
noexcept

Check if the mouse is over the 'header' part of the meter.

Returns
True, when the mouse is over the 'header' part of the meter.
See also
resetMouseOver

◆ resetMouseOver()

void sd::SoundMeter::Header::resetMouseOver ( )
noexcept

Reset 'mouse over' status of the 'header' part of the meter.

◆ setReferredWidth()

void sd::SoundMeter::Header::setReferredWidth ( float  referredWidth)
noexcept

Set the referred width (from other meters) used to decide what info to display.

When this is set to zero, each meter uses his own bounds to decide what to display. When set to a non zero value (for instance from another meter) this meter will use that value to decide what to display. When there is not enough room (width) to display the full description or name, display the abbreviated type description.

Parameters
referredWidthThe width (in pixels) to use when deciding what to display in the header.

Referenced by sd::SoundMeter::MeterChannel::setReferredTypeWidth().

◆ draw()

void sd::SoundMeter::Header::draw ( juce::Graphics &  g,
bool  meterActive,
bool  faderEnabled,
const MeterColours meterColours 
)

Draw the 'header' part of the meter.

Parameters
[in,out]gThe juce graphics context to use.
meterActiveTrue, when the meter is active (not muted).
faderEnabledTrue, when the fader overlay is enabled.
meterColoursThe colours to draw the header with.

References getInfo(), sd::SoundMeter::MeterColours::inactiveColour, sd::SoundMeter::Constants::kDefaultHeaderFontHeight, sd::SoundMeter::MeterColours::muteColour, sd::SoundMeter::MeterColours::muteMouseOverColour, and sd::SoundMeter::MeterColours::textColour.

Referenced by sd::SoundMeter::MeterChannel::paint().


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