From 96e9d5ef47ef58a4f7b4c9b86bf899ec413d331b Mon Sep 17 00:00:00 2001 From: Mole Shang <135e2@135e2.dev> Date: Sat, 2 Mar 2024 20:47:02 +0800 Subject: ui: make about popup movable --- src/ui.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ui.c b/src/ui.c index 6a392c3..f3d006e 100644 --- a/src/ui.c +++ b/src/ui.c @@ -19,6 +19,7 @@ static nk_size pct; static bool show_app_about; static nfdchar_t *outPath; +static struct nk_rect about_dialog_bounds = {128, 64, 768, 512}; void load_ui(struct ui_struct *ui) { static char text[USHRT_MAX], box_buffer[UINT16_MAX], status_string[UCHAR_MAX]; @@ -69,9 +70,21 @@ void load_ui(struct ui_struct *ui) { if (show_app_about) { /* about popup */ - static struct nk_rect s = {128, 64, 798, 512}; - if (nk_popup_begin(ui->ctx, NK_POPUP_DYNAMIC, "About", NK_WINDOW_CLOSABLE, - s)) { + if (nk_popup_begin(ui->ctx, NK_POPUP_DYNAMIC, "About", + NK_WINDOW_CLOSABLE | NK_WINDOW_MOVABLE | + NK_WINDOW_DYNAMIC, + about_dialog_bounds)) { + about_dialog_bounds = nk_window_get_bounds(ui->ctx); + /* Pure magic calculated from experiments. + * I'll guess that 6 is the x border size, + * but really have no idea what 85 is. + * What's worse, it's related w/ font size. Jeez. + */ + about_dialog_bounds.x -= 6; + about_dialog_bounds.y -= 85; + // DEBUG_PRINT("w: %f, h: %f\n", nk_window_get_bounds(ui->ctx).x, + // nk_window_get_bounds(ui->ctx).y); + nk_layout_row_dynamic(ui->ctx, 30, 1); for (int i = 0; icon[i]; i++) nk_label(ui->ctx, icon[i], NK_TEXT_CENTERED); -- cgit v1.2.3