gs_ddt.h

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit b43d8e8eacd288061aa09f86d1beec7f1c0cc4c5
parent 0e52ba60f9e1f5e218f4481ab172fdf15922c01e
Author: Samdal <samdal@protonmail.com>
Date:   Thu, 20 Oct 2022 19:51:50 +0200

add gs_gui_rect setting

Diffstat:
Mgs_ddt.h | 12+++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/gs_ddt.h b/gs_ddt.h @@ -27,7 +27,7 @@ typedef struct gs_ddt_s { } gs_ddt_t; extern void gs_ddt_printf(gs_ddt_t* ddt, const char* fmt, ...); -extern void gs_ddt(gs_ddt_t* ddt, gs_gui_context_t* ctx, const gs_gui_selector_desc_t* desc); +extern void gs_ddt(gs_ddt_t* ddt, gs_gui_context_t* ctx, gs_gui_rect_t screen, const gs_gui_selector_desc_t* desc); // A gui context must be begun before this is ran #ifdef GS_DDT_IMPL @@ -52,18 +52,16 @@ gs_ddt_printf(gs_ddt_t* ddt, const char* fmt, ...) } void -gs_ddt(gs_ddt_t* ddt, gs_gui_context_t* ctx, const gs_gui_selector_desc_t* desc) +gs_ddt(gs_ddt_t* ddt, gs_gui_context_t* ctx, gs_gui_rect_t screen, const gs_gui_selector_desc_t* desc) { - gs_vec2 fb = ctx->framebuffer_size; - if (ddt->open) - ddt->y = gs_interp_linear(ddt->y, fb.y * ddt->size, ddt->open_speed); + ddt->y = gs_interp_linear(ddt->y, screen.h * ddt->size, ddt->open_speed); else if (!ddt->open && ddt->y > 0) ddt->y = gs_interp_linear(ddt->y, -1, ddt->close_speed); else if (!ddt->open) return; - if (gs_gui_window_begin_ex(ctx, "gs_ddt_content", gs_gui_rect(0, 0, fb.x, ddt->y - 24), NULL, NULL, + if (gs_gui_window_begin_ex(ctx, "gs_ddt_content", gs_gui_rect(screen.x, screen.y, screen.w, ddt->y - 24), NULL, NULL, GS_GUI_OPT_FORCESETRECT | GS_GUI_OPT_NOTITLE | GS_GUI_OPT_NORESIZE)) { gs_gui_layout_row(ctx, 1, (int[]){-1}, 0); gs_gui_text(ctx, ddt->tb); @@ -71,7 +69,7 @@ gs_ddt(gs_ddt_t* ddt, gs_gui_context_t* ctx, const gs_gui_selector_desc_t* desc) gs_gui_window_end(ctx); } - if (gs_gui_window_begin_ex(ctx, "gs_ddt_input", gs_gui_rect(0, ddt->y - 24, fb.x, 24), NULL, NULL, + if (gs_gui_window_begin_ex(ctx, "gs_ddt_input", gs_gui_rect(screen.x, ddt->y - 24, screen.w, 24), NULL, NULL, GS_GUI_OPT_FORCESETRECT | GS_GUI_OPT_NOTITLE | GS_GUI_OPT_NORESIZE)) { int len = strlen(ddt->cb); gs_gui_layout_row(ctx, 3, (int[]){14, len * 7+2, 10}, 0);