# HG changeset patch # User Olaf Winermann # Date 1749451276 -7200 # Node ID a5b393e766c4248e5b1ae3177251b432d09aa157 # Parent 7255f59f339a12598b78771cb4164c83e1acf880 add ui_image_set/ui_image_get for setting UiGeneric image values diff -r 7255f59f339a -r a5b393e766c4 ui/common/types.c --- a/ui/common/types.c Sun Jun 08 23:47:00 2025 +0200 +++ b/ui/common/types.c Mon Jun 09 08:41:16 2025 +0200 @@ -36,6 +36,7 @@ #include "../ui/tree.h" #include "types.h" #include "context.h" +#include "../ui/image.h" @@ -395,6 +396,28 @@ } } +void ui_image_set(UiGeneric *g, void *img) { + // TODO: ref? + if(g->set) { + g->set(g, img, UI_IMAGE_OBJECT_TYPE); + } else { + g->value = img; + g->type = UI_IMAGE_OBJECT_TYPE; + } +} + +void* ui_image_get(UiGeneric *g) { + if(g->type) { + if(!strcmp(g->type, UI_IMAGE_OBJECT_TYPE)) { + return g->value; + } else { + return NULL; + } + } + return g->value; +} + + char* ui_text_get(UiText* s) { if (s) { return s->get ? s->get(s) : s->value.ptr; diff -r 7255f59f339a -r a5b393e766c4 ui/ui/toolkit.h --- a/ui/ui/toolkit.h Sun Jun 08 23:47:00 2025 +0200 +++ b/ui/ui/toolkit.h Mon Jun 09 08:41:16 2025 +0200 @@ -558,6 +558,8 @@ UIEXPORT char* ui_string_get(UiString *s); UIEXPORT void ui_text_set(UiText *s, const char* value); UIEXPORT char* ui_text_get(UiText *s); +UIEXPORT void ui_image_set(UiGeneric *g, void *img); +UIEXPORT void* ui_image_get(UiGeneric *g); UIEXPORT void ui_var_set_int(UiContext *ctx, const char *name, int64_t value); UIEXPORT int64_t ui_var_get_int(UiContext *ctx, const char *name);