Blank - C UI Library
- 5 Devlogs
- 23 Total hours
Blank is a modern, minimalist ui library with a flexible backend. It is implemented in c with minimal dependencies and build requirements.
Blank is a modern, minimalist ui library with a flexible backend. It is implemented in c with minimal dependencies and build requirements.
The colors used in blank are no longer hardcoded and can now instead be determined while building the ui.
After resolving some issues that annoyed me in the last devlog, I was finally able to start adding more ui elements. The first of which was an image component (Displaying the fancy logo here).
Elements are now clickable. This works through an if check in the app loop that allows you to execute code based on the id of a ui element or the mouse button used.
I wanna add more ui elements and also layouts so people can do things like adding side panels and stuff lol. Might also work on making the existing components and overally style prettier.
Devlog - Rewriting the ui arranging and fixing bad multithreading code
Fixing bad multithreading code
I spent a lot of time recently debugging and fixing issues related to the multithreading code in blank.
Most of the issues were related to missing mutex locks or use-after-frees. They would lead to random crashes at runtime
without sufficient error messages. Using Thread-Sanitizer i was able to address most of them.
Rewriting the layout arranging code
Previously, layout arranging, the process of ordering and placing elements in the ui using a given layout, relied heavily on using ratios
and relative sizes to determine the position and size of individual elements. I have now rewritten the ui element layout process to use
absolute sizes which makes the system more reliable and less prone to floating point errors. I was also able to massively simplify the process,
which will hopefully result in better performance overall.
Next up
Next, i wanna improve the memory management and rely more on arena allocators for things like ui elements and render commands. This will
probably mean including mutexes to make the allocators that are used on multiple threads thread-safe.
I also wanna improve the api (header) to use a single file rather than being split into multiple files.
Groups allow you to group elements with a custom layout. They are stored in an array and then submitted to the regular layout, while still stored in the group component.
To achieve nested layouts i rewrote the way layouts are built to have them first calculate the minimum size of each component, then see what share of the screen they take up and then scale them so the entire screen is covered. While this is not fully functional yet, it allows for nested layouts in the first place. The group components are then flattened and submitted to the regular renderable ui components for rendering.
Next up im gonna work on polishing this, adding vertical support and refining the system to properly calculate how much of the screen gets taken up.
The basic system for ui-elements is now in place as can be seen by the button example. UI Elements need to be submitted, then the layout will be rebuilt and they are assigned their positions and sizes, unless specified directly. They are then rendered.
Some of the next ui components will be labels, text-fields and groups
Layouts allow you to customise the placement of components in a group or at the base ui building.
Right now, only the linear layout is implemented, but in the future i plan on adding grid-layouts and more probably lol
You are now able to handle events like window closing and window resizing in the app thread to rebuild the ui when required.
Next up, im gonna be working on implementing ui-groups and inner layouts for them.
Devlog: Implementing blank’s basic infrastructure
I started by adding a relatively flexible backend system, that allows you to use any backend for rendering, thread-handling… by passing in a single initializer function.
I also implemented very basic multi-threading, and task separation since the intention is to make it a ui with state.
Next up, I will probably work on getting basic ui element submission and rendering working.