Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fltk/fltk/llms.txt
Use this file to discover all available pages before exploring further.
Fl_Slider
TheFl_Slider widget contains a sliding knob inside a box that allows users to select a value from a continuous range. It’s commonly used for volume controls, scrollbars, and value selection.
Header File
Class Overview
Fl_Slider is a valuator widget that provides a graphical slider control. Features include:
- Sliding knob for value selection
- Horizontal or vertical orientation
- Multiple visual styles (standard, fill, nice)
- Linear or logarithmic scaling
- Optional tick marks for nice sliders
- Configurable range with
minimum()andmaximum()
Inheritance
Fl_Valuator (which inherits from Fl_Widget)
Slider Types
Set the slider type usingtype(int):
FL_VERT_SLIDER(0) - Vertical slider (default)FL_HOR_SLIDER(1) - Horizontal sliderFL_VERT_FILL_SLIDER(2) - Vertical filled slider (progress meter style)FL_HOR_FILL_SLIDER(3) - Horizontal filled sliderFL_VERT_NICE_SLIDER(4) - Vertical slider with nice-looking knobFL_HOR_NICE_SLIDER(5) - Horizontal slider with nice-looking knob
Constructors
Standard Constructor
The X coordinate of the slider relative to the enclosing window
The Y coordinate of the slider relative to the enclosing window
Width of the slider in pixels
Height of the slider in pixels
Label text for the slider
Type Constructor
Slider type (e.g.,
FL_HOR_SLIDER, FL_VERT_NICE_SLIDER)The X coordinate of the slider
The Y coordinate of the slider
Width in pixels
Height in pixels
Label text
Public Methods
slider_size()
Fraction of widget size (0.0 to 1.0). Default is 0.08. Setting to 1.0 prevents movement.
For fill sliders, this controls the size of the area around the end that causes dragging rather than jumping to the mouse.
slider()
Box type for the slider knob (e.g.,
FL_UP_BOX, FL_ROUND_UP_BOX)scale()
Either
LINEAR_SCALE (0, default) or LOG_SCALEticks()
Tick position bitset:
TICKS_NONE(0x00) - No ticksTICKS_BELOW(0x01) - Below horizontal sliderTICKS_ABOVE(0x02) - Above horizontal sliderTICKS_LEFT(0x01) - Left of vertical sliderTICKS_RIGHT(0x02) - Right of vertical slider
Number of tick marks to draw
num_ticks()
uchar - Number of tick marks
bounds()
Minimum value
Maximum value
The minimum may be greater than maximum to reverse the slider direction.
scrollvalue()
Current scroll position
Size of visible area
First position in scrollable area
Total size of scrollable area
int - 1 if slider changed, 0 otherwise
handle()
The FLTK event type
int - 1 if handled, 0 otherwise
Protected Methods
draw()
Inherited Methods from Fl_Valuator
Value Management
value()/value(double)- Get or set current valueminimum()/minimum(double)- Get or set minimum valuemaximum()/maximum(double)- Get or set maximum valuerange(double min, double max)- Set min and max togetherstep(double)/step(double, int)- Set value stepping incrementprecision(int)- Set number of digits for text display
Callback Control
when()/when(uchar)- Control when callbacks occurclamp(double)- Clamp value to min/max range
Usage Example
Logarithmic Scale Example
Common Use Cases
- Volume controls - Audio level adjustment
- Brightness/contrast - Image adjustment controls
- Progress indicators - Using fill sliders as progress meters
- Scrollbars - Custom scrollbar implementation
- Parameter adjustment - Fine-tuning numeric values
- Color pickers - RGB/HSV component selection
See Also
- Fl_Valuator - Base class for value controls
- Fl_Value_Slider - Slider with numeric value display
- Fl_Scrollbar - Specialized slider for scrolling
- Fl_Adjuster - Up/down arrow value adjuster
- Fl_Dial - Circular value control