diff --git a/redo/containerctrls_darwin.go b/redo/containerctrls_darwin.go index 4c70cce..ef834ad 100644 --- a/redo/containerctrls_darwin.go +++ b/redo/containerctrls_darwin.go @@ -19,6 +19,7 @@ func newTab() Tab { t := new(tab) id := C.newTab(unsafe.Pointer(t)) t.controlbase = newControl(id) + t.fpreferredSize = t.tabpreferredSize return t } @@ -32,7 +33,12 @@ func (t *tab) Append(name string, control Control) { s.child.setParent(&controlParent{tabview}) } -// no need to override Control.allocate() as only prepared the tabbed control; its children will be reallocated when that one is resized +func (t *tab) tabpreferredSize(d *sizing) (width, height int) { + s := C.tabPrefSize(t.id) + return int(s.width), int(s.height) +} + +// no need to override Control.commitResize() as only prepared the tabbed control; its children will be reallocated when that one is resized //export tabResized func tabResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) { diff --git a/redo/control_darwin.go b/redo/control_darwin.go index 8248fd9..bb24337 100644 --- a/redo/control_darwin.go +++ b/redo/control_darwin.go @@ -30,8 +30,8 @@ func newControl(id C.id) *controlbase { } c.fallocate = baseallocate(c) c.fpreferredSize = func(d *sizing) (int, int) { - // TODO - return 64, 32 + s := C.controlPrefSize(c.id) + return int(s.width), int(s.height) } c.fcommitResize = func(a *allocation, d *sizing) { //TODO diff --git a/redo/objc_darwin.h b/redo/objc_darwin.h index 20a2c4f..d5c81f3 100644 --- a/redo/objc_darwin.h +++ b/redo/objc_darwin.h @@ -81,6 +81,7 @@ struct xalignment { intptr_t baseline; }; extern struct xsize controlPrefSize(id); +extern struct xsize tabPrefSize(id); extern struct xsize areaPrefSize(id); extern struct xalignment alignmentInfo(id, struct xrect); diff --git a/redo/xsizing_darwin.m b/redo/xsizing_darwin.m index 12faf4b..6ad95f0 100644 --- a/redo/xsizing_darwin.m +++ b/redo/xsizing_darwin.m @@ -4,6 +4,7 @@ #import #define toNSControl(x) ((NSControl *) (x)) +#define toNSTabView(x) ((NSTabView *) (x)) #define toNSScrollView(x) ((NSScrollView *) (x)) #define toNSView(x) ((NSView *) (x)) @@ -24,6 +25,19 @@ struct xsize controlPrefSize(id control) return s; } +struct xsize tabPrefSize(id control) +{ + NSTabView *tv; + NSSize s; + struct xsize t; + + tv = toNSTabView(control); + s = [tv minimumSize]; + t.width = (intptr_t) s.width; + t.height = (intptr_t) s.height; + return t; +} + // TODO use this, possibly update to not need scrollview /* struct xsize areaPrefSize(id scrollview)