Ipe is a lightweight, cross-platform GUI framework for the Dryad programming language. It is inspired by Windows Forms and provides a simple, object-oriented API for building desktop applications.
Ipe uses a dual-layer architecture:
- Native Layer (
ipe/native): A C shared library (ipe.soon Linux,ipe.dllon Windows) that handles window creation, rendering, and event polling using system APIs (SDL2 on Linux, GDI/Win32 on Windows). - Dryad Layer (
ipe/lib): A Dryad wrapper library that uses FFI to communicate with the native layer and provides high-level classes likeForm,Button, andLabel.
- Cross-Platform: Runs on Linux (via SDL2) and Windows (via Win32 API).
- Object-Oriented: Class-based component system (
Form,Control, etc.). - Event-Driven: Built-in
EventEmitterpattern for handling UI events (clicks, key presses). - Dependency-Free Text: Includes a built-in bitmap font renderer, requiring no external font libraries.
- Lightweight: Minimal overhead and dependencies.
To use Ipe, you must first compile the native shared library.
- Install SDL2 development headers (e.g.,
sudo apt install libsdl2-dev). - Navigate to the native directory and compile:
cd ipe/native # You can use the provided Makefile: make # OR compile manually with gcc: gcc -shared -O2 -fPIC $(sdl2-config --cflags) ipe_helper_sdl2.c -o ipe.so -lSDL2
- Navigate to the native directory:
cd ipe/native - Compile using
gcc:gcc -shared -O2 ipe_helper.c -o ipe.dll -lgdi32 -luser32 -lkernel32
Import the library in your Dryad script:
import { Form, Button, Label, Application } from "ipe/lib/ipe.dryad"; function main() { // 1. Create the main form let form = new Form(); form.title = "My Ipe App"; form.width = 800; form.height = 600; // 2. Add a button let btn = new Button(); btn.text = "Click Me"; btn.x = 100; btn.y = 100; btn.width = 120; btn.height = 40; // 3. Add an event listener btn.on("click", function(data) { println("Button clicked!"); }); form.add(btn); // 4. Run the application loop Application.run(form); } main();
Base class for all UI components. Inherits from EventEmitter.
- Properties:
x,y: Position coordinates.width,height: Dimensions.text: Content text.backColor: Background color (hex format, e.g.,0xFF0000for red).visible: Boolean visibility state.foreColor: Foreground/Text color.
The main window container.
- Properties:
title: Window title bar text.controls: List of child controls.
- Methods:
add(control): Adds a child control to the form.
A clickable button component. Renders with a simple shadow effect and centered text.
A text display component. Uses the internal 8x8 bitmap font renderer.
Static class for managing the application lifecycle.
- Methods:
run(mainForm): Starts the main event loop. This method blocks until the window is closed.
ipe/lib/ipe.dryad: Core Dryad library implementation.ipe/native/: Native C source code.ipe_helper_sdl2.c: Linux/SDL2 backend.ipe_helper.c: Windows/GDI backend.font8x8_basic.h: Bitmap font data.
ipe/tests/: Example applications.demo.dryad: Interactive WinForms-style demo.
MIT License. See LICENSE for details.