Mon, 08 Dec 2025 18:11:54 +0100
add server base structs
| application/demo_bindings.c | file | annotate | diff | comparison | revisions | |
| application/main.c | file | annotate | diff | comparison | revisions | |
| ui/common/message.c | file | annotate | diff | comparison | revisions | |
| ui/common/message.h | file | annotate | diff | comparison | revisions | |
| ui/server/image.c | file | annotate | diff | comparison | revisions | |
| ui/server/image.h | file | annotate | diff | comparison | revisions | |
| ui/server/objs.mk | file | annotate | diff | comparison | revisions | |
| ui/server/toolkit.c | file | annotate | diff | comparison | revisions | |
| ui/server/toolkit.h | file | annotate | diff | comparison | revisions | |
| ui/server/widget.c | file | annotate | diff | comparison | revisions | |
| ui/server/widget.h | file | annotate | diff | comparison | revisions | |
| ui/server/window.c | file | annotate | diff | comparison | revisions | |
| ui/server/window.h | file | annotate | diff | comparison | revisions | |
| ui/ui/toolkit.h | file | annotate | diff | comparison | revisions |
--- a/application/demo_bindings.c Mon Dec 08 16:21:24 2025 +0100 +++ b/application/demo_bindings.c Mon Dec 08 18:11:54 2025 +0100 @@ -32,7 +32,7 @@ #include <stdlib.h> #include <string.h> -#if !defined(UI_WIN32) +#if !defined(UI_WIN32) && !defined(UI_SERVER) Document* document_create(int id) { Document* doc = ui_document_new(sizeof(Document)); @@ -171,10 +171,6 @@ ui_show(obj); } -#endif - -#ifndef UI_WIN32 - int main(int argc, char **argv) { ui_init(NULL, argc, argv); ui_onstartup(application_startup, NULL); @@ -184,8 +180,18 @@ #else +#ifndef UI_WIN32 + +int main(int argc, char **argv) { + return 0; +} + +#else + int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { return 0; } -#endif \ No newline at end of file +#endif + +#endif
--- a/application/main.c Mon Dec 08 16:21:24 2025 +0100 +++ b/application/main.c Mon Dec 08 18:11:54 2025 +0100 @@ -178,7 +178,7 @@ #endif -#if !defined(UI_COCOA) && !defined(UI_MOTIF) && !defined(UI_WIN32) && !defined(UI_QT) && !defined(UI_TEST) +#if !defined(UI_COCOA) && !defined(UI_MOTIF) && !defined(UI_WIN32) && !defined(UI_QT) && !defined(UI_TEST) && !defined(UI_SERVER) typedef struct { UiString *str1; @@ -1288,3 +1288,11 @@ #endif +#ifdef UI_SERVER + +void main(int argc, char **argv) { + +} + + +#endif
--- a/ui/common/message.c Mon Dec 08 16:21:24 2025 +0100 +++ b/ui/common/message.c Mon Dec 08 18:11:54 2025 +0100 @@ -116,8 +116,9 @@ // message complete //fprintf(stderr, "send: %.*s\n", (int)msg_size, msg); if(handler->handler.callback) { - handler->handler.callback(cx_mutstrn(msg, msg_size)); + handler->handler.callback(cx_strn(msg, msg_size)); } + free(msg); msg = NULL; msg_size = 0; msg_pos = 0;
--- a/ui/common/message.h Mon Dec 08 16:21:24 2025 +0100 +++ b/ui/common/message.h Mon Dec 08 18:11:54 2025 +0100 @@ -46,7 +46,7 @@ typedef struct UiMessageHandler UiMessageHandler; -typedef void(*msg_received_callback)(cxmutstr msg); +typedef void(*msg_received_callback)(cxstring msg); struct UiMessageHandler { int (*start)(UiMessageHandler *handler);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/server/image.c Mon Dec 08 18:11:54 2025 +0100 @@ -0,0 +1,37 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "image.h" + +void ui_image_ref(UIIMAGE img) { + +} + +void ui_image_unref(UIIMAGE img) { + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/server/image.h Mon Dec 08 18:11:54 2025 +0100 @@ -0,0 +1,46 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef IMAGE_H +#define IMAGE_H + +#include "../ui/image.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + + +#ifdef __cplusplus +} +#endif + +#endif /* IMAGE_H */ +
--- a/ui/server/objs.mk Mon Dec 08 16:21:24 2025 +0100 +++ b/ui/server/objs.mk Mon Dec 08 18:11:54 2025 +0100 @@ -30,6 +30,8 @@ SERVER_OBJPRE = $(OBJ_DIR)$(SERVER_SRC_DIR) SERVEROBJ = toolkit.o +SERVEROBJ += widget.o +SERVEROBJ += image.o TOOLKITOBJS += $(SERVEROBJ:%=$(SERVER_OBJPRE)%) TOOLKITSOURCE += $(SERVEROBJ:%.o=SERVER/%.c)
--- a/ui/server/toolkit.c Mon Dec 08 16:21:24 2025 +0100 +++ b/ui/server/toolkit.c Mon Dec 08 18:11:54 2025 +0100 @@ -75,3 +75,24 @@ } ui_queue_free(event_queue); } + +typedef struct CallMain { + UiServerEvent event; + ui_threadfunc func; + void *data; +} CallMain; + +static void mainthr(UiServerEventData *event, void *userdata) { + CallMain *c = userdata; + if(c->func) { + c->func(c->data); + } + free(c); +} + +void ui_call_mainthread(ui_threadfunc tf, void* td) { + CallMain *c = malloc(sizeof(CallMain)); + c->func = tf; + c->data = td; + ui_queue_put(event_queue, c); +}
--- a/ui/server/toolkit.h Mon Dec 08 16:21:24 2025 +0100 +++ b/ui/server/toolkit.h Mon Dec 08 18:11:54 2025 +0100 @@ -34,15 +34,20 @@ #include "../common/context.h" #include "../common/object.h" +#include <cx/list.h> #include <cx/string.h> #ifdef __cplusplus extern "C" { #endif +typedef struct UiSrvObj UiSrvObj; + typedef struct UiServerEvent UiServerEvent; typedef struct UiServerEventData UiServerEventData; typedef void(*ui_srvevent_func)(UiServerEventData *event, void *userdata); + +typedef cxmutstr (*ui_serialize_func)(UiWidget *w); struct UiServerEventData { UiObject *obj; @@ -56,6 +61,23 @@ void *userdata; }; +struct UiSrvObj { + cxmutstr id; +}; + +struct UiWidget { + UiSrvObj *obj; + cxmutstr id; + UiVar *var; + cxmutstr var_id; + UiVarType var_type; + CxList *children; + cxmutstr args; + UiBool visible; + UiBool enabled; + ui_serialize_func *serialize; +}; + void ui_server_message_received(cxstring msg);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/server/widget.c Mon Dec 08 18:11:54 2025 +0100 @@ -0,0 +1,38 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "widget.h" + + +void ui_set_enabled(UIWIDGET widget, int enabled) { + +} + +void ui_set_visible(UIWIDGET widget, int visible) { + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/server/widget.h Mon Dec 08 18:11:54 2025 +0100 @@ -0,0 +1,46 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WIDGET_H +#define WIDGET_H + +#include "../ui/widget.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + + +#ifdef __cplusplus +} +#endif + +#endif /* WIDGET_H */ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/server/window.c Mon Dec 08 18:11:54 2025 +0100 @@ -0,0 +1,30 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "window.h" +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/server/window.h Mon Dec 08 18:11:54 2025 +0100 @@ -0,0 +1,47 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WINDOW_H +#define WINDOW_H + +#include "../ui/window.h" +#include "toolkit.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + + +#ifdef __cplusplus +} +#endif + +#endif /* WINDOW_H */ +
--- a/ui/ui/toolkit.h Mon Dec 08 16:21:24 2025 +0100 +++ b/ui/ui/toolkit.h Mon Dec 08 18:11:54 2025 +0100 @@ -148,8 +148,10 @@ #elif UI_SERVER -#define UIWIDGET void* -#define UIWINDOW void* +typedef struct UiWidget UiWidget; + +#define UIWIDGET UiWidget* +#define UIWINDOW UiWidget* #define UIMENU void* #endif