ui/common/types.c

branch
newapi
changeset 337
2904fba2708b
parent 325
99a93a9250c4
equal deleted inserted replaced
336:56c12f44c2d3 337:2904fba2708b
279 uic_reg_var(ctx, name, UI_VAR_RANGE, r); 279 uic_reg_var(ctx, name, UI_VAR_RANGE, r);
280 } 280 }
281 return r; 281 return r;
282 } 282 }
283 283
284 UIEXPORT UiGeneric* ui_generic_new(UiContext *ctx, char *name) {
285 UiGeneric *g = ui_malloc(ctx, sizeof(UiGeneric));
286 memset(g, 0, sizeof(UiGeneric));
287 if(name) {
288 uic_reg_var(ctx, name, UI_VAR_GENERIC, g);
289 }
290 return g;
291 }
292
284 293
285 void ui_int_set(UiInteger* i, int64_t value) { 294 void ui_int_set(UiInteger* i, int64_t value) {
286 if (i && i->set) { 295 if (i && i->set) {
287 i->set(i, value); 296 i->set(i, value);
288 } 297 }
387 void uic_list_copy(UiList *from, UiList *to) { 396 void uic_list_copy(UiList *from, UiList *to) {
388 to->update = from->update; 397 to->update = from->update;
389 to->obj = from->obj; 398 to->obj = from->obj;
390 } 399 }
391 400
401 void uic_generic_copy(UiGeneric *from, UiGeneric *to) {
402 to->get = from->get;
403 to->get_type = from->get_type;
404 to->set = from->set;
405 to->obj = from->obj;
406 }
392 407
393 void uic_int_save(UiInteger *i) { 408 void uic_int_save(UiInteger *i) {
394 if(!i->obj) return; 409 if(!i->obj) return;
395 i->value = i->get(i); 410 i->value = i->get(i);
396 } 411 }
412 } 427 }
413 428
414 void uic_range_save(UiRange *r) { 429 void uic_range_save(UiRange *r) {
415 if(!r->obj) return; 430 if(!r->obj) return;
416 r->get(r); 431 r->get(r);
432 }
433
434 void uic_generic_save(UiGeneric *g) {
435 if(!g->obj) return;
436 g->get(g);
417 } 437 }
418 438
419 439
420 void uic_int_unbind(UiInteger *i) { 440 void uic_int_unbind(UiInteger *i) {
421 i->get = NULL; 441 i->get = NULL;
460 void uic_list_unbind(UiList *l) { 480 void uic_list_unbind(UiList *l) {
461 l->update = NULL; 481 l->update = NULL;
462 l->obj = NULL; 482 l->obj = NULL;
463 } 483 }
464 484
485 void uic_generic_unbind(UiGeneric *g) {
486 g->get = NULL;
487 g->get_type = NULL;
488 g->set = NULL;
489 g->obj = NULL;
490 }
491
465 492
466 UIEXPORT UiListSelection ui_list_getselection(UiList *list) { 493 UIEXPORT UiListSelection ui_list_getselection(UiList *list) {
467 if (list->getselection) { 494 if (list->getselection) {
468 return list->getselection(list); 495 return list->getselection(list);
469 } 496 }

mercurial