Overview
simple_vision is a comprehensive GUI toolkit for Eiffel that provides a fluent API for building desktop applications. It wraps EiffelVision2 with modern naming conventions, rich widgets, form validation, state machines, and Cairo graphics.
Part of the Simple Eiffel ecosystem.
Quick Start
Installation
- Set the environment variable:
export SIMPLE_EIFFEL=/d/prod - Add to your ECF file:
<library name="simple_vision" location="$SIMPLE_EIFFEL/simple_vision/simple_vision.ecf"/>
Hello World
class
MY_APP
inherit
SV_APPLICATION
create
make_and_launch
feature {NONE} -- Initialization
make_and_launch
do
default_create
launch
end
build_main_window
local
sv: SV_QUICK
do
create sv.make
main_window := sv.window ("My App")
.sized (400, 300)
.child (
sv.column_of (<<
sv.text ("Hello, simple_vision!"),
sv.button ("Click Me").on_click (agent handle_click)
>>)
.padding (20)
.spacing (10)
)
end
handle_click
do
print ("Button clicked!%N")
end
end
Widget Gallery
Basic Widgets
text, button, checkbox, radio_group, dropdown, list
Input Fields
text_field, password_field, decimal_field, masked_field
Range Widgets
slider, progress_bar, spin_box
Containers
row, column, grid, stack, tabs, splitter, card, scroll
Data Widgets
data_grid, tree
Application Chrome
menu_bar, toolbar, statusbar, dialog
Masked Fields
phone, email, date, credit_card, ssn, zip, ip_address, time
Graphics
canvas (Cairo), waveform, image
Widget Factory (SV_QUICK)
local
sv: SV_QUICK
do
create sv.make
-- Windows
sv.window ("Title")
-- Containers
sv.row -- Horizontal box
sv.column -- Vertical box
sv.row_of (<<widget1, widget2>>) -- Row with children
sv.tabs -- Tab panel
sv.horizontal_splitter -- Left/right split
-- Basic Widgets
sv.text ("Label text")
sv.button ("Click Me")
sv.text_field
sv.checkbox ("Enable feature")
sv.radios (<<"Option 1", "Option 2">>)
sv.dropdown_with (<<"Choice A", "Choice B">>)
-- Masked Fields (Phase 6.75)
sv.phone_field
sv.email_field
sv.date_field
sv.credit_card_field
-- Dialogs
sv.info_box ("Information message")
sv.question_box ("Are you sure?")
sv.open_file_dialog
sv.color_picker
end
Form Validation
simple_vision includes a form validation system with built-in rules for common scenarios.
local
sv: SV_QUICK
my_form: SV_FORM
do
create sv.make
my_form := sv.form
.add_field (sv.field ("username")
.widget (sv.text_field)
.required
.min_length (3)
.max_length (20))
.add_field (sv.field ("email")
.widget (sv.email_field)
.required)
.add_field (sv.field ("age")
.widget (sv.spin_box_range (18, 120))
.range (18, 120))
.on_valid (agent handle_submit)
end
Built-in Validation Rules
| Rule | Description |
|---|---|
required | Field must have a value |
min_length (n) | Minimum character length |
max_length (n) | Maximum character length |
range (min, max) | Numeric range validation |
email | Valid email format |
pattern (regex) | Custom regex pattern |
State Machines
Declarative UI state management with fluent API and JSON configuration support.
local
sv: SV_QUICK
machine: SV_STATE_MACHINE
do
create sv.make
-- Create programmatically
machine := sv.state_machine ("auth")
machine.state ("logged_out").described_as ("User not logged in").do_nothing
machine.state ("logging_in").described_as ("Authentication in progress").do_nothing
machine.state ("logged_in").described_as ("User authenticated").do_nothing
machine.on ("login").from_state ("logged_out").to ("logging_in").apply.do_nothing
machine.on ("success").from_state ("logging_in").to ("logged_in").apply.do_nothing
machine.on ("logout").from_state ("logged_in").to ("logged_out").apply.do_nothing
machine.set_initial ("logged_out")
-- Trigger transitions
machine.trigger ("login")
print ("Current state: " + machine.current_state.name + "%N")
-- Or load from JSON file
if attached sv.state_machine_from_file ("auth.json") as m then
m.trigger ("login")
end
end
Theming
Built-in support for dark mode, color schemes, and UI scaling.
local
sv: SV_QUICK
do
create sv.make
-- Dark mode
sv.set_dark_mode (True)
sv.toggle_dark_mode
-- Color schemes
sv.set_color_scheme ("blue")
sv.set_color_scheme ("green")
sv.set_color_scheme ("purple")
-- UI scaling
sv.set_ui_scale (1.25) -- 125%
sv.increase_ui_scale
sv.decrease_ui_scale
sv.reset_ui_scale
end
Cairo Graphics (Phase 7)
Custom drawing with Cairo integration and waveform visualization for audio applications.
local
sv: SV_QUICK
canvas: SV_CAIRO_CANVAS
do
create sv.make
-- Create drawing canvas
canvas := sv.canvas (400, 300)
.background_hex (0xFFFFFF)
.on_draw (agent draw_content)
-- Waveform display for audio
waveform := sv.waveform (300, 100)
.foreground_hex (0x3498DB)
.background_hex (0x2C3E50)
end
draw_content (a_context: CAIRO_CONTEXT)
do
a_context.set_color_hex (0x3498DB)
.fill_rect (10, 10, 100, 50)
.do_nothing
a_context.set_color_hex (0xE74C3C)
.stroke_circle (200, 150, 40)
.do_nothing
end
API Classes
| Category | Classes |
|---|---|
| Core | SV_APPLICATION, SV_QUICK, SV_ANY |
| Windows | SV_WINDOW |
| Containers | SV_ROW, SV_COLUMN, SV_BOX, SV_GRID, SV_STACK, SV_TAB_PANEL, SV_SPLITTER, SV_CARD, SV_SCROLL |
| Basic Widgets | SV_TEXT, SV_BUTTON, SV_CHECKBOX, SV_RADIO_GROUP, SV_DROPDOWN, SV_LIST, SV_SLIDER, SV_PROGRESS_BAR, SV_SPIN_BOX |
| Input Fields | SV_TEXT_FIELD, SV_PASSWORD_FIELD, SV_DECIMAL_FIELD, SV_MASKED_FIELD |
| Data Widgets | SV_DATA_GRID, SV_TREE |
| Application | SV_MENU_BAR, SV_MENU, SV_MENU_ITEM, SV_TOOLBAR, SV_TOOLBAR_BUTTON, SV_STATUSBAR |
| Dialogs | SV_DIALOG, SV_FILE_DIALOG, SV_MESSAGE_BOX, SV_COLOR_PICKER, SV_FONT_PICKER |
| Forms | SV_FORM, SV_FIELD, SV_VALIDATION_RULE |
| State | SV_STATE_MACHINE, SV_STATE, SV_TRANSITION |
| Graphics | SV_CAIRO_CANVAS, SV_WAVEFORM, SV_IMAGE |
| Styling | SV_THEME, SV_COLOR, SV_TOKENS |