Skip to content

Commit

Permalink
Port treenode functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ashn-dot-dev committed Oct 29, 2023
1 parent 056fe79 commit f83c037
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
21 changes: 14 additions & 7 deletions demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,26 @@ int main(void) {
murl_handle_input(ctx);
mu_begin(ctx);

if (mu_begin_window(ctx, "Hello", mu_rect(20, 20, 200, 150))) {
if (mu_header(ctx, "Header")) {
mu_text(ctx, "text");
if (mu_begin_window(ctx, "Hello", mu_rect(20, 20, 400, 300))) {
mu_text(ctx, "text");

mu_checkbox(ctx, "checkbox", &checked);
mu_checkbox(ctx, "checkbox", &checked);

mu_slider(ctx, &slider, 0.0, 100.0);
mu_slider(ctx, &slider, 0.0, 100.0);

mu_number(ctx, &number, 2.0);
}
mu_number(ctx, &number, 2.0);

mu_label(ctx, "Hello, raylib");

if (mu_header(ctx, "Header")) {
mu_text(ctx, "text under header");
}

if (mu_begin_treenode(ctx, "Treenode")) {
mu_text(ctx, "text under treenode");
mu_end_treenode(ctx);
}

if (mu_button(ctx, "The button")) {
mu_open_popup(ctx, "popup");
}
Expand Down
21 changes: 14 additions & 7 deletions demo.sunder
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,26 @@ func main() void {
murl_handle_input(ctx);
mu_begin(ctx);

if mu_begin_window(ctx, startof("Hello"), (:mu_Rect){.x = 20, .y = 20, .w = 200, .h = 150}) != 0 {
if (mu_header(ctx, startof("Header")) != 0) {
mu_text(ctx, startof("text"));
if mu_begin_window(ctx, startof("Hello"), (:mu_Rect){.x = 20, .y = 20, .w = 400, .h = 300}) != 0 {
mu_text(ctx, startof("text"));

mu_checkbox(ctx, startof("checkbox"), &checked);
mu_checkbox(ctx, startof("checkbox"), &checked);

mu_slider(ctx, &slider, 0.0, 100.0);
mu_slider(ctx, &slider, 0.0, 100.0);

mu_number(ctx, &number, 2.0);
}
mu_number(ctx, &number, 2.0);

mu_label(ctx, startof("Hello, raylib"));

if (mu_header(ctx, startof("Header")) != 0) {
mu_text(ctx, startof("text under header"));
}

if (mu_begin_treenode(ctx, startof("Treenode")) != 0) {
mu_text(ctx, startof("text under treenode"));
mu_end_treenode(ctx);
}

if (mu_button(ctx, startof("The button")) != 0) {
mu_open_popup(ctx, startof("popup"));
}
Expand Down
3 changes: 3 additions & 0 deletions microui.sunder
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func mu_textbox(ctx: *mu_Context, buf: *char, bufsz: sint) sint { return mu_text
func mu_slider(ctx: *mu_Context, value: *mu_Real, lo: mu_Real, hi: mu_Real) sint { return mu_slider_ex(ctx, value, lo, hi, 0.0, MU_SLIDER_FMT, (:sint)MU_OPT_ALIGNCENTER); }
func mu_number(ctx: *mu_Context, value: *mu_Real, step: mu_Real) sint { return mu_number_ex(ctx, value, step, MU_SLIDER_FMT, (:sint)MU_OPT_ALIGNCENTER); }
func mu_header(ctx: *mu_Context, label: *char) sint { return mu_header_ex(ctx, label, 0); }
func mu_begin_treenode(ctx: *mu_Context, label: *char) sint { return mu_begin_treenode_ex(ctx, label, 0); }
func mu_begin_window(ctx: *mu_Context, title: *char, rect: mu_Rect) sint { return mu_begin_window_ex(ctx, title, rect, 0); }

extern func mu_text(ctx: *mu_Context, text: *byte) void;
Expand All @@ -107,6 +108,8 @@ extern func mu_textbox_raw(ctx: *mu_Context, buf: *char, bufsz: sint, id: mu_Id,
extern func mu_textbox_ex(ctx: *mu_Context, buf: *char, bufsz: sint, opt: sint) sint;
extern func mu_slider_ex(ctx: *mu_Context, value: *mu_Real, low: mu_Real, high: mu_Real, step: mu_Real, fmt: *char, opt: sint) sint;
extern func mu_number_ex(ctx: *mu_Context, value: *mu_Real, step: mu_Real, fmt: *char, opt: sint) sint;
extern func mu_begin_treenode_ex(ctx: *mu_Context, label: *char, opt: sint) sint;
extern func mu_end_treenode(ctx: *mu_Context) void;
extern func mu_header_ex(ctx: *mu_Context, label: *char, opt: sint) sint;
extern func mu_begin_window_ex(ctx: *mu_Context, title: *char, rect: mu_Rect, opt: sint) sint;
extern func mu_end_window(ctx: *mu_Context) void;
Expand Down

0 comments on commit f83c037

Please sign in to comment.