From 8632d0c2f3c5b9eada161ea8743f995e46c0ff94 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 11 Jun 2014 11:17:00 -0400 Subject: [PATCH] Implemented Window.Center() on Mac OS X. --- objc_darwin.h | 1 + sysdata_darwin.go | 10 ++++++++++ sysdata_darwin.m | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/objc_darwin.h b/objc_darwin.h index b18f0d7..c62e2ab 100644 --- a/objc_darwin.h +++ b/objc_darwin.h @@ -116,6 +116,7 @@ extern BOOL isCheckboxChecked(id); extern void windowSetContentSize(id, intptr_t, intptr_t); extern void setProgress(id, intptr_t); extern void setAreaSize(id, intptr_t, intptr_t); +extern void center(id); /* combobox_darwin.m */ extern id makeCombobox(BOOL); diff --git a/sysdata_darwin.go b/sysdata_darwin.go index 19b2d49..26bcd98 100644 --- a/sysdata_darwin.go +++ b/sysdata_darwin.go @@ -412,3 +412,13 @@ func (s *sysData) repaintAll() { } <-ret } + +func (s *sysData) center() { + ret := make(chan struct{}) + defer close(ret) + uitask <- func() { + C.center(s.id) + ret <- struct{}{} + } + <-ret +} diff --git a/sysdata_darwin.m b/sysdata_darwin.m index c04ce37..6a6a999 100644 --- a/sysdata_darwin.m +++ b/sysdata_darwin.m @@ -229,3 +229,8 @@ void setAreaSize(id scrollview, intptr_t width, intptr_t height) [area setFrame:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height)]; [area display]; // and redraw } + +void center(id w) +{ + [toNSWindow(w) center]; +}