Skip to content

Commit

Permalink
Port mu_slider
Browse files Browse the repository at this point in the history
  • Loading branch information
ashn-dot-dev committed Oct 28, 2023
1 parent c35c362 commit df77901
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <microui.h>
#include <murl.h>

float slider = 0.0;
int checked = 0;
char buf[256] = {0};

Expand All @@ -50,6 +51,8 @@ int main(void) {

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

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

mu_label(ctx, "Hello, raylib");

if (mu_button(ctx, "The button")) {
Expand Down
3 changes: 3 additions & 0 deletions demo.sunder
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "microui.sunder";
import "murl.sunder";
import "smolui.sunder";

var slider: float = 0.0;
var checked: sint = 0;
var buf = (:[256]byte)[0...];

Expand All @@ -32,6 +33,8 @@ func main() void {

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

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

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

if (mu_button(ctx, startof("The button")) != 0) {
Expand Down
4 changes: 4 additions & 0 deletions microui.sunder
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "c";

let MU_SLIDER_FMT = startof("%.2f");

alias MU_CLIP = enum {
MU_CLIP_PART = 1;
MU_CLIP_ALL;
Expand Down Expand Up @@ -92,6 +94,7 @@ extern func mu_end(ctx: *mu_Context) void;

func mu_button(ctx: *mu_Context, label: *char) sint { return mu_button_ex(ctx, label, 0, (:sint)MU_OPT_ALIGNCENTER); }
func mu_textbox(ctx: *mu_Context, buf: *char, bufsz: sint) sint { return mu_textbox_ex(ctx, buf, bufsz, 0); }
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_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 @@ -100,6 +103,7 @@ extern func mu_button_ex(ctx: *mu_Context, label: *char, icon: sint, opt: sint)
extern func mu_checkbox(ctx: *mu_Context, label: *char, state: *sint) sint;
extern func mu_textbox_raw(ctx: *mu_Context, buf: *char, bufsz: sint, id: mu_Id, r: mu_Rect, opt: sint) sint;
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_begin_window_ex(ctx: *mu_Context, title: *char, rect: mu_Rect, opt: sint) sint;
extern func mu_end_window(ctx: *mu_Context) void;
extern func mu_open_popup(ctx: *mu_Context, name: *char) void;
Expand Down

0 comments on commit df77901

Please sign in to comment.