fltk.widgets
FLTK Common Widgets
This module provides common widget classes:
- Box: Simple display widget for text or decoration
- Button: Clickable button with callback support
- CheckButton: Checkbox button
- RadioButton: Radio button (mutually exclusive in group)
- ToggleButton: Toggle button (maintains on/off state)
- LightButton: Button with indicator light
- RepeatButton: Button that auto-repeats when held
- ReturnButton: Default button (responds to Enter key)
- RoundButton: Round radio-style button
- Input: Text input field
- FloatInput: Floating-point number input
- IntInput: Integer number input
- SecretInput: Password input (shows dots)
- MultilineInput: Multi-line text input
- FileInput: File path input
- Output: Read-only text display
- MultilineOutput: Multi-line read-only text
- Slider: Basic slider for selecting numeric values
- ValueSlider: Slider with value display
- Progress: Progress bar
- Dial: Circular dial for numeric values
- Counter: Numeric counter with +/- buttons
- Roller: Rolling valuator
- Scrollbar: Scrollbar widget
- ValueInput: Numeric input field
- ValueOutput: Numeric output display
- Adjuster: Valuator with arrow buttons
License
BSD-3-ClauseCopyright
Copyright © 2025 DDN (D Developer Network) Members
Types 51
Simple box widget for displaying text or decoration.
Box widgets are typically used as labels or decorative elements. They can display text and have various border styles.
Example:
auto box = new Box(Boxtype.UP_BOX, 10, 10, 100, 30, "Hello");BoxPtr _boxHandleThe underlying box handlethis(Boxtype boxtype, int x, int y, int width, int height, string label = null)Creates a new box widget.this(int x, int y, int width, int height, string label = null)Creates a new flat box widget (no border).~thisDestroys the box and releases resources.Clickable button widget.
Buttons respond to mouse clicks and can trigger callbacks. They can display text labels and various visual states.
Example:
auto button = new Button(10, 10, 100, 30, "Click Me");
button.onClick = () {
writeln("Button clicked!");
};ButtonPtr _buttonHandleThe underlying button handlethis(int x, int y, int width, int height, string label = null)Creates a new button widget.~thisDestroys the button and releases resources.Text input widget.
Input widgets allow users to enter and edit text.
Example:
auto input = new Input(10, 10, 200, 25, "Name:");
input.value = "John Doe";
string text = input.value;InputPtr _inputHandleThe underlying input handlevoid value(string text)Sets the input's text value.void text(string content)Sets the text content.void clear()Clears the input field.this(int x, int y, int width, int height, string label = null)Creates a new input widget.~thisDestroys the input and releases resources.Slider widget for selecting numeric values.
ValueSlider widgets allow users to select a value from a range by dragging a slider or clicking on the track. The current value is displayed next to the slider.
Example:
auto slider = new ValueSlider(10, 10, 200, 25, "Volume:");
slider.range(-10, 10);
slider.step = 1;
slider.value = 0;
double val = slider.value;ValueSliderPtr _sliderHandleThe underlying value slider handlevoid value(double val)Sets the slider's current value.void minimum(double min)Sets the slider's minimum value.void maximum(double max)Sets the slider's maximum value.void range(double min, double max)Sets the slider's range (minimum and maximum).void step(double s)Sets the slider's step value.void setHorizontal()Sets the slider to horizontal orientation.void setVertical()Sets the slider to vertical orientation.this(int x, int y, int width, int height, string label = null)Creates a new value slider widget.~thisDestroys the slider and releases resources.Horizontal value slider widget.
HorValueSlider is a convenience class that creates a ValueSlider with horizontal orientation as the default. The slider displays its current numeric value.
Example:
auto slider = new HorValueSlider(10, 10, 200, 25, "Volume:");
slider.range(0, 100);
slider.value = 50;this(int x, int y, int width, int height, string label = null)Creates a new horizontal value slider widget.Slider type constants.
These values define the visual style and orientation of slider widgets.
Basic slider widget for selecting numeric values.
Slider widgets allow users to select a value from a range by dragging a slider or clicking on the track. Unlike ValueSlider, this widget does not display the current value.
Slider inherits from Valuator and provides all valuator functionality including value, minimum, maximum, step, clamp, round, etc.
Example:
auto slider = new Slider(10, 10, 200, 25, "Volume:");
slider.range(0, 100);
slider.value = 50;
slider.sliderType = SliderType.HOR_SLIDER;SliderPtr _sliderHandlevoid setHorizontal()Sets the slider to horizontal orientation.void setVertical()Sets the slider to vertical orientation.this(int x, int y, int width, int height, string label = null)Creates a new slider widget.Slider widget with a filled track.
FillSlider is a convenience class that creates a Slider with a filled appearance. The track fills from the minimum to the current value, making it useful as a progress or value meter.
Example:
auto slider = new FillSlider(10, 10, 200, 25, "Progress:");
slider.range(0, 100);
slider.value = 75;void setHorizontal()Sets the slider to horizontal filled orientation.void setVertical()Sets the slider to vertical filled orientation.this(int x, int y, int width, int height, string label = null)Creates a new filled slider widget.Slider widget with a nice visual appearance.
NiceSlider is a convenience class that creates a Slider with a nicer looking control knob compared to the standard slider.
Example:
auto slider = new NiceSlider(10, 10, 200, 25, "Volume:");
slider.range(0, 100);
slider.value = 50;void setHorizontal()Sets the slider to horizontal nice orientation.void setVertical()Sets the slider to vertical nice orientation.this(int x, int y, int width, int height, string label = null)Creates a new nice slider widget.Horizontal slider widget.
HorSlider is a convenience class that creates a Slider with horizontal orientation as the default.
Example:
auto slider = new HorSlider(10, 10, 200, 25, "Volume:");
slider.range(0, 100);
slider.value = 50;this(int x, int y, int width, int height, string label = null)Creates a new horizontal slider widget.Horizontal filled slider widget.
HorFillSlider is a convenience class that creates a horizontal slider with a filled appearance. The track fills from the minimum to the current value.
Example:
auto slider = new HorFillSlider(10, 10, 200, 25, "Progress:");
slider.range(0, 100);
slider.value = 75;this(int x, int y, int width, int height, string label = null)Creates a new horizontal filled slider widget.Horizontal nice slider widget.
HorNiceSlider is a convenience class that creates a horizontal slider with a nicer visual appearance.
Example:
auto slider = new HorNiceSlider(10, 10, 200, 25, "Volume:");
slider.range(0, 100);
slider.value = 50;this(int x, int y, int width, int height, string label = null)Creates a new horizontal nice slider widget.Checkbox button widget.
CheckButton widgets display a checkbox that can be checked or unchecked.
Example:
auto check = new CheckButton(10, 10, 100, 25, "Enable");
check.checked = true;
if (check.checked) { ... }CheckButtonPtr _checkHandlethis(int x, int y, int width, int height, string label = null)Radio button widget.
RadioButton widgets are mutually exclusive within a group - only one can be selected at a time.
Example:
auto radio1 = new RadioButton(10, 10, 100, 25, "Option 1");
auto radio2 = new RadioButton(10, 40, 100, 25, "Option 2");
radio1.selected = true;RadioButtonPtr _radioHandlethis(int x, int y, int width, int height, string label = null)Toggle button widget.
ToggleButton widgets maintain an on/off state when clicked.
Example:
auto toggle = new ToggleButton(10, 10, 100, 25, "Toggle");
toggle.on = true;
if (toggle.on) { ... }ToggleButtonPtr _toggleHandlethis(int x, int y, int width, int height, string label = null)Light button widget with indicator light.
LightButton widgets display an indicator light that shows on/off state visually.
Example:
auto light = new LightButton(10, 10, 100, 25, "Enable");
light.on = true; // turns indicator onLightButtonPtr _lightHandlethis(int x, int y, int width, int height, string label = null)Radio light button widget.
RadioLightButton widgets are light buttons with radio button behavior, meaning they are mutually exclusive within a group. When one radio light button is selected, others in the same group are automatically deselected.
Example:
auto option1 = new RadioLightButton(10, 10, 100, 25, "Option 1");
auto option2 = new RadioLightButton(10, 40, 100, 25, "Option 2");
option1.on = true; // selects option1, deselects others in groupRadioLightButtonPtr _radioLightHandleRadioLightButtonPtr radioLightHandle() @safe nothrow @nogcReturns the underlying radio light button handle.this(int x, int y, int width, int height, string label = null)Creates a new radio light button widget.Radio round button widget.
RadioRoundButton widgets are round buttons with radio button behavior, meaning they are mutually exclusive within a group. When one radio round button is selected, others in the same group are automatically deselected.
Example:
auto option1 = new RadioRoundButton(10, 10, 100, 25, "Option 1");
auto option2 = new RadioRoundButton(10, 40, 100, 25, "Option 2");
option1.on = true; // selects option1, deselects others in groupRadioRoundButtonPtr _radioRoundHandleRadioRoundButtonPtr radioRoundHandle() @safe nothrow @nogcReturns the underlying radio round button handle.this(int x, int y, int width, int height, string label = null)Creates a new radio round button widget.Toggle light button widget.
ToggleLightButton widgets are light buttons that maintain on/off state. Unlike radio buttons, multiple toggle light buttons can be on at the same time.
Example:
auto option1 = new ToggleLightButton(10, 10, 100, 25, "Option 1");
auto option2 = new ToggleLightButton(10, 40, 100, 25, "Option 2");
option1.on = true; // both can be on simultaneously
option2.on = true;ToggleLightButtonPtr _toggleLightHandleToggleLightButtonPtr toggleLightHandle() @safe nothrow @nogcReturns the underlying toggle light button handle.this(int x, int y, int width, int height, string label = null)Creates a new toggle light button widget.Toggle round button widget.
ToggleRoundButton widgets are round buttons that maintain on/off state. Unlike radio buttons, multiple toggle round buttons can be on at the same time.
Example:
auto option1 = new ToggleRoundButton(10, 10, 100, 25, "Option 1");
auto option2 = new ToggleRoundButton(10, 40, 100, 25, "Option 2");
option1.on = true; // both can be on simultaneously
option2.on = true;ToggleRoundButtonPtr _toggleRoundHandleToggleRoundButtonPtr toggleRoundHandle() @safe nothrow @nogcReturns the underlying toggle round button handle.this(int x, int y, int width, int height, string label = null)Creates a new toggle round button widget.Repeat button widget.
RepeatButton widgets auto-repeat their callback when held down.
Example:
auto repeat = new RepeatButton(10, 10, 100, 25, "Hold Me");
repeat.onClick = { count++; }; // called repeatedly while heldRepeatButtonPtr _repeatHandlethis(int x, int y, int width, int height, string label = null)Return button widget (default button).
ReturnButton widgets respond to the Enter key as the default button. They display a special visual indicator (typically a border).
Example:
auto ok = new ReturnButton(10, 10, 100, 25, "OK");
ok.onClick = { window.hide(); }; // activated by Enter keyReturnButtonPtr _returnHandlethis(int x, int y, int width, int height, string label = null)Round button widget.
RoundButton widgets have a round radio-style appearance. They can be used as radio buttons with visual round indicators.
Example:
auto round = new RoundButton(10, 10, 100, 25, "Option");
round.on = true; // selects the buttonRoundButtonPtr _roundHandlethis(int x, int y, int width, int height, string label = null)Float input widget.
FloatInput widgets accept only floating-point numbers.
Example:
auto floatIn = new FloatInput(10, 10, 100, 25, "Value:");
floatIn.value = "3.14";FloatInputPtr _floatInputHandlethis(int x, int y, int width, int height, string label = null)Integer input widget.
IntInput widgets accept only integer numbers.
Example:
auto intIn = new IntInput(10, 10, 100, 25, "Count:");
intIn.value = "42";IntInputPtr _intInputHandlethis(int x, int y, int width, int height, string label = null)Secret input widget (password field).
SecretInput widgets display dots/asterisks instead of actual characters, suitable for password entry.
Example:
auto password = new SecretInput(10, 10, 200, 25, "Password:");
password.value = "secret123";SecretInputPtr _secretInputHandlethis(int x, int y, int width, int height, string label = null)Multiline input widget.
MultilineInput widgets accept multiple lines of text.
Example:
auto multi = new MultilineInput(10, 10, 200, 100, "Notes:");
multi.value = "Line 1\nLine 2\nLine 3";MultilineInputPtr _multilineInputHandlethis(int x, int y, int width, int height, string label = null)File input widget.
FileInput widgets provide file path input with navigation support.
Example:
auto fileIn = new FileInput(10, 10, 300, 25, "File:");
fileIn.value = "/home/user/document.txt";FileInputPtr _fileInputHandlethis(int x, int y, int width, int height, string label = null)Multiline output widget (read-only).
MultilineOutput widgets display multiple lines of read-only text.
Example:
auto multiOut = new MultilineOutput(10, 10, 200, 100, "Log:");
multiOut.value = "Line 1\nLine 2\nLine 3";MultilineOutputPtr _multilineOutputHandlethis(int x, int y, int width, int height, string label = null)Dial type constants.
These values define the visual style of dial widgets.
Dial widget for selecting numeric values.
Dial widgets provide a circular dial interface for selecting values. The dial can be styled as normal (dot), line, or filled arc.
Dial inherits from Valuator and provides all valuator functionality including value, minimum, maximum, step, clamp, round, etc.
Example:
auto dial = new Dial(10, 10, 100, 100, "Volume:");
dial.range(0, 100);
dial.value = 50;
dial.dialType = DialType.FILL;DialPtr _dialHandlethis(int x, int y, int width, int height, string label = null)Creates a new dial widget.Dial widget with a filled arc indicator.
FillDial is a convenience class that creates a Dial with the FILL type preset. The dial draws a filled arc from the minimum position to the current value.
Example:
auto dial = new FillDial(10, 10, 100, 100, "Level:");
dial.range(0, 100);
dial.value = 75;this(int x, int y, int width, int height, string label = null)Creates a new filled dial widget.Dial widget with a line indicator.
LineDial is a convenience class that creates a Dial with the LINE type preset. The dial draws a line from the center to indicate the current value.
Example:
auto dial = new LineDial(10, 10, 100, 100, "Position:");
dial.range(0, 360);
dial.value = 180;this(int x, int y, int width, int height, string label = null)Creates a new line dial widget.Counter type constants.
These values define the visual style of counter widgets.
Counter widget with increment/decrement buttons.
Counter widgets provide +/- buttons for adjusting numeric values. The NORMAL type has 4 buttons (including fast increment), while the SIMPLE type has only 2 buttons.
Example:
auto counter = new Counter(10, 10, 150, 25, "Count:");
counter.value = 10;
counter.step = 1;CounterPtr _counterHandlethis(int x, int y, int width, int height, string label = null)Simple counter widget with only 2 buttons.
SimpleCounter is a convenience class that creates a Counter with the SIMPLE type preset. Unlike the normal counter, it has only two buttons (+/-) without the fast increment buttons.
Example:
auto counter = new SimpleCounter(10, 10, 150, 25, "Count:");
counter.value = 10;
counter.step = 1;this(int x, int y, int width, int height, string label = null)Creates a new simple counter widget.2D positioner widget for selecting X/Y coordinates.
Positioner provides a 2D input interface where the user can click and drag to select X and Y coordinate values simultaneously. The crosshairs indicate the current position.
Example:
auto pos = new Positioner(10, 10, 100, 100, "Position:");
pos.xbounds(0, 100);
pos.ybounds(0, 100);
pos.xvalue = 50;
pos.yvalue = 50;PositionerPtr _posHandlethis(int x, int y, int width, int height, string label = null)Creates a new positioner widget.Scrollbar widget.
Scrollbar widgets for scrolling content.
Example:
auto scrollbar = new Scrollbar(10, 10, 20, 200);
scrollbar.value = 0;ScrollbarPtr _scrollbarHandlethis(int x, int y, int width, int height, string label = null)Value input widget for numeric values.
ValueInput widgets provide a text field for entering numeric values.
Example:
auto input = new ValueInput(10, 10, 100, 25, "Value:");
input.value = 42.5;ValueInputPtr _valueInputHandlethis(int x, int y, int width, int height, string label = null)Value output widget for displaying numeric values.
ValueOutput widgets display read-only numeric values.
Example:
auto output = new ValueOutput(10, 10, 100, 25, "Result:");
output.value = 123.45;ValueOutputPtr _valueOutputHandlethis(int x, int y, int width, int height, string label = null)Adjuster widget with arrow buttons.
Adjuster widgets provide arrows for incrementing/decrementing values.
Example:
auto adjuster = new Adjuster(10, 10, 75, 25, "Adjust:");
adjuster.value = 0.5;AdjusterPtr _adjusterHandlethis(int x, int y, int width, int height, string label = null)Read-only text output widget.
Output widgets display text that cannot be edited by the user.
Example:
auto output = new Output(10, 10, 200, 25, "Status:");
output.value = "Ready";OutputPtr _outputHandlethis(int x, int y, int width, int height, string label = null)Progress bar widget.
Progress widgets display a progress bar showing completion percentage.
Example:
auto progress = new Progress(10, 10, 200, 25, "Loading:");
progress.minimum = 0;
progress.maximum = 100;
progress.value = 50;ProgressPtr _progressHandlethis(int x, int y, int width, int height, string label = null)Chart type enumeration.
Defines the visual style of a Chart widget.
Chart widget for displaying simple charts.
Chart widgets display data as bar charts, line charts, pie charts, etc. Data values can be added, inserted, replaced, and cleared dynamically.
Example:
auto chart = new Chart(10, 10, 300, 200, "Sales");
chart.chartType = ChartType.BAR;
chart.add(10.0, "Q1");
chart.add(25.0, "Q2");
chart.add(15.0, "Q3");
chart.add(30.0, "Q4");ChartPtr _chartHandlevoid clear()Clears all data from the chart.void add(double val, string label = null, uint col = 0)Adds a data value to the chart.void insert(int index, double val, string label = null, uint col = 0)Inserts a data value at a specific index.void replace(int index, double val, string label = null, uint col = 0)Replaces a data value at a specific index.void setBounds(double lower, double upper)Sets the chart bounds.void maxsize(int m)Sets the maximum number of data values for the chart.void textfont(int f)Sets the chart's text font.void textsize(int s)Sets the chart's text size.void textcolor(uint c)Sets the chart's text color.void autosize(bool enabled)Sets whether the chart auto-sizes its bounds.this(int x, int y, int width, int height, string label = null)Creates a new chart widget.Clock type enumeration.
Defines the visual style of a Clock widget.
Analog clock widget.
Clock widgets display an analog clock face with hour, minute, and second hands. The clock automatically updates every second to show the current time.
Example:
auto clock = new Clock(10, 10, 200, 200, "Time");
clock.clockType = ClockType.ROUND;ClockPtr _clockHandlevoid value(ulong v)Sets the clock's value as Unix time.void setTime(int h, int m, int s)Sets the clock's value using hour, minute, second.this(int x, int y, int width, int height, string label = null)Creates a new clock widget.Round analog clock widget.
RoundClock is a convenience class that creates a Clock with ROUND type preset. It displays a circular analog clock face with hour, minute, and second hands.
Example:
auto clock = new RoundClock(10, 10, 200, 200, "Time");this(int x, int y, int width, int height, string label = null)Creates a new round clock widget.Color chooser display mode.
Defines how color values are displayed in the ColorChooserWidget.
Embeddable color chooser widget.
ColorChooserWidget provides a standard RGB color chooser that can be embedded in any window or group. It includes a hue/saturation box, a value slider, and input fields for precise color entry.
The widget supports multiple display modes (RGB, byte, hex, HSV) and provides both RGB and HSV color access methods.
Example:
auto colorChooser = new ColorChooserWidget(10, 10, 300, 200);
colorChooser.rgb(1.0, 0.0, 0.0); // Set to red
// Later, get the selected color
double r = colorChooser.r;
double g = colorChooser.g;
double b = colorChooser.b;ColorChooserPtr _colorChooserHandleColorChooserPtr colorChooserHandle() @safe nothrow @nogcReturns the underlying color chooser handle.void mode(ColorChooserMode m)Sets the color chooser display mode.bool hsv(double h, double s, double v)Sets the color using HSV values.bool rgb(double red, double green, double blue)Sets the color using RGB values.double[3] hsv2rgb(double h, double s, double v)Converts HSV color values to RGB.double[3] rgb2hsv(double r, double g, double b)Converts RGB color values to HSV.this(int x, int y, int width, int height, string label = null)Creates a new color chooser widget.~thisDestroys the color chooser and releases resources.