summaryrefslogtreecommitdiff
path: root/src/ui.c
diff options
context:
space:
mode:
authorMole Shang <[email protected]>2024-03-02 20:47:02 +0800
committerMole Shang <[email protected]>2024-03-02 20:47:02 +0800
commit96e9d5ef47ef58a4f7b4c9b86bf899ec413d331b (patch)
treece04137d01a92e364450d4d7f242005db453ff14 /src/ui.c
parentcf31015f6a3cc205cb682f154478599b36040382 (diff)
downloadhinata-96e9d5ef47ef58a4f7b4c9b86bf899ec413d331b.tar.gz
hinata-96e9d5ef47ef58a4f7b4c9b86bf899ec413d331b.tar.bz2
hinata-96e9d5ef47ef58a4f7b4c9b86bf899ec413d331b.zip
ui: make about popup movable
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c19
1 files 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);