summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--new/container_darwin.m33
-rw-r--r--new/uipriv_darwin.h1
-rw-r--r--new/window_darwin.m12
3 files changed, 43 insertions, 3 deletions
diff --git a/new/container_darwin.m b/new/container_darwin.m
index 333b914..5012229 100644
--- a/new/container_darwin.m
+++ b/new/container_darwin.m
@@ -8,7 +8,9 @@
// - NSTab switching tabs calls both -[setFrame:] and -[setFrameSize:] on the new tab
// so we just override setFrameSize:
// thanks to mikeash and JtRip in irc.freenode.net/#macdev
-@implementation uiContainer
+@implementation uiContainer {
+ BOOL uimargined;
+}
uiLogObjCClassAllocations
@@ -28,12 +30,37 @@ uiLogObjCClassAllocations
[self uiUpdateNow];
}
+// These are based on measurements from Interface Builder.
+// TODO reverify these against /layout rects/, not /frame rects/
+#define macXMargin 20
+#define macYMargin 20
+
- (void)uiUpdateNow
{
uiSizing d;
+ intmax_t x, y, width, height;
+
+ if (self.child == NULL)
+ return;
+ x = [self bounds].origin.x;
+ y = [self bounds].origin.y;
+ width = [self bounds].size.width;
+ height = [self bounds].size.height;
+ if (self->uimargined) {
+ x += macXMargin;
+ y += macYMargin;
+ width -= 2 * macXMargin;
+ height -= 2 * macYMargin;
+ }
+ (*(self.child->resize))(self.child, x, y, width, height, &d);
+}
+
+// TODO margined
- if (self.child != NULL)
- (*(self.child->resize))(self.child, [self bounds].origin.y, [self bounds].origin.y, [self bounds].size.width, [self bounds].size.height, &d);
+- (void)uiSetMargined:(BOOL)margined
+{
+ self->uimargined = margined;
+ [self uiUpdateNow];
}
@end
diff --git a/new/uipriv_darwin.h b/new/uipriv_darwin.h
index 5a48fca..5ec8b4c 100644
--- a/new/uipriv_darwin.h
+++ b/new/uipriv_darwin.h
@@ -40,4 +40,5 @@ extern void setStandardControlFont(NSControl *);
// TODO rename to uiChild
@property uiControl *child;
- (void)uiUpdateNow;
+- (void)uiSetMargined:(BOOL)margined;
@end
diff --git a/new/window_darwin.m b/new/window_darwin.m
index 2052f18..8a7309d 100644
--- a/new/window_darwin.m
+++ b/new/window_darwin.m
@@ -110,3 +110,15 @@ void uiWindowSetChild(uiWindow *w, uiControl *c)
D.container.child = c;
(*(D.container.child->setParent))(D.container.child, (uintptr_t) (D.container));
}
+
+// TODO margined
+
+void uiWindowSetMargined(uiWindow *w, int margined)
+{
+ BOOL m;
+
+ m = NO;
+ if (margined)
+ m = YES;
+ [D.container uiSetMargined:m];
+}