diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2022-06-12 17:08:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-12 17:08:10 +0100 |
| commit | 108558ddfceee3a8d1d2c5c1496e2c5fc1bf4cea (patch) | |
| tree | 84cb8fa212cf4dfb192ffde8881b9f21f4b25fe6 | |
| parent | 65b8cfae82f781579c8b32011e05bddae183e8ed (diff) | |
| parent | 4be92c7eb89f6b26becb0ed79ce14bc445673b6a (diff) | |
Merge pull request #1841 from hasenj/hack-objc-window-init
HACK work around for creating a cocoa window
| -rw-r--r-- | vendor/darwin/Foundation/NSTypes.odin | 7 | ||||
| -rw-r--r-- | vendor/darwin/Foundation/NSWindow.odin | 21 |
2 files changed, 22 insertions, 6 deletions
diff --git a/vendor/darwin/Foundation/NSTypes.odin b/vendor/darwin/Foundation/NSTypes.odin index ef895d449..0c1239710 100644 --- a/vendor/darwin/Foundation/NSTypes.odin +++ b/vendor/darwin/Foundation/NSTypes.odin @@ -36,7 +36,12 @@ NotFound :: IntegerMax Float :: distinct (f32 when size_of(uint) == 4 else f64) +Point :: struct { + x: Float, + y: Float, +} + Size :: struct { width: Float, height: Float, -}
\ No newline at end of file +} diff --git a/vendor/darwin/Foundation/NSWindow.odin b/vendor/darwin/Foundation/NSWindow.odin index 3c7c17023..330af6012 100644 --- a/vendor/darwin/Foundation/NSWindow.odin +++ b/vendor/darwin/Foundation/NSWindow.odin @@ -3,8 +3,8 @@ package objc_Foundation import NS "vendor:darwin/Foundation" Rect :: struct { - x, y: f64, - width, height: f64, + using origin: Point, + using size: Size, } WindowStyleFlag :: enum NS.UInteger { @@ -102,8 +102,19 @@ Window_alloc :: proc() -> ^Window { } @(objc_type=Window, objc_name="initWithContentRect") -Window_initWithContentRect :: proc(self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: bool) -> ^Window { - return msgSend(^Window, self, "initWithContentRect:styleMask:backing:defer:", contentRect, styleMask, backing, doDefer) +Window_initWithContentRect :: proc (self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: bool) -> ^Window { + self := self + // HACK: due to a compiler bug, the generated calling code does not + // currently work for this message. Has to do with passing a struct along + // with other parameters, so we don't send the rect here. + // Omiting the rect argument here actually works, because of how the C + // calling conventions are defined. + self = msgSend(^Window, self, "initWithContentRect:styleMask:backing:defer:", styleMask, backing, doDefer) + + // apply the contentRect now, since we did not pass it to the init call + msgSend(nil, self, "setContentSize:", contentRect.size) + msgSend(nil, self, "setFrameOrigin:", contentRect.origin) + return self } @(objc_type=Window, objc_name="contentView") Window_contentView :: proc(self: ^Window) -> ^View { @@ -148,4 +159,4 @@ Window_setTitle :: proc(self: ^Window, title: ^NS.String) { @(objc_type=Window, objc_name="close") Window_close :: proc(self: ^Window) { msgSend(nil, self, "close") -}
\ No newline at end of file +} |