diff options
author | Mole Shang <[email protected]> | 2024-03-02 20:47:02 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2024-03-02 20:47:02 +0800 |
commit | 96e9d5ef47ef58a4f7b4c9b86bf899ec413d331b (patch) | |
tree | ce04137d01a92e364450d4d7f242005db453ff14 | |
parent | cf31015f6a3cc205cb682f154478599b36040382 (diff) | |
download | hinata-96e9d5ef47ef58a4f7b4c9b86bf899ec413d331b.tar.gz hinata-96e9d5ef47ef58a4f7b4c9b86bf899ec413d331b.tar.bz2 hinata-96e9d5ef47ef58a4f7b4c9b86bf899ec413d331b.zip |
ui: make about popup movable
-rw-r--r-- | src/ui.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -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); |