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

A slider-based UI component that displays selectable tabs. More...

#include <tab_selector.h>

Inheritance diagram for TabSelector:

Public Member Functions

 TabSelector (String name)
 
void paint (Graphics &g) override
 
void mouseEvent (const MouseEvent &e)
 
void mouseDown (const MouseEvent &e) override
 
void mouseDrag (const MouseEvent &e) override
 
void mouseUp (const MouseEvent &e) override
 
void setNames (std::vector< std::string > names)
 
void setFontHeightPercent (float percent)
 
float getFontHeightPercent ()
 
void setActive (bool active)
 
void valueChanged () override
 Called when the slider value changes, triggers a redraw of the image.
 
OpenGlImageComponentgetImageComponent ()
 
void redoImage ()
 Redraws the image component.
 

Static Public Attributes

static constexpr float kDefaultFontHeightPercent = 0.26f
 Default percentage of the font height relative to the component height.
 

Detailed Description

A slider-based UI component that displays selectable tabs.

The TabSelector uses the slider's value to determine which tab is selected. It displays each tab name horizontally and highlights the currently selected tab. The component can be integrated with custom look-and-feels and supports OpenGL image rendering for efficient drawing.

Constructor & Destructor Documentation

◆ TabSelector()

TabSelector::TabSelector ( String name)

Constructor.

Parameters
nameThe name of the TabSelector component.

Constructs a TabSelector with a given name. Sets default look-and-feel values and initializes the image component.

Member Function Documentation

◆ getFontHeightPercent()

float TabSelector::getFontHeightPercent ( )
inline

Gets the current font height percentage.

Returns
The font height percentage.

◆ getImageComponent()

OpenGlImageComponent * TabSelector::getImageComponent ( )
inline

Retrieves the underlying OpenGlImageComponent used for rendering.

Returns
A pointer to the OpenGlImageComponent.

◆ mouseDown()

void TabSelector::mouseDown ( const MouseEvent & e)
override

Called when the mouse button is pressed down on the TabSelector.

Parameters
eThe mouse event.

Called when the mouse button is pressed on the TabSelector.

Parameters
eThe mouse event.

◆ mouseDrag()

void TabSelector::mouseDrag ( const MouseEvent & e)
override

Called when the mouse is dragged while the button is held down on the TabSelector.

Parameters
eThe mouse event.

◆ mouseEvent()

void TabSelector::mouseEvent ( const MouseEvent & e)

Handles mouse events that change the selected tab.

Parameters
eThe mouse event object.

Handles mouse events to select a tab based on the mouse position.

Parameters
eThe mouse event.

◆ mouseUp()

void TabSelector::mouseUp ( const MouseEvent & e)
override

Called when the mouse button is released after being pressed on the TabSelector.

Parameters
eThe mouse event.

Called when the mouse button is released on the TabSelector.

Parameters
eThe mouse event.

◆ paint()

void TabSelector::paint ( Graphics & g)
override

Paints the TabSelector, drawing tab names and highlighting the selected tab.

Parameters
gThe JUCE Graphics context.

Paints the tabs and the highlight for the currently selected tab. Draws a highlight line, tab names, and uses the appropriate colors based on the active state.

◆ redoImage()

void TabSelector::redoImage ( )
inline

Redraws the image component.

◆ setActive()

void TabSelector::setActive ( bool active)
inline

Sets whether the TabSelector is active.

Parameters
activeTrue if active, false otherwise.

◆ setFontHeightPercent()

void TabSelector::setFontHeightPercent ( float percent)
inline

Sets the font height as a percentage of the component height.

Parameters
percentThe font height percentage.

◆ setNames()

void TabSelector::setNames ( std::vector< std::string > names)
inline

Sets the names of the tabs.

Parameters
namesA vector of strings representing each tab name.

◆ valueChanged()

void TabSelector::valueChanged ( )
inlineoverride

Called when the slider value changes, triggers a redraw of the image.

Member Data Documentation

◆ kDefaultFontHeightPercent

float TabSelector::kDefaultFontHeightPercent = 0.26f
staticconstexpr

Default percentage of the font height relative to the component height.


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