Level 0, a view
isolen_run is the whole of main. It parses the standard arguments, opens the window and the device, calls your view whenever a frame is needed, and returns the process exit code once the window closes.
main.cpp
#include "isolenui/app/app.h"
#include "isolenui/kit/kit.h"
// level zero never touches a window or a frame, it only gets a view callback
// the engine runs whenever something on screen could have changed
static void draw(isolen_frame* f, void* user)
{
(void)user;
ui::ctx* u = f->ui;
// the shell body is already a ui::view, so this column scrolls with it
// once the window is too short for it
ui_box(u, ui::col().pad(24.0f).gap(12.0f))
{
ui::text(u, "isolen ui", ui::head(u));
ui::text(u, "a presentation engine's element and layout api",
ui::body(u));
if (ui::button(u, "quit")) {
isolen_quit(f->app);
}
}
}
int main(int argc, char** argv)
{
isolen_app_desc d = isolen_app_defaults();
d.title = "isolen ui demo";
d.width = 1280;
d.height = 720;
d.view = draw;
return isolen_run(&d, argc, argv);
}What the view receives
The view is an isolen_view_fn: it takes an isolen_frame* and the user pointer from the description. The frame carries everything this tick needs:
uiis the context to declare into. The shell has already calledui::beginand opened the root.listis agfx_listfor painting straight on top of what the tree draws.inputis this frame'sui::input.dtandtimeare in seconds.widthandheightare in logical units, andscaleis physical pixels per unit. See pixels and high DPI.zoomis the page magnification this frame is drawn at, 1 when not zoomed. See pinch zoom.fullscreenandmaximizedgive the window state, andwindow_changedis true on the frame either one changed. See window chrome.backendandnativeare for level two.
Internally, isolen_run is exactly level one: open, loop over isolen_next_frame calling the view, then close.