move some files around
This commit is contained in:
parent
47c4f2045c
commit
cfe7501fe2
12 changed files with 78 additions and 49 deletions
|
|
@ -2,6 +2,7 @@ local ffi = require("ffi")
|
|||
local C = ffi.C
|
||||
local gfx = _pxl8_gfx
|
||||
local input = _pxl8_input
|
||||
local ui = _pxl8_ui
|
||||
|
||||
-- pxl8 lua api
|
||||
--
|
||||
|
|
@ -369,30 +370,30 @@ function pxl8.mat4_lookat(eye, center, up)
|
|||
return C.pxl8_mat4_lookat(eye_vec, center_vec, up_vec)
|
||||
end
|
||||
|
||||
pxl8.gfx = gfx
|
||||
pxl8.input = input
|
||||
pxl8.ui = _pxl8_ui
|
||||
|
||||
function pxl8.bounds(x, y, w, h)
|
||||
return ffi.new("pxl8_bounds", {x = x, y = y, w = w, h = h})
|
||||
end
|
||||
|
||||
function pxl8.ui_button(label)
|
||||
return C.pxl8_ui_button(_pxl8_ui, label)
|
||||
return C.pxl8_ui_button(ui, label)
|
||||
end
|
||||
|
||||
function pxl8.ui_checkbox(label, state)
|
||||
local state_ptr = ffi.new("bool[1]", state)
|
||||
local changed = C.pxl8_ui_checkbox(_pxl8_ui, label, state_ptr)
|
||||
local changed = C.pxl8_ui_checkbox(ui, label, state_ptr)
|
||||
return changed, state_ptr[0]
|
||||
end
|
||||
|
||||
function pxl8.ui_has_mouse_focus()
|
||||
return C.pxl8_ui_has_mouse_focus(ui)
|
||||
end
|
||||
|
||||
function pxl8.ui_indent(amount)
|
||||
C.pxl8_ui_indent(_pxl8_ui, amount)
|
||||
C.pxl8_ui_indent(ui, amount)
|
||||
end
|
||||
|
||||
function pxl8.ui_label(text)
|
||||
C.pxl8_ui_label(_pxl8_ui, text)
|
||||
C.pxl8_ui_label(ui, text)
|
||||
end
|
||||
|
||||
function pxl8.ui_layout_row(item_count, widths, height)
|
||||
|
|
@ -402,20 +403,20 @@ function pxl8.ui_layout_row(item_count, widths, height)
|
|||
elseif type(widths) == "number" then
|
||||
widths_array = ffi.new("int[1]", widths)
|
||||
end
|
||||
C.pxl8_ui_layout_row(_pxl8_ui, item_count, widths_array, height)
|
||||
C.pxl8_ui_layout_row(ui, item_count, widths_array, height)
|
||||
end
|
||||
|
||||
function pxl8.ui_window_begin(title, x, y, w, h, options)
|
||||
local rect = ffi.new("pxl8_bounds", {x = x, y = y, w = w, h = h})
|
||||
return C.pxl8_ui_window_begin(_pxl8_ui, title, rect, options or 0)
|
||||
return C.pxl8_ui_window_begin(ui, title, rect, options or 0)
|
||||
end
|
||||
|
||||
function pxl8.ui_window_end()
|
||||
C.pxl8_ui_window_end(_pxl8_ui)
|
||||
C.pxl8_ui_window_end(ui)
|
||||
end
|
||||
|
||||
function pxl8.ui_window_set_open(title, open)
|
||||
C.pxl8_ui_window_set_open(_pxl8_ui, title, open)
|
||||
C.pxl8_ui_window_set_open(ui, title, open)
|
||||
end
|
||||
|
||||
return pxl8
|
||||
|
|
|
|||
|
|
@ -334,6 +334,9 @@ SDL_AppResult SDL_AppIterate(void* appstate) {
|
|||
|
||||
if (app->ui) {
|
||||
pxl8_ui_input_mousemove(app->ui, app->input.mouse_x, app->input.mouse_y);
|
||||
if (app->input.mouse_wheel_x != 0 || app->input.mouse_wheel_y != 0) {
|
||||
pxl8_ui_input_scroll(app->ui, app->input.mouse_wheel_x * 10, -app->input.mouse_wheel_y * 10);
|
||||
}
|
||||
|
||||
pxl8_ui_frame_begin(app->ui);
|
||||
|
||||
|
|
|
|||
|
|
@ -174,6 +174,7 @@ static const char* pxl8_ffi_cdefs =
|
|||
"void pxl8_ui_input_text(pxl8_ui* ui, const char* text);\n"
|
||||
"bool pxl8_ui_button(pxl8_ui* ui, const char* label);\n"
|
||||
"bool pxl8_ui_checkbox(pxl8_ui* ui, const char* label, bool* state);\n"
|
||||
"bool pxl8_ui_has_mouse_focus(pxl8_ui* ui);\n"
|
||||
"void pxl8_ui_indent(pxl8_ui* ui, int amount);\n"
|
||||
"void pxl8_ui_label(pxl8_ui* ui, const char* text);\n"
|
||||
"void pxl8_ui_layout_row(pxl8_ui* ui, int item_count, const int* widths, int height);\n"
|
||||
|
|
|
|||
|
|
@ -137,8 +137,8 @@ pxl8_ui* pxl8_ui_create(pxl8_gfx* gfx) {
|
|||
ui->mu_ctx.style->colors[9] = (mu_Color){2, 0, 0, 255};
|
||||
ui->mu_ctx.style->colors[10] = (mu_Color){3, 0, 0, 255};
|
||||
ui->mu_ctx.style->colors[11] = (mu_Color){10, 0, 0, 255};
|
||||
ui->mu_ctx.style->colors[12] = (mu_Color){7, 0, 0, 255};
|
||||
ui->mu_ctx.style->colors[13] = (mu_Color){8, 0, 0, 255};
|
||||
ui->mu_ctx.style->colors[12] = (mu_Color){1, 0, 0, 255};
|
||||
ui->mu_ctx.style->colors[13] = (mu_Color){3, 0, 0, 255};
|
||||
|
||||
return ui;
|
||||
}
|
||||
|
|
@ -194,6 +194,11 @@ void pxl8_ui_input_text(pxl8_ui* ui, const char* text) {
|
|||
mu_input_text(&ui->mu_ctx, text);
|
||||
}
|
||||
|
||||
bool pxl8_ui_has_mouse_focus(pxl8_ui* ui) {
|
||||
if (!ui) return false;
|
||||
return ui->mu_ctx.hover_root != NULL;
|
||||
}
|
||||
|
||||
bool pxl8_ui_button(pxl8_ui* ui, const char* label) {
|
||||
if (!ui) return false;
|
||||
return mu_button(&ui->mu_ctx, label) & MU_RES_SUBMIT;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ void pxl8_ui_destroy(pxl8_ui* ui);
|
|||
void pxl8_ui_frame_begin(pxl8_ui* ui);
|
||||
void pxl8_ui_frame_end(pxl8_ui* ui);
|
||||
|
||||
bool pxl8_ui_button(pxl8_ui* ui, const char* label);
|
||||
bool pxl8_ui_checkbox(pxl8_ui* ui, const char* label, bool* state);
|
||||
bool pxl8_ui_has_mouse_focus(pxl8_ui* ui);
|
||||
void pxl8_ui_indent(pxl8_ui* ui, i32 amount);
|
||||
void pxl8_ui_input_keydown(pxl8_ui* ui, i32 key);
|
||||
void pxl8_ui_input_keyup(pxl8_ui* ui, i32 key);
|
||||
void pxl8_ui_input_mousedown(pxl8_ui* ui, i32 x, i32 y, i32 button);
|
||||
|
|
@ -59,10 +63,6 @@ void pxl8_ui_input_mousemove(pxl8_ui* ui, i32 x, i32 y);
|
|||
void pxl8_ui_input_mouseup(pxl8_ui* ui, i32 x, i32 y, i32 button);
|
||||
void pxl8_ui_input_scroll(pxl8_ui* ui, i32 x, i32 y);
|
||||
void pxl8_ui_input_text(pxl8_ui* ui, const char* text);
|
||||
|
||||
bool pxl8_ui_button(pxl8_ui* ui, const char* label);
|
||||
bool pxl8_ui_checkbox(pxl8_ui* ui, const char* label, bool* state);
|
||||
void pxl8_ui_indent(pxl8_ui* ui, i32 amount);
|
||||
void pxl8_ui_label(pxl8_ui* ui, const char* text);
|
||||
void pxl8_ui_layout_row(pxl8_ui* ui, i32 item_count, const i32* widths, i32 height);
|
||||
i32 pxl8_ui_menu(pxl8_ui* ui, pxl8_menu_item* items, i32 item_count);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue