From 2cf0707c3ed1bc3849ec3927ce04c8f540baf018 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 18 Aug 2015 19:57:16 -0400 Subject: [PATCH] Set up work for rearranging control layout to be depth-first and to relayout the entire window on a change. --- redo/reredo/control.c | 15 +++++++++++++++ redo/reredo/darwin/control.m | 9 +++++---- redo/reredo/ui_darwin.h | 4 ++-- redo/reredo/uipriv.h | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/redo/reredo/control.c b/redo/reredo/control.c index c713dc17..cbd59ecd 100644 --- a/redo/reredo/control.c +++ b/redo/reredo/control.c @@ -42,6 +42,21 @@ uiControl *uiControlParent(uiControl *c) return cb->parent; } +// returns self if self is a window +uiControl *toplevelOwning(uiControl *c) +{ + struct controlBase *cb; + + for (;;) { + if (uiIsA(c, uiWindowType(), 0) != NULL) + return c; + cb = controlBase(c); + if (cb->parent == NULL) + return NULL; + c = cb->parent; + } +} + static void controlUpdateState(uiControl *); void uiControlSetParent(uiControl *c, uiControl *parent) diff --git a/redo/reredo/darwin/control.m b/redo/reredo/darwin/control.m index edbeb24d..2e638930 100644 --- a/redo/reredo/darwin/control.m +++ b/redo/reredo/darwin/control.m @@ -10,14 +10,15 @@ uintmax_t uiDarwinControlType(void) return type_uiDarwinControl; } -void uiDarwinControlRelayoutParent(uiDarwinControl *c) +void uiDarwinControlTriggerRelayout(uiDarwinControl *c) { uiControl *p; - p = uiControlParent(uiControl(c)); - if (p == NULL) + p = toplevelOwning(uiControl(c)); + if (p == NULL) // not in a window return; - (*(uiDarwinControl(p)->Relayout))(uiDarwinControl(p)); + c = uiDarwinControl(p); + (*(c->Relayout))(uiDarwinControl(c)); } void osCommitShow(uiControl *c) diff --git a/redo/reredo/ui_darwin.h b/redo/reredo/ui_darwin.h index d8d10d37..e70f8aa3 100644 --- a/redo/reredo/ui_darwin.h +++ b/redo/reredo/ui_darwin.h @@ -15,7 +15,7 @@ struct uiDarwinControl { _UI_EXTERN uintmax_t uiDarwinControlType(void); #define uiDarwinControl(this) ((uiDarwinControl *) uiIsA((this), uiDarwinControlType(), 1)) // TODO document -_UI_EXTERN void uiDarwinControlRelayoutParent(uiDarwinControl *); +_UI_EXTERN void uiDarwinControlTriggerRelayout(uiDarwinControl *); // TODO document #define uiDarwinDefineControlWithOnDestroy(type, typefn, handlefield, onDestroy) \ @@ -42,7 +42,7 @@ _UI_EXTERN void uiDarwinControlRelayoutParent(uiDarwinControl *); } \ static void _ ## type ## Relayout(uiDarwinControl *c) \ { \ - uiDarwinControlRelayoutParent(uiDarwinControl(c)); \ + /* do nothing */ \ } #define uiDarwinDefineControl(type, typefn, handlefield) \ diff --git a/redo/reredo/uipriv.h b/redo/reredo/uipriv.h index f244031f..87eadb84 100644 --- a/redo/reredo/uipriv.h +++ b/redo/reredo/uipriv.h @@ -15,6 +15,8 @@ extern void uiFree(void *); extern void complain(const char *, ...); +extern uiControl *toplevelOwning(uiControl *); + extern void osCommitShow(uiControl *); extern void osCommitHide(uiControl *); extern void osCommitEnable(uiControl *);