GUI to ruby

This commit is contained in:
John Alanbrook 2022-08-04 01:49:56 +00:00
parent 9d34354a80
commit a296b77c45
4 changed files with 18 additions and 2 deletions

View file

@ -421,8 +421,8 @@ static void edit_mouse_cb(GLFWwindow *w, int button, int action, int mods)
}
}
struct nk_context *ctx;
struct nk_glfw nkglfw = {0};
static struct nk_context *ctx;
static struct nk_glfw nkglfw = {0};
void editor_init(struct mSDLWindow *window)
{

View file

@ -7,6 +7,9 @@
extern mrb_state *mrb;
#include "nuklear.h"
extern struct nk_context *ctx;
int fib(int n) {
if (n < 2) return n;
@ -28,8 +31,16 @@ mrb_value mrb_load(mrb_state *mrb, mrb_value self) {
return self;
}
mrb_value mrb_ui_label(mrb_state *mrb, mrb_value self) {
char *str;
mrb_get_args(mrb, "z", &str);
nk_labelf(ctx, NK_TEXT_LEFT, "%s", str);
return self;
}
void ffi_load() {
mrb_define_method(mrb, mrb->object_class, "fib", mrb_fib, MRB_ARGS_REQ(1));
mrb_define_method(mrb, mrb->object_class, "load", mrb_load, MRB_ARGS_REQ(1));
mrb_define_method(mrb, mrb->object_class, "ui_label", mrb_ui_label, MRB_ARGS_REQ(1));
}

View file

@ -41,3 +41,7 @@ void script_update() {
void script_draw() {
mrb_funcall(mrb, obj, "draw", 0);
}
void script_editor() {
mrb_funcall(mrb, obj, "editor", 0);
}

View file

@ -6,5 +6,6 @@ void script_run(const char *script);
void script_dofile(const char *file);
void script_update();
void script_draw();
void script_editor();
#endif