And implemented proper control showing on Mac OS X.

This commit is contained in:
Pietro Gagliardi 2015-04-08 19:14:22 -04:00
parent f470768a8e
commit 310fbe58fd
4 changed files with 29 additions and 6 deletions

View File

@ -23,12 +23,27 @@ uiLogObjCClassAllocations
} }
- (void)setFrameSize:(NSSize)s - (void)setFrameSize:(NSSize)s
{
[super setFrameSize:s];
[self uiUpdateNow];
}
- (void)uiUpdateNow
{ {
uiSizing d; uiSizing d;
[super setFrameSize:s];
if (self.child != NULL) 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); (*(self.child->resize))(self.child, [self bounds].origin.y, [self bounds].origin.y, [self bounds].size.width, [self bounds].size.height, &d);
} }
@end @end
void updateParent(uintptr_t parent)
{
uiContainer *c;
if (parent == 0)
return;
c = (uiContainer *) parent;
[c uiUpdateNow];
}

View File

@ -8,6 +8,7 @@ struct uiSingleViewControl {
NSView *view; NSView *view;
NSScrollView *scrollView; NSScrollView *scrollView;
NSView *immediate; // the control that is added to the parent container; either view or scrollView NSView *immediate; // the control that is added to the parent container; either view or scrollView
uintptr_t parent;
}; };
#define S(c) ((uiSingleViewControl *) (c)) #define S(c) ((uiSingleViewControl *) (c))
@ -24,9 +25,17 @@ static uintptr_t singleHandle(uiControl *c)
static void singleSetParent(uiControl *c, uintptr_t parent) static void singleSetParent(uiControl *c, uintptr_t parent)
{ {
NSView *parentView = (NSView *) parent; uiSingleViewControl *s = S(c);
uintptr_t oldparent;
NSView *parentView;
[parentView addSubview:S(c)->immediate]; oldparent = s->parent;
s->parent = parent;
parentView = (NSView *) (s->parent);
// TODO will this change parents?
[parentView addSubview:s->immediate];
updateParent(oldparent);
updateParent(s->parent);
} }
// also good for NSBox and NSProgressIndicator // also good for NSBox and NSProgressIndicator

View File

@ -36,5 +36,7 @@ extern void setStandardControlFont(NSControl *);
// container_darwin.m // container_darwin.m
@interface uiContainer : NSView @interface uiContainer : NSView
// TODO rename to uiChild
@property uiControl *child; @property uiControl *child;
- (void)uiUpdateNow;
@end @end

View File

@ -1,9 +1,6 @@
// 6 april 2015 // 6 april 2015
#import "uipriv_darwin.h" #import "uipriv_darwin.h"
// TODO
// - showing on size
@interface uiWindowDelegate : NSObject <NSWindowDelegate> @interface uiWindowDelegate : NSObject <NSWindowDelegate>
@property (assign) NSWindow *w; @property (assign) NSWindow *w;
@property (assign) uiContainer *container; @property (assign) uiContainer *container;