cepheid

An Aurora 4X clone
Log | Files | Refs | README

commit ce2c86eaba85fe239a2a77581b716e3b5eb0fb21
parent f522707e3c4958b0a90ac6376623bb59d4d36a11
Author: hhvn <dev@hhvn.uk>
Date:   Mon,  3 Oct 2022 16:04:40 +0100

Each value in a dropdown can be associated with a void *

Diffstat:
Msrc/struct.h | 3++-
Msrc/uielem.c | 4++--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/struct.h b/src/struct.h @@ -158,7 +158,8 @@ typedef struct { int n; int sel; /* -1 for none */ char *placeholder; - char *val[DROPDOWN_MAX]; + char *str[DROPDOWN_MAX]; + void *val[DROPDOWN_MAX]; /* internal */ Geom rect; Pane pane; diff --git a/src/uielem.c b/src/uielem.c @@ -152,14 +152,14 @@ ui_dropdown(int x, int y, int w, Dropdown *d) { pane_begin(&d->pane); if (d->sel != -1) - ui_print(x + TPX, y + TPY, col_fg, "%s", d->val[d->sel]); + ui_print(x + TPX, y + TPY, col_fg, "%s", d->str[d->sel]); else if (d->placeholder) ui_print(x + TPX, y + TPY, col_info, "%s", d->placeholder); if (focused) { ui_draw_rectangle(x, y + h, w, fh - h, col_unselbg); for (i = 0; i < d->n; i++) { - ui_print(x + TPX, y + TPY + (i+1) * h, col_fg, "%s", d->val[i]); + ui_print(x + TPX, y + TPY + (i+1) * h, col_fg, "%s", d->str[i]); } }