diff --git a/redo/control_darwin.go b/redo/control_darwin.go index c92ed75..b3b3dcf 100644 --- a/redo/control_darwin.go +++ b/redo/control_darwin.go @@ -34,8 +34,7 @@ func dobasecommitResize(id C.id, c *allocation, d *sizing) { } func basegetAuxResizeInfo(c controlPrivate, d *sizing) { - id := c.id() - d.neighborAlign = C.alignmentInfo(id, C.frame(id)) + d.neighborAlign = C.alignmentInfoFrame(c.id()) } type scroller struct { diff --git a/redo/objc_darwin.h b/redo/objc_darwin.h index b95cc07..99089fc 100644 --- a/redo/objc_darwin.h +++ b/redo/objc_darwin.h @@ -96,7 +96,7 @@ extern id newScrollView(id, BOOL); /* xsizing_darwin.m */ extern struct xalignment alignmentInfo(id, struct xrect); -extern struct xrect frame(id); +extern struct xalignment alignmentInfoFrame(id); /* area_darwin.h */ extern Class getAreaClass(void); diff --git a/redo/xsizing_darwin.m b/redo/xsizing_darwin.m index 56c55b4..1c9f123 100644 --- a/redo/xsizing_darwin.m +++ b/redo/xsizing_darwin.m @@ -8,20 +8,14 @@ #define toNSScrollView(x) ((NSScrollView *) (x)) #define toNSView(x) ((NSView *) (x)) -// TODO figure out where these should go +// TODO figure out where this should go -// this function is safe to call on Areas; it'll just return the frame and a baseline of 0 since it uses the default NSView implementations -struct xalignment alignmentInfo(id c, struct xrect newrect) +// these function are safe to call on Areas; they'll just return the frame and a baseline of 0 since they use the default NSView implementations + +static struct xalignment doAlignmentInfo(NSView *v, NSRect r) { - NSView *v; struct xalignment a; - NSRect r; - v = toNSView(c); - r = NSMakeRect((CGFloat) newrect.x, - (CGFloat) newrect.y, - (CGFloat) newrect.width, - (CGFloat) newrect.height); r = [v alignmentRectForFrame:r]; a.rect.x = (intptr_t) r.origin.x; a.rect.y = (intptr_t) r.origin.y; @@ -33,16 +27,23 @@ struct xalignment alignmentInfo(id c, struct xrect newrect) return a; } -// TODO remove? -struct xrect frame(id c) +struct xalignment alignmentInfo(id c, struct xrect newrect) { + NSView *v; NSRect r; - struct xrect s; - r = [toNSView(c) frame]; - s.x = (intptr_t) r.origin.x; - s.y = (intptr_t) r.origin.y; - s.width = (intptr_t) r.size.width; - s.height = (intptr_t) r.size.height; - return s; + v = toNSView(c); + r = NSMakeRect((CGFloat) newrect.x, + (CGFloat) newrect.y, + (CGFloat) newrect.width, + (CGFloat) newrect.height); + return doAlignmentInfo(v, r); +} + +struct xalignment alignmentInfoFrame(id c) +{ + NSView *v; + + v = toNSView(c); + return doAlignmentInfo(v, [v frame]); }