Removed the need for C.frame() by splitting apart the alignment rect functions on the Mac OS X side.

This commit is contained in:
Pietro Gagliardi 2014-08-11 11:36:32 -04:00
parent 10201ef24f
commit be56135451
3 changed files with 22 additions and 22 deletions

View File

@ -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 {

View File

@ -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);

View File

@ -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]);
}