Repository navigation
OpenECS-examples 0.8.0
Pre-releaseOpenECS-examples 0.8.0 adds two examples: c15_board, a board of blocks and wires, and s26_history, undo and redo with the History panel. Every example now runs on LuaJIT 2.1, and its Lua panels are objects of a class. The release has the examples built for Linux and Windows.
It comes out with OpenECS 0.8.0, which ships these examples, built, in its examples/ folder, and OpenECS-std 0.8.0, whose plugins they use.
Run an example from OpenECS's folder:
./OpenECS --fresh --preset examples/c15_board/preset.luaWhat you can learn
A board. c15_board is a board of blocks and wires, built with ui's board, in Lua and in C. A click, Ctrl and a rectangle choose blocks; a drag and the arrows move them; a drag from an output's pin to an input's wires them. The wheel zooms, and the middle button moves the view. A Show block has a picture made in memory, whose grey follows its value.
History. s26_history keeps a tally's changes in a history, in Lua and in C. Ctrl+Z undoes, Ctrl+Y and Ctrl+Shift+Z redo, and a drag is one record. The History panel goes to a record at a click, and follows the focused panel. A panel without a history of its own uses the tool's default one.
LuaJIT. The examples give FFI arrays to C as buffers, without copying them: s2_media's samples, s4_model's and s10_cglm's points, s8_gpu's pixels and s9_gpu_model's vertices. sketch_lua builds its image in a string.buffer. c13_workers sends its messages as string.buffer's bytes. c14_structs and s10_cglm use a C plugin's structs as cdata, with fields, methods and operators. s24_profiler finds a Lua function, wave, in the profile.
Classes. Each example's Lua panel keeps its state in an object of its class, with its functions as methods. c1_hello explains the class.
Drawing again on events. A panel type names the events that draw it again. c7_events and c5_services show it from Lua and from C, and s3_network, s5_files, s6_web, s14_gamepad, s17_notify and s25_keys keep no table of their panels.
The GPU. s8_gpu draws gpu's rounded rectangles, circles, rings, clips inside clips and bold text, in Lua and in C. c3_ui and s22_viewer draw on the GPU; their preset_pixels.lua draws them into pixels.
ui. c3_ui shows, in Lua and in C:
- icons, and labels of words and icons, such as a Lock button;
- marks in a tree, such as a lock that a click turns;
- a tree and a list of many rows that build only the rows in view;
- a dropdown of 40 items, and text cut at two lines;
- tooltips, also on each choice of a selector;
- a menu of the panel, with a heading, a line, a dimmed entry and a submenu;
- a finder of ui's elements in a popup, whose rows drag onto the panel;
- a tree that refuses a drop inside itself, and marks where a drop lands;
- an image of draw beside a title, made again for each tint.
Its callbacks follow their meaning: a selector, tabs and dropdowns call onChange only when the choice changes.
Popups. c11_popups opens a submenu beside its menu, and a finder from a field in the title bar, in Lua and in C. A menu at the window's edge stays inside it.
Drag and drop. c9_drag_drop marks where a dragged colour will land, in Lua and in C, and its palette moves its own colours.
Files. s5_files shows a tree of folders beside the grid. It copies a file dropped from a file manager into the folder, and Show in Files shows a note in the panel. watcher and watcher_c watch a folder and the folders inside it, in Lua and in C. The notes use fs in place of io and os, and delete to the trash.
A whole tool. c12_sketch binds Ctrl+H for each plugin, in all its panels. Its highlight is yellow for one run only, through the settings' run layer. Each canvas counts its unsaved changes in a badge. showCanvas focuses an open canvas or opens one. useBrush takes nil to go back to the settings' brush.
Keys. c6_keys binds keys for a plugin, and its panel type's key wins over the plugin's. s25_keys binds a key after the prefix, Alt+W then C, and adds an entry to the menu Tools.
The console. s23_console's entries name their source, which a checkbox hides. The Show dropdown chooses the levels, and Sort the order. A hidden console shows a badge in the colour of its worst entry.
Logs and sessions. c7_events and c4_settings hear the log through ecs.logged. c8_state opens a saved session that names its preset, and takes the preset's menus, keys and settings again.
The viewer. s22_viewer puts Previous, Next and Slideshow in the title bar. Its text shows line numbers, and a mark on the rows that a long line wraps into.
First-party plugins. s7_first_party shows that a manifest that is not valid is left out of the plugin list, and why. It opens the settings window at a setting with settings.show, and walks every theme.
Small fixes
s6_webserves on port 47210, so its test runs besides3_network's.s3_networklistens on 127.0.0.1 with a free port, ands13_processgives programs variables.c10_text_input's field shows an italic hint while it is empty.s17_notify's tray icon is its ownicon.png.c13_workersstops its workers when its plugin is disabled, and counts again when it is enabled.shuild.cprints its flags with--help.
What will break
Plugin API 4. Every example's plugin says api = 4, and needs OpenECS 0.8.0. Code copied from 0.7.0 must change as OpenECS's and OpenECS-std's releases say: Lua is LuaJIT 2.1, so buffers are FFI arrays and string.pack is gone; structs, such as cglm's vectors, are cdata; workers' messages cannot hold functions; and ui's callbacks follow their meaning.
Downloads
openecs-examples-0.8.0-linux-x86_64.tar.gzandopenecs-examples-0.8.0-windows-x86_64.zip: the examples built. Unpack one into an OpenECS 0.8.0 folder.openecs-examples-0.8.0-source.tar.gz: the examples' source. Build them inside a checkout of OpenECS, as its README.md says.SHA256SUMS: checksums of the archives.
The examples are under the 0BSD license.