Fixed control positioning on initial window show on Mac OS X.

This commit is contained in:
Pietro Gagliardi 2014-07-18 15:16:41 -04:00
parent 6bc4425915
commit b56f60c04c
2 changed files with 8 additions and 2 deletions

View File

@ -135,7 +135,6 @@ func windowClosing(xw unsafe.Pointer) C.BOOL {
//export windowResized //export windowResized
func windowResized(xw unsafe.Pointer, width C.uintptr_t, height C.uintptr_t) { func windowResized(xw unsafe.Pointer, width C.uintptr_t, height C.uintptr_t) {
// TODO this isn't called when the window first opens up
w := (*window)(unsafe.Pointer(xw)) w := (*window)(unsafe.Pointer(xw))
w.doresize(int(width), int(height)) w.doresize(int(width), int(height))
fmt.Printf("new size %d x %d\n", width, height) fmt.Printf("new size %d x %d\n", width, height)

View File

@ -21,11 +21,16 @@
} }
- (void)windowDidResize:(NSNotification *)n - (void)windowDidResize:(NSNotification *)n
{
[self doWindowResize:[n object]];
}
- (void)doWindowResize:(id)win
{ {
NSWindow *w; NSWindow *w;
NSRect r; NSRect r;
w = toNSWindow([n object]); w = toNSWindow(win);
r = [[w contentView] frame]; r = [[w contentView] frame];
windowResized(self->gowin, (uintptr_t) r.size.width, (uintptr_t) r.size.height); windowResized(self->gowin, (uintptr_t) r.size.width, (uintptr_t) r.size.height);
} }
@ -62,6 +67,8 @@ void windowSetTitle(id win, const char * title)
void windowShow(id win) void windowShow(id win)
{ {
[toNSWindow(win) makeKeyAndOrderFront:toNSWindow(win)]; [toNSWindow(win) makeKeyAndOrderFront:toNSWindow(win)];
// calling the above the first time won't emit a size changed event (unlike on Windows and GTK+), so fake one to get the controls laid out properly
[[toNSWindow(win) delegate] doWindowResize:win];
} }
void windowHide(id win) void windowHide(id win)