Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacob-c-smith/ui
Callback driven user interface library written with SDL2
https://github.com/jacob-c-smith/ui
api c gui json open-source system-programming ui
Last synced: 14 days ago
JSON representation
Callback driven user interface library written with SDL2
- Host: GitHub
- URL: https://github.com/jacob-c-smith/ui
- Owner: Jacob-C-Smith
- License: mit
- Created: 2022-01-06T21:55:43.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-21T06:49:53.000Z (8 months ago)
- Last Synced: 2024-05-22T02:59:38.180Z (8 months ago)
- Topics: api, c, gui, json, open-source, system-programming, ui
- Language: C
- Homepage: https://g10.app/status/
- Size: 1.85 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UI
##### **This project is still incomplete. This notice will be removed when the project is polished to my liking**
![UI window example](Window.png)This simple callback driven UI library implements many UI elements, like labels, buttons, and dropdowns to name a few. UI element colors are customizable, and the user configurations are stored nontemporally in AppData. Windows and UI elements are constructed at run time from JSON files.
## Window JSON
Here's the source for the above window:```json
{
"name" : "Test window",
"width" : 800,
"height" : 720,
"elements" : [
{
"type" : "LABEL",
"name" : "label",
"text" : "Label",
"x" : 16,
"y" : 16,
"size" : 1
},
{
"type" : "CHECKBOX",
"name" : "checkbox",
"x" : 16,
"y" : 32,
"labels" : [
"Checkbox 1",
"Checkbox 2",
"Checkbox 3"
],
"checked" : [
false,
false,
false
]
},
{
"type" : "BUTTON",
"name" : "button",
"label" : "Button",
"x" : 16,
"y" : 96
},
{
"type" : "DROPDOWN",
"name" : "dropdown",
"x" : 16,
"y" : 80,
"options" : [
"Option 1",
"Option 2",
"Option 3"
],
"index" : -1,
"collapsed" : true
},
{
"type" : "RADIO BUTTON",
"name" : "radiobutton",
"x" : 16,
"y" : 112,
"labels" : [
"Radio button 1",
"Radio button 2",
"Radio button 3"
],
"index" : 0
},
{
"type" : "LABEL",
"name" : "label 2",
"text" : "An Image:",
"x" : 16,
"y" : 180,
"size" : 1
},
{
"type" : "IMAGE",
"name" : "image",
"x" : 16,
"y" : 192,
"width" : 768,
"height" : 512,
"path" : "image.png"
},
{
"type" : "TEXT INPUT",
"name" : "text input",
"x" : 16,
"y" : 160,
"width" : 80,
"height" : 14,
"placeholder" : "Text Input",
"length" : 255
},
{
"type" : "LABEL",
"name" : "label 3",
"text" : "A Table:",
"x" : 160,
"y" : 16,
"size" : 1
},
{
"type" : "TABLE",
"name" : "element table",
"x" : 160,
"y" : 32,
"max rows" : 5,
"max columns" : 3
}
]
}
```
[ [UI Window JSON](window.json) ]## A minimal program written with the UI library
```c
#includeint main ( int argc, const char **argv )
{
// Initialized data
ui_instance *p_ui_instance = 0;
ui_window *p_ui_window = 0;// Initialize the UI library
ui_init(&p_ui_instance, "");// Load a window from the filesystem
load_window(&p_ui_window, "window.json");// Add the window to the instance
ui_append_window(p_ui_instance, p_ui_window);// Start running
p_ui_instance->running = true;// Loop
while (p_ui_instance->running)
{
// Process input
ui_process_input(p_ui_instance);// Draw windows
ui_draw(p_ui_instance);
}// Exit the UI library
ui_exit(p_ui_instance);return 1;
}
```