diff -r dbde25a5bc53 -r c03c338a7dcf ui/common/context.h --- a/ui/common/context.h Tue Jan 24 18:46:47 2017 +0100 +++ b/ui/common/context.h Fri Nov 10 17:17:14 2017 +0100 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 2014 Olaf Wintermann. All rights reserved. + * Copyright 2017 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: @@ -43,17 +43,29 @@ typedef struct UiListVar UiListVar; typedef struct UiGroupWidget UiGroupWidget; +typedef enum UiVarType UiVarType; + +enum UiVarType { + UI_VAR_SPECIAL = 0, + UI_VAR_INTEGER, + UI_VAR_STRING, + UI_VAR_TEXT, + UI_VAR_LIST, + UI_VAR_RANGE +}; + struct UiContext { UiContext *parent; UiObject *obj; UcxMempool *mempool; + UcxMap *bound; // key: char* value: UiVar* UcxMap *vars; // key: char* value: UiVar* void *document; UcxList *groups; // int list UcxList *group_widgets; // UiGroupWidget* list void (*set_document)(UiContext *ctx, void *document); - void (*detach_document)(UiContext *ctx, void *document); + void (*detach_document)(UiContext *ctx); char *title; @@ -66,18 +78,10 @@ }; struct UiVar { - void *value; - int type; - int isextern; - UcxMap *from; -}; - -struct UiListPtr { - UiList *list; -}; - -struct UiListVar { - UiListPtr *listptr; + void *value; + void *orig_val; + UiVarType type; + UiVar *from; }; struct UiGroupWidget { @@ -86,30 +90,22 @@ int numgroups; }; -enum UiVarType { - UI_VAR_INTEGER = 0, - UI_VAR_STRING, - UI_VAR_TEXT, - UI_VAR_LIST -}; UiContext* uic_context(UiObject *toplevel, UcxMempool *mp); UiContext* uic_root_context(UiContext *ctx); void uic_context_set_document(UiContext *ctx, void *document); -void uic_context_detach_document(UiContext *ctx, void *document); +void uic_context_detach_document(UiContext *ctx); + +//UiVar* uic_get_var(UiContext *ctx, char *name); +UiVar* uic_create_var(UiContext *ctx, char *name, UiVarType type); +void* uic_create_value(UiContext *ctx, UiVarType type); -UiVar* uic_get_var(UiContext *ctx, char *name); -UiVar* uic_connect_var(UiContext *ctx, char *name, int type); -void uic_move_var(UiVar *from, UiVar *to, UiBool set); -void uic_reg_var(UiContext *ctx, char *name, int type, size_t vs, void *value); -void uic_add_var( - UiContext *ctx, - char *name, - UiVar *newvar, - int type, - size_t vs); +void uic_copy_binding(UiVar *from, UiVar *to, UiBool copytodoc); +void uic_unbind_var(UiVar *var); -void* uic_create_value(UcxAllocator *a, int type); +void uic_reg_var(UiContext *ctx, char *name, UiVarType type, void *value); + +void uic_remove_bound_var(UiContext *ctx, UiVar *var); void uic_check_group_widgets(UiContext *ctx); void uic_add_group_widget(UiContext *ctx, void *widget, UcxList *groups);