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.
What This Example Demonstrates
Fl_Flex provides modern, flexible layouts similar to CSS Flexbox:- Horizontal and vertical arrangements
- Automatic widget sizing and spacing
- Fixed and flexible widget sizes
- Gap control between widgets
- Nested layouts for complex UIs
- Responsive resizing behavior
Simple Example
Source file:examples/howto-flex-simple.cxx
Compilation Command
Expected Behavior
- Horizontal row of buttons with consistent spacing
- “File”, “New”, and “Save” buttons have equal size
- Empty space in the middle (fixed 30 pixels + gaps)
- “Exit” button on the right
- All resize proportionally when window is resized
- Minimum window width enforced (300 pixels)
Key Concepts
Creating Fl_Flex
Fixed vs Flexible Widgets
Gap Control
Advanced Login Form Example
Source file:test/flex_login.cxx (simplified)
Compilation
Variations and Extensions
Toolbar Layout
Three-Panel Layout
Controlling Individual Widget Behavior
Dynamic Resizing
Comparison: Manual vs Fl_Flex Layout
Manual Positioning (Old Way)
Fl_Flex (New Way)
Best Practices
- Use Fl_Flex for toolbars and button rows - perfect use case
- Nest Fl_Flex containers for complex layouts
- Use empty Fl_Box widgets as spacers
- Set fixed sizes for widgets that shouldn’t resize
- Call layout() after dynamically changing visibility
- Use gap() and margin() instead of manual spacing
- Make the Fl_Flex resizable for responsive windows
Next Steps
- Compare with Fl_Grid layout
- Learn about responsive design
- See custom widgets