mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 22:58:46 +00:00
Merge pull request #1841 from hasenj/hack-objc-window-init
HACK work around for creating a cocoa window
This commit is contained in:
+6
-1
@@ -36,7 +36,12 @@ NotFound :: IntegerMax
|
|||||||
|
|
||||||
Float :: distinct (f32 when size_of(uint) == 4 else f64)
|
Float :: distinct (f32 when size_of(uint) == 4 else f64)
|
||||||
|
|
||||||
|
Point :: struct {
|
||||||
|
x: Float,
|
||||||
|
y: Float,
|
||||||
|
}
|
||||||
|
|
||||||
Size :: struct {
|
Size :: struct {
|
||||||
width: Float,
|
width: Float,
|
||||||
height: Float,
|
height: Float,
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-5
@@ -3,8 +3,8 @@ package objc_Foundation
|
|||||||
import NS "vendor:darwin/Foundation"
|
import NS "vendor:darwin/Foundation"
|
||||||
|
|
||||||
Rect :: struct {
|
Rect :: struct {
|
||||||
x, y: f64,
|
using origin: Point,
|
||||||
width, height: f64,
|
using size: Size,
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowStyleFlag :: enum NS.UInteger {
|
WindowStyleFlag :: enum NS.UInteger {
|
||||||
@@ -102,8 +102,19 @@ Window_alloc :: proc() -> ^Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@(objc_type=Window, objc_name="initWithContentRect")
|
@(objc_type=Window, objc_name="initWithContentRect")
|
||||||
Window_initWithContentRect :: proc(self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: bool) -> ^Window {
|
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)
|
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")
|
@(objc_type=Window, objc_name="contentView")
|
||||||
Window_contentView :: proc(self: ^Window) -> ^View {
|
Window_contentView :: proc(self: ^Window) -> ^View {
|
||||||
@@ -148,4 +159,4 @@ Window_setTitle :: proc(self: ^Window, title: ^NS.String) {
|
|||||||
@(objc_type=Window, objc_name="close")
|
@(objc_type=Window, objc_name="close")
|
||||||
Window_close :: proc(self: ^Window) {
|
Window_close :: proc(self: ^Window) {
|
||||||
msgSend(nil, self, "close")
|
msgSend(nil, self, "close")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user