Skip to content
/ rim Public

Experimental Immediate-mode UI library in C that renders down to native toolkit widgets using a Virtual DOM

License

Notifications You must be signed in to change notification settings

petabyt/rim

Repository files navigation

Rim

Retained ← Immediate Mode

Rim is an immediate-mode UI library that renders down to native retained-mode widgets. It's able to do this using a virtual DOM to diff UI trees and apply changes to a native toolkit window in real time.

If that doesn't make sense to you, imagine React.js but:

  • Replace Javascript with C
  • Replace JSX with imgui
  • Replace HTML/CSS with GTK, Cocoa, or any other UI toolkit

That's what Rim is.

Example

#include <stdio.h>
#include <rim.h>
int mymain(struct RimContext *ctx, void *arg) {
    int show_more = 0;
    while (rim_poll(ctx)) {
        if (im_begin_window("My Window", 500, 500)) {
            if (im_button("Button")) show_more = !show_more;
            if (show_more) im_label("Hello World");
            im_end_window();
        }
    }
    return 0;
}
int main(void) {
    return rim_start(mymain, NULL);
}

Modular backend

  • Rim is capable of supporting multiple different UI toolkits (backends).
  • currently LibUI is the only backend, but adding a Qt or wxWidgets backend would be trivial.
  • LibUI backend Supports Win32 (Windows Common Controls), MacOS (Cocoa), and Linux (GTK3)

Fast?

The tree builder and differ is fast enough that there should be virtually zero overhead for basic changes. (eg: text in a label changes) For more info see perf.

Compiling

Rim is compiled as a static library with the backend included. On Linux, libgtk-3-dev is required.

git clone https://github.com/petabyt/libui-dev.git --depth 1 --recurse-submodules
git clone https://github.com/petabyt/rim.git --depth 1 --recurse-submodules
cd rim
cmake -G Ninja -B build -DRIM_COMPILE_DEMOS=ON CMAKE_BUILD_TYPE=Debug
cmake --build build

Why?

See why.

Roadmap

  • Support tables
  • Widget Recycler
  • Support multiple sessions in one process
  • A way to handle RecyclerViews/tables
  • Qt backend
  • Jetpack Compose/Views backend

About

Experimental Immediate-mode UI library in C that renders down to native toolkit widgets using a Virtual DOM

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published