garage44.eu/jeroen/pinnacle

logclone: git clone https://garage44.eu/jeroen/pinnacle.git

.. /docs/interface.md

raw

Interfaces: apps built from views

Pinnacle's interface library is Mithril (code.garage44.eu/jeroen/mithril), the same library the web and Cartopolis use, taken without std and with no code from outside our own repositories. An app describes its screen as a view — elements, the component library's classes, signals for what changes — and pinnacle-view (view/) styles it, lays it out for the window, draws it and turns input into the view's events. A new app, or an app being rebuilt, is built this way; hand-placed rectangles (pinnacle_layout) and immediate drawing (pinnacle_ui::theme) are what the older apps still use, and each moves over when a session works on it.

On views so far: the home screen, About, Settings, Clock, Notes, Calculator, the Store, Contacts, Files, Fien, Paint, Messages, Calls, Bluetooth, the terminal, and the display server's password, question and notification list. Still drawn by hand: the status bar, the home bar and the banner.

An app

let mut app = App::new("Clock");
let mut screen = Screen::new(app.width, app.height);
let seconds = signal(now());
screen.mount(page(seconds.clone()));        // el("main")…, the library's classes
screen.draw(&mut app.canvas(), true);
app.present_all();
loop {
    match app.next_event(deadline) {
        Event::Input(e) => {
            screen.input(&e);              // clicks reach the view's handlers
            if let Some(area) = screen.draw(&mut app.canvas(), false) {
                app.present(area);          // only what changed
            }
        }
        Event::Shown(true) | Event::Resized => { screen.resize(app.width, app.height); /* draw all */ }
        Event::Clipboard(text) => { screen.paste(&text); }
        …
    }
}

Facts that bit