double value() const;int value(double v);Fl_Slider *slider = new Fl_Slider(50, 50, 200, 30);slider->bounds(0.0, 100.0); // Set rangeslider->value(50.0); // Set to middledouble val = slider->value();printf("Value: %.2f\n", val);
bounds() - Set Range
Set minimum and maximum values.
void bounds(double min, double max);double minimum() const;double maximum() const;slider->bounds(0.0, 100.0); // 0 to 100slider->bounds(-50.0, 50.0); // -50 to +50
step() - Increment Size
Set the step size for arrow key adjustments.
void step(double s);double step() const;slider->step(1.0); // Increment by 1slider->step(0.1); // Fine increments
slider_size() - Knob Size
Set size of the moving slider knob.
void slider_size(double s); // Fraction of total (0.0 - 1.0)float slider_size() const;slider->slider_size(0.1); // 10% of track length
void scale(Scale_Type s);Scale_Type scale() const;// Scale typesLINEAR_SCALE // Linear scale (default)LOG_SCALE // Logarithmic scaleslider->scale(LOG_SCALE); // Good for volume, frequency
ticks() - Show Tick Marks
Add tick marks to nice sliders.
void ticks(uchar position, uchar num_ticks = 11);// Tick positions (can combine with |)TICKS_NONE // No ticksTICKS_ABOVE // Above horizontal sliderTICKS_BELOW // Below horizontal sliderTICKS_LEFT // Left of vertical sliderTICKS_RIGHT // Right of vertical sliderslider->type(FL_HOR_NICE_SLIDER);slider->ticks(Fl_Slider::TICKS_BELOW, 11);
Sliders appear as a track with a movable knob. Vertical sliders have the knob moving up/down, horizontal left/right. Fill sliders show a colored bar from minimum to current value. Nice sliders have a rounded, raised knob.
// Set angle range (default: 45 to 315 degrees)void angles(short angle1, short angle2);short angle1() const;short angle2() const;// 0 degrees is straight down, angles go clockwisedial->angles(0, 360); // Full circledial->angles(225, 315); // Bottom-left quadrant
Circular widget with indicator showing current value. Normal dial shows a dot on the perimeter, line dial shows a line from center, fill dial shows a colored arc.
void step(double s); // Set single step sizevoid step(double s, double l); // Set single and fast stepvoid lstep(double l); // Set large (fast) stepcounter->step(1.0, 10.0); // +/-1 and +/-10 buttons
Shows numeric value in center with arrow buttons on either side. Normal counter has four buttons: double-left, left, right, double-right for slow and fast adjustment.
// Callback on every change (while dragging)slider->when(FL_WHEN_CHANGED);// Callback only when released (default)slider->when(FL_WHEN_RELEASE);// Callback on bothslider->when(FL_WHEN_CHANGED | FL_WHEN_RELEASE);