summaryrefslogtreecommitdiff
path: root/new/newcontrol_darwin.m
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-09 16:21:09 -0400
committerPietro Gagliardi <[email protected]>2015-04-09 16:21:09 -0400
commit92b43720b6b33e838f8e9b5dffaa556529de3d52 (patch)
tree5bbfb07548bab0cdbecb2b38a479321e6730d6b4 /new/newcontrol_darwin.m
parent3f05be544ce9e57e8b00dfe99a64f223c6c2539b (diff)
Decided to split control removal from parent into its own method removeParent() rather than automatically doing it in setParent().
Diffstat (limited to 'new/newcontrol_darwin.m')
-rw-r--r--new/newcontrol_darwin.m17
1 files changed, 13 insertions, 4 deletions
diff --git a/new/newcontrol_darwin.m b/new/newcontrol_darwin.m
index 8b0bd48..77c23ca 100644
--- a/new/newcontrol_darwin.m
+++ b/new/newcontrol_darwin.m
@@ -13,6 +13,7 @@ struct uiSingleViewControl {
#define S(c) ((uiSingleViewControl *) (c))
+// TODO this will need to change if we want to provide removal
static void singleDestroy(uiControl *c)
{
[S(c)->view removeFromSuperview];
@@ -26,18 +27,25 @@ static uintptr_t singleHandle(uiControl *c)
static void singleSetParent(uiControl *c, uintptr_t parent)
{
uiSingleViewControl *s = S(c);
- uintptr_t oldparent;
NSView *parentView;
- oldparent = s->parent;
s->parent = parent;
parentView = (NSView *) (s->parent);
- // TODO will this change parents?
[parentView addSubview:s->immediate];
- updateParent(oldparent);
updateParent(s->parent);
}
+static void singleRemoveParent(uiControl *c)
+{
+ uiSingleViewControl *s = S(c);
+ uintptr_t oldparent;
+
+ oldparent = s->parent;
+ s->parent = 0;
+ [s->immediate removeFromSuperview];
+ updateParent(oldparent);
+}
+
// also good for NSBox and NSProgressIndicator
static uiSize singlePreferredSize(uiControl *c, uiSizing *d)
{
@@ -92,6 +100,7 @@ uiControl *uiDarwinNewControl(Class class, BOOL inScrollView, BOOL scrollViewHas
c->control.destroy = singleDestroy;
c->control.handle = singleHandle;
c->control.setParent = singleSetParent;
+ c->control.removeParent = singleRemoveParent;
c->control.preferredSize = singlePreferredSize;
c->control.resize = singleResize;