From 204f450ff8823b8d33cb8a54015d43e0e996c2ec Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 14 Apr 2015 09:41:52 -0400 Subject: [PATCH] More parent planning and related API changes. I now have a better handle over what I want after last night: p.SetChild() is only called by w.SetChild() and the various uiTab and uiGroup methods; everything else should call Control.SetParent(). Some renaming is needed. --- parentplan | 20 +++++++++++++++++--- ui.h | 6 +++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/parentplan b/parentplan index 80f6eb9d..9f817b5c 100644 --- a/parentplan +++ b/parentplan @@ -27,13 +27,27 @@ c.Add(h) p.Update() c.Resize() d.Remove(1) - f.RemoveParent() + f.SetParent(NULL) p.Update() c.Resize() g.Hide() p.Update() c.Resize() w.SetChild(i) - ????????????? + p.SetChild(i) + c.SetParent(NULL) + d.SetParent(NULL) + ... + i.SetParent(p) + ... + p.Update() + i.Resize() +w.SetChild(NULL) + p.SetChild(NULL) + i.SetParent(NULL) + p.Update() +w.SetChild(i) + (again) w.Destroy() - ????????????? + p.Destroy() + i.Destroy() diff --git a/ui.h b/ui.h index f82e8005..d7facff8 100644 --- a/ui.h +++ b/ui.h @@ -41,7 +41,6 @@ struct uiControl { void (*destroy)(uiControl *); uintptr_t (*handle)(uiControl *); void (*setParent)(uiControl *, uiParent *); - void (*removeParent)(uiControl *); void (*preferredSize)(uiControl *, uiSizing *, intmax_t *, intmax_t *); void (*resize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *); int (*visible)(uiControl *); @@ -57,7 +56,6 @@ struct uiControl { void uiControlDestroy(uiControl *); uintptr_t uiControlHandle(uiControl *); void uiControlSetParent(uiControl *, uiParent *); -void uiControlRemoveParent(uiControl *); void uiControlPreferredSize(uiControl *, uiSizing *, intmax_t *width, intmax_t *height); void uiControlResize(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *); int uiControlVisible(uiControl *); @@ -90,7 +88,9 @@ struct uiParent { // The uiParent should already not have a child and the uiControl should already not have a parent. // // child can be NULL, in which case the uiParent has no children. - // This form should be called by uiControl.RemoveParent(). + // This version should also call uiControl.SetParent(), passing NULL. + // + // If this uiParent has a child already, then the current child is replaced with the new one. void (*SetChild)(uiParent *p, uiControl *child); #define uiParentSetChild(p, child) ((*((p)->SetChild))((p), (child)))