Examples

Examples

[edit | edit source]

The repository includes a small collection of examples that are useful both as smoke tests and as reference code for application authors.

Minimal PlexyUI example

[edit | edit source]

The following example is based on examples/hello_uikit.c:

#include <plexy_ui.h>
#include <stdio.h>

static void on_click(uint32_t widget_id, void* userdata) {
    printf("Button clicked! (widget %u)\n", widget_id);
}

int main(void) {
    PlexyApp* app = plexy_app_create("Hello UIKit");
    PlexyWindow* win = plexy_window_create(app, 400, 300, "Hello PlexyDesk");
    uint32_t root = plexy_window_root(win);

    plexy_padding(win, root, 24, 24, 24, 24);
    plexy_gap(win, root, 16);
    plexy_justify(win, root, PLEXY_JUSTIFY_CENTER);
    plexy_align(win, root, PLEXY_ALIGN_CENTER);

    uint32_t title = plexy_label(win, root, "Welcome to PlexyDesk UIKit");
    plexy_set_text_color_hex(win, title, "#1f2937");

    uint32_t btn = plexy_button(win, root, "Click Me");
    plexy_set_fill_color_hex(win, btn, "#3b82f6");
    plexy_set_text_color_hex(win, btn, "#ffffff");
    plexy_on_click(win, btn, on_click, NULL);

    plexy_app_run(app);
    plexy_app_destroy(app);
    return 0;
}

Build and run:

gcc -o hello_uikit hello_uikit.c -L../lib -lplexyui
./hello_uikit

Useful example files

[edit | edit source]
File Why it is useful
examples/hello_uikit.c Smallest usable PlexyUI program
examples/hello_client.c Lightweight client-side entry point
examples/canvas_demo.c Canvas and rendering-oriented example
examples/drawer_demo.c Drawer and interaction example
examples/plexy_dock.c Dock-related shell UI ideas
examples/settings_panel.c Structured settings-style interface
examples/showcase_demo.c Broader demonstration page for the toolkit
examples/widget_demo.c Widget coverage and visual output

What to learn from the examples

[edit | edit source]
  • how to create an application and a root window
  • how layout is controlled with padding, gap, justify, align, and rows or columns
  • how to style widgets with color, radius, elevation, and glass-related helpers
  • how to bind click and value callbacks
  • how client programs fit into the compositor model

Next step

[edit | edit source]

After reading the examples, continue with Developer Guide and Architecture.