diff -r 29d98cff4f56 -r 853685152c1d ui/common/types.c --- a/ui/common/types.c Sat Nov 11 12:22:16 2017 +0100 +++ b/ui/common/types.c Sun Nov 12 12:03:50 2017 +0100 @@ -223,6 +223,15 @@ return i; } +UiDouble* ui_double_new(UiContext *ctx, char *name) { + UiDouble *d = ui_malloc(ctx, sizeof(UiDouble)); + memset(d, 0, sizeof(UiDouble)); + if(name) { + uic_reg_var(ctx, name, UI_VAR_DOUBLE, d); + } + return d; +} + UiString* ui_string_new(UiContext *ctx, char *name) { UiString *s = ui_malloc(ctx, sizeof(UiString)); memset(s, 0, sizeof(UiString)); @@ -241,6 +250,15 @@ return t; } +UiRange* ui_range_new(UiContext *ctx, char *name) { + UiRange *r = ui_malloc(ctx, sizeof(UiRange)); + memset(r, 0, sizeof(UiRange)); + if(name) { + uic_reg_var(ctx, name, UI_VAR_RANGE, r); + } + return r; +} + // private functions void uic_int_copy(UiInteger *from, UiInteger *to) { @@ -249,6 +267,12 @@ to->obj = from->obj; } +void uic_double_copy(UiDouble *from, UiDouble *to) { + to->get = from->get; + to->set = from->set; + to->obj = from->obj; +} + void uic_string_copy(UiString *from, UiString *to) { to->get = from->get; to->set = from->set; @@ -289,6 +313,11 @@ i->value = i->get(i); } +void uic_double_save(UiDouble *d) { + if(!d->obj) return; + d->value = d->get(d); +} + void uic_string_save(UiString *s) { if(!s->obj) return; s->get(s); @@ -312,6 +341,12 @@ i->obj = NULL; } +void uic_double_unbind(UiDouble *d) { + d->get = NULL; + d->set = NULL; + d->obj = NULL; +} + void uic_string_unbind(UiString *s) { s->get = NULL; s->set = NULL;