mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-13 01:21:38 -07:00
Update vendor:darwin/Foundation to implement Event, Color, Screen, and other fixes
This commit is contained in:
+32
-1
@@ -1,9 +1,22 @@
|
||||
package objc_Foundation
|
||||
|
||||
foreign import "system:Foundation.framework"
|
||||
|
||||
import "core:intrinsics"
|
||||
import "core:runtime"
|
||||
import "core:strings"
|
||||
|
||||
RunLoopMode :: ^String
|
||||
|
||||
@(link_prefix="NS")
|
||||
foreign Foundation {
|
||||
CommonRunLoopMode: RunLoopMode
|
||||
DefaultRunLoopMode: RunLoopMode
|
||||
EventTrackingRunLoopMode: RunLoopMode
|
||||
ModalPanelRunLoopMode: RunLoopMode
|
||||
TrackingRunLoopMode: RunLoopMode
|
||||
}
|
||||
|
||||
ActivationPolicy :: enum UInteger {
|
||||
Regular = 0,
|
||||
Accessory = 1,
|
||||
@@ -87,12 +100,30 @@ Application_run :: proc "c" (self: ^Application) {
|
||||
msgSend(nil, self, "run")
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Application, objc_name="terminate")
|
||||
Application_terminate :: proc "c" (self: ^Application, sender: ^Object) {
|
||||
msgSend(nil, self, "terminate:", sender)
|
||||
}
|
||||
|
||||
@(objc_type=Application, objc_name="isRunning")
|
||||
Application_isRunning :: proc "c" (self: ^Application) -> BOOL {
|
||||
return msgSend(BOOL, self, "isRunning")
|
||||
}
|
||||
|
||||
@(objc_type=Application, objc_name="currentEvent")
|
||||
Application_currentEvent :: proc "c" (self: ^Application) -> ^Event {
|
||||
return msgSend(^Event, self, "currentEvent")
|
||||
}
|
||||
|
||||
@(objc_type=Application, objc_name="nextEventMatchingMask")
|
||||
Application_nextEventMatchingMask :: proc "c" (self: ^Application, mask: EventMask, expiration: ^Date, in_mode: RunLoopMode, dequeue: BOOL) -> ^Event {
|
||||
return msgSend(^Event, self, "nextEventMatchingMask:untilDate:inMode:dequeue:", mask, expiration, in_mode, dequeue)
|
||||
}
|
||||
|
||||
@(objc_type=Application, objc_name="sendEvent")
|
||||
Application_sendEvent :: proc "c" (self: ^Application, event: ^Event) {
|
||||
msgSend(Event, self, "sendEvent:", event)
|
||||
}
|
||||
|
||||
|
||||
@(objc_class="NSRunningApplication")
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
package objc_Foundation
|
||||
|
||||
@(objc_class="NSColorSpace")
|
||||
ColorSpace :: struct {using _: Object}
|
||||
|
||||
@(objc_class="NSColor")
|
||||
Color :: struct {using _: Object}
|
||||
|
||||
@(objc_type=Color, objc_name="colorWithSRGBRed", objc_is_class_method=true)
|
||||
Color_colorWithSRGBRed :: proc "c" (red, green, blue, alpha: Float) -> ^Color {
|
||||
return msgSend(^Color, Color, "colorWithSRGBRed:green:blue:alpha:", red, green, blue, alpha)
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="colorWithCalibratedHue", objc_is_class_method=true)
|
||||
Color_colorWithCalibratedHue :: proc "c" (hue, saturation, brightness, alpha: Float) -> ^Color {
|
||||
return msgSend(^Color, Color, "colorWithCalibratedHue:hue:saturation:brightness:alpha:", hue, saturation, brightness, alpha)
|
||||
}
|
||||
@(objc_type=Color, objc_name="colorWithCalibratedRed", objc_is_class_method=true)
|
||||
Color_colorWithCalibratedRed :: proc "c" (red, green, blue, alpha: Float) -> ^Color {
|
||||
return msgSend(^Color, Color, "colorWithCalibratedRed:green:blue:alpha:", red, green, blue, alpha)
|
||||
}
|
||||
@(objc_type=Color, objc_name="colorWithCalibratedWhite", objc_is_class_method=true)
|
||||
Color_colorWithCalibratedWhite :: proc "c" (white, alpha: Float) -> ^Color {
|
||||
return msgSend(^Color, Color, "colorWithCalibratedWhite:alpha:", white, alpha)
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="colorWithDeviceCyan", objc_is_class_method=true)
|
||||
Color_colorWithDeviceCyan :: proc "c" (cyan, magenta, yellow, black, alpha: Float) -> ^Color {
|
||||
return msgSend(^Color, Color, "colorWithDeviceCyan:magenta:yellow:black:", cyan, magenta, yellow, black)
|
||||
}
|
||||
@(objc_type=Color, objc_name="colorWithDeviceHue", objc_is_class_method=true)
|
||||
Color_colorWithDeviceHue :: proc "c" (hue, saturation, brightness, alpha: Float) -> ^Color {
|
||||
return msgSend(^Color, Color, "colorWithDeviceHue:hue:saturation:brightness:alpha:", hue, saturation, brightness, alpha)
|
||||
}
|
||||
@(objc_type=Color, objc_name="colorWithDeviceRed", objc_is_class_method=true)
|
||||
Color_colorWithDeviceRed :: proc "c" (red, green, blue, alpha: Float) -> ^Color {
|
||||
return msgSend(^Color, Color, "colorWithDeviceRed:green:blue:alpha:", red, green, blue, alpha)
|
||||
}
|
||||
@(objc_type=Color, objc_name="colorWithDeviceWhite", objc_is_class_method=true)
|
||||
Color_colorWithDeviceWhite :: proc "c" (white, alpha: Float) -> ^Color {
|
||||
return msgSend(^Color, Color, "colorWithDeviceWhite:alpha:", white, alpha)
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Color, objc_name="blackColor", objc_is_class_method=true)
|
||||
Color_blackColor :: proc "c" () -> ^Color {
|
||||
return msgSend(^Color, Color, "blackColor")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="whiteColor", objc_is_class_method=true)
|
||||
Color_whiteColor :: proc "c" () -> ^Color {
|
||||
return msgSend(^Color, Color, "whiteColor")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="redColor", objc_is_class_method=true)
|
||||
Color_redColor :: proc "c" () -> ^Color {
|
||||
return msgSend(^Color, Color, "redColor")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="greenColor", objc_is_class_method=true)
|
||||
Color_greenColor :: proc "c" () -> ^Color {
|
||||
return msgSend(^Color, Color, "greenColor")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="orangeColor", objc_is_class_method=true)
|
||||
Color_orangeColor :: proc "c" () -> ^Color {
|
||||
return msgSend(^Color, Color, "orangeColor")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="purpleColor", objc_is_class_method=true)
|
||||
Color_purpleColor :: proc "c" () -> ^Color {
|
||||
return msgSend(^Color, Color, "purpleColor")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="cyanColor", objc_is_class_method=true)
|
||||
Color_cyanColor :: proc "c" () -> ^Color {
|
||||
return msgSend(^Color, Color, "cyanColor")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="blueColor", objc_is_class_method=true)
|
||||
Color_blueColor :: proc "c" () -> ^Color {
|
||||
return msgSend(^Color, Color, "blueColor")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="magentaColor", objc_is_class_method=true)
|
||||
Color_magentaColor :: proc "c" () -> ^Color {
|
||||
return msgSend(^Color, Color, "magentaColor")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="yellowColor", objc_is_class_method=true)
|
||||
Color_yellowColor :: proc "c" () -> ^Color {
|
||||
return msgSend(^Color, Color, "yellowColor")
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Color, objc_name="getCMYKA")
|
||||
Color_getCMYKA :: proc "c" (self: ^Color) -> (cyan, magenta, yellow, black, alpha: Float) {
|
||||
msgSend(nil, Color, "getCyan:magenta:yellow:black:alpha:", &cyan, &magenta, &yellow, &black, &alpha)
|
||||
return
|
||||
}
|
||||
@(objc_type=Color, objc_name="getHSBA")
|
||||
Color_getHSBA :: proc "c" (self: ^Color) -> (hue, saturation, brightness, alpha: Float) {
|
||||
msgSend(nil, Color, "getHue:saturation:brightness:alpha:", &hue, &saturation, &brightness, &alpha)
|
||||
return
|
||||
}
|
||||
@(objc_type=Color, objc_name="getRGBA")
|
||||
Color_getRGBA :: proc "c" (self: ^Color) -> (red, green, blue, alpha: Float) {
|
||||
msgSend(nil, Color, "getRed:green:blue:alpha:", &red, &green, &blue, &alpha)
|
||||
return
|
||||
}
|
||||
@(objc_type=Color, objc_name="getWhiteAlpha")
|
||||
Color_getWhiteAlpha :: proc "c" (self: ^Color) -> (white, alpha: Float) {
|
||||
msgSend(nil, Color, "getWhite:alpha:", &white, &alpha)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Color, objc_name="colorWithColorSpace", objc_is_class_method=true)
|
||||
Color_colorWithColorSpace :: proc "c" (space: ^ColorSpace, components: []Float) -> ^Color {
|
||||
return msgSend(^Color, Color, "colorWithColorSpace:components:count", space, raw_data(components), Integer(len(components)))
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Color, objc_name="colorSpaceName")
|
||||
Color_colorSpaceName :: proc "c" (self: ^Color) -> ^String {
|
||||
return msgSend(^String, self, "colorSpaceName")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="colorSpace")
|
||||
Color_colorSpace :: proc "c" (self: ^Color) -> ^ColorSpace {
|
||||
return msgSend(^ColorSpace, self, "colorSpace")
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="colorUsingColorSpaceName")
|
||||
Color_colorUsingColorSpaceName :: proc "c" (self: ^Color, colorSpace: ^String, device: ^Dictionary = nil) -> ^Color {
|
||||
if device != nil {
|
||||
return msgSend(^Color, self, "colorUsingColorSpaceName:device:", colorSpace, device)
|
||||
}
|
||||
return msgSend(^Color, self, "colorUsingColorSpaceName:", colorSpace)
|
||||
}
|
||||
|
||||
@(objc_type=Color, objc_name="numberOfComponents")
|
||||
Color_numberOfComponents :: proc "c" (self: ^Color) -> Integer {
|
||||
return msgSend(Integer, self, "numberOfComponents")
|
||||
}
|
||||
@(objc_type=Color, objc_name="getComponents")
|
||||
Color_getComponents :: proc "c" (self: ^Color, components: [^]Float) {
|
||||
msgSend(nil, self, "getComponents:", components)
|
||||
}
|
||||
+303
-1
@@ -2,4 +2,306 @@ package objc_Foundation
|
||||
|
||||
@(objc_class="NSEvent")
|
||||
Event :: struct {using _: Object}
|
||||
// TODO: implement NSEvent
|
||||
|
||||
|
||||
|
||||
EventMask :: distinct bit_set[EventType; UInteger]
|
||||
EventMaskAny :: ~EventMask{}
|
||||
|
||||
EventType :: enum UInteger {
|
||||
LeftMouseDown = 1,
|
||||
LeftMouseUp = 2,
|
||||
RightMouseDown = 3,
|
||||
RightMouseUp = 4,
|
||||
MouseMoved = 5,
|
||||
LeftMouseDragged = 6,
|
||||
RightMouseDragged = 7,
|
||||
MouseEntered = 8,
|
||||
MouseExited = 9,
|
||||
KeyDown = 10,
|
||||
KeyUp = 11,
|
||||
FlagsChanged = 12,
|
||||
AppKitDefined = 13,
|
||||
SystemDefined = 14,
|
||||
ApplicationDefined = 15,
|
||||
Periodic = 16,
|
||||
CursorUpdate = 17,
|
||||
Rotate = 18,
|
||||
BeginGesture = 19,
|
||||
EndGesture = 20,
|
||||
ScrollWheel = 22,
|
||||
TabletPoint = 23,
|
||||
TabletProximity = 24,
|
||||
OtherMouseDown = 25,
|
||||
OtherMouseUp = 26,
|
||||
OtherMouseDragged = 27,
|
||||
Gesture = 29,
|
||||
Magnify = 30,
|
||||
Swipe = 31,
|
||||
SmartMagnify = 32,
|
||||
QuickLook = 33,
|
||||
Pressure = 34,
|
||||
DirectTouch = 37,
|
||||
ChangeMode = 38,
|
||||
}
|
||||
|
||||
EventPhase :: distinct bit_set[EventPhaseFlag; UInteger]
|
||||
EventPhaseFlag :: enum UInteger {
|
||||
Began = 0,
|
||||
Stationary = 1,
|
||||
Changed = 2,
|
||||
Ended = 3,
|
||||
Cancelled = 4,
|
||||
MayBegin = 5,
|
||||
}
|
||||
EventPhaseNone :: EventPhase{}
|
||||
EventPhaseBegan :: EventPhase{.Began}
|
||||
EventPhaseStationary :: EventPhase{.Stationary}
|
||||
EventPhaseChanged :: EventPhase{.Changed}
|
||||
EventPhaseEnded :: EventPhase{.Ended}
|
||||
EventPhaseCancelled :: EventPhase{.Cancelled}
|
||||
EventPhaseMayBegin :: EventPhase{.MayBegin}
|
||||
|
||||
/* pointer types for NSTabletProximity events or mouse events with subtype NSTabletProximityEventSubtype*/
|
||||
PointingDeviceType :: enum UInteger {
|
||||
Unknown = 0,
|
||||
Pen = 1,
|
||||
Cursor = 2,
|
||||
Eraser = 3,
|
||||
}
|
||||
|
||||
/* these messages are valid for all events */
|
||||
|
||||
@(objc_type=Event, objc_name="type")
|
||||
Event_type :: proc "c" (self: ^Event) -> EventType {
|
||||
return msgSend(EventType, self, "type")
|
||||
}
|
||||
@(objc_type=Event, objc_name="modifierFlags")
|
||||
Event_modifierFlags :: proc "c" (self: ^Event) -> UInteger {
|
||||
return msgSend(UInteger, self, "modifierFlags")
|
||||
}
|
||||
@(objc_type=Event, objc_name="timestamp")
|
||||
Event_timestamp :: proc "c" (self: ^Event) -> TimeInterval {
|
||||
return msgSend(TimeInterval, self, "timestamp")
|
||||
}
|
||||
@(objc_type=Event, objc_name="window")
|
||||
Event_window :: proc "c" (self: ^Event) -> ^Window {
|
||||
return msgSend(^Window, self, "window")
|
||||
}
|
||||
@(objc_type=Event, objc_name="windowNumber")
|
||||
Event_windowNumber :: proc "c" (self: ^Event) -> UInteger {
|
||||
return msgSend(UInteger, self, "windowNumber")
|
||||
}
|
||||
|
||||
/* these messages are valid for all mouse down/up/drag events */
|
||||
|
||||
@(objc_type=Event, objc_name="clickCount")
|
||||
Event_clickCount :: proc "c" (self: ^Event) -> Integer {
|
||||
return msgSend(Integer, self, "clickCount")
|
||||
}
|
||||
|
||||
// for NSOtherMouse events, but will return valid constants for NSLeftMouse and NSRightMouse
|
||||
@(objc_type=Event, objc_name="buttonNumber")
|
||||
Event_buttonNumber :: proc "c" (self: ^Event) -> Integer {
|
||||
return msgSend(Integer, self, "buttonNumber")
|
||||
}
|
||||
|
||||
/* these messages are valid for all mouse down/up/drag and enter/exit events */
|
||||
@(objc_type=Event, objc_name="eventNumber")
|
||||
Event_eventNumber :: proc "c" (self: ^Event) -> Integer {
|
||||
return msgSend(Integer, self, "eventNumber")
|
||||
}
|
||||
|
||||
/* -pressure is valid for all mouse down/up/drag events, and is also valid for NSTabletPoint events on 10.4 or later */
|
||||
@(objc_type=Event, objc_name="pressure")
|
||||
Event_pressure :: proc "c" (self: ^Event) -> f32 {
|
||||
return msgSend(f32, self, "pressure")
|
||||
}
|
||||
|
||||
/* -locationInWindow is valid for all mouse-related events */
|
||||
@(objc_type=Event, objc_name="locationInWindow")
|
||||
Event_locationInWindow :: proc "c" (self: ^Event) -> Point {
|
||||
return msgSend(Point, self, "locationInWindow")
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Event, objc_name="deltaX")
|
||||
Event_deltaX :: proc "c" (self: ^Event) -> Float {
|
||||
return msgSend(Float, self, "deltaX")
|
||||
}
|
||||
@(objc_type=Event, objc_name="deltaY")
|
||||
Event_deltaY :: proc "c" (self: ^Event) -> Float {
|
||||
return msgSend(Float, self, "deltaY")
|
||||
}
|
||||
@(objc_type=Event, objc_name="deltaZ")
|
||||
Event_deltaZ :: proc "c" (self: ^Event) -> Float {
|
||||
return msgSend(Float, self, "deltaZ")
|
||||
}
|
||||
@(objc_type=Event, objc_name="delta")
|
||||
Event_delta :: proc "c" (self: ^Event) -> (x, y, z: Float) {
|
||||
x = self->deltaX()
|
||||
y = self->deltaY()
|
||||
z = self->deltaZ()
|
||||
return
|
||||
}
|
||||
|
||||
@(objc_type=Event, objc_name="hasPreciseScrollingDeltas")
|
||||
Event_hasPreciseScrollingDeltas :: proc "c" (self: ^Event) -> BOOL {
|
||||
return msgSend(BOOL, self, "hasPreciseScrollingDeltas")
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Event, objc_name="scrollingDeltaX")
|
||||
Event_scrollingDeltaX :: proc "c" (self: ^Event) -> Float {
|
||||
return msgSend(Float, self, "scrollingDeltaX")
|
||||
}
|
||||
@(objc_type=Event, objc_name="scrollingDeltaY")
|
||||
Event_scrollingDeltaY :: proc "c" (self: ^Event) -> Float {
|
||||
return msgSend(Float, self, "scrollingDeltaY")
|
||||
}
|
||||
@(objc_type=Event, objc_name="scrollingDelta")
|
||||
Event_scrollingDelta :: proc "c" (self: ^Event) -> (x, y: Float) {
|
||||
x = self->scrollingDeltaX()
|
||||
y = self->scrollingDeltaY()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
@(objc_type=Event, objc_name="momentumPhase")
|
||||
Event_momentumPhase :: proc "c" (self: ^Event) -> EventPhase {
|
||||
return msgSend(EventPhase, self, "momentumPhase")
|
||||
}
|
||||
@(objc_type=Event, objc_name="phase")
|
||||
Event_phase :: proc "c" (self: ^Event) -> EventPhase {
|
||||
return msgSend(EventPhase, self, "phase")
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Event, objc_name="isDirectionInvertedFromDevice")
|
||||
Event_isDirectionInvertedFromDevice :: proc "c" (self: ^Event) -> BOOL {
|
||||
return msgSend(BOOL, self, "isDirectionInvertedFromDevice")
|
||||
}
|
||||
|
||||
@(objc_type=Event, objc_name="characters")
|
||||
Event_characters :: proc "c" (self: ^Event) -> ^String {
|
||||
return msgSend(^String, self, "characters")
|
||||
}
|
||||
@(objc_type=Event, objc_name="charactersIgnoringModifiers")
|
||||
Event_charactersIgnoringModifiers :: proc "c" (self: ^Event) -> ^String {
|
||||
return msgSend(^String, self, "charactersIgnoringModifiers")
|
||||
}
|
||||
@(objc_type=Event, objc_name="isARepeat")
|
||||
Event_isARepeat :: proc "c" (self: ^Event) -> BOOL {
|
||||
return msgSend(BOOL, self, "isARepeat")
|
||||
}
|
||||
|
||||
@(objc_type=Event, objc_name="keyCode")
|
||||
Event_keyCode :: proc "c" (self: ^Event) -> u16 {
|
||||
return msgSend(u16, self, "keyCode")
|
||||
}
|
||||
|
||||
@(objc_type=Event, objc_name="subtype")
|
||||
Event_subtype :: proc "c" (self: ^Event) -> i16 {
|
||||
return msgSend(i16, self, "subtype")
|
||||
}
|
||||
|
||||
@(objc_type=Event, objc_name="data1")
|
||||
Event_data1 :: proc "c" (self: ^Event) -> Integer {
|
||||
return msgSend(Integer, self, "data1")
|
||||
}
|
||||
@(objc_type=Event, objc_name="data2")
|
||||
Event_data2 :: proc "c" (self: ^Event) -> Integer {
|
||||
return msgSend(Integer, self, "data2")
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Event, objc_name="absoluteX")
|
||||
Event_absoluteX :: proc "c" (self: ^Event) -> Integer {
|
||||
return msgSend(Integer, self, "absoluteX")
|
||||
}
|
||||
@(objc_type=Event, objc_name="absoluteY")
|
||||
Event_absoluteY :: proc "c" (self: ^Event) -> Integer {
|
||||
return msgSend(Integer, self, "absoluteY")
|
||||
}
|
||||
@(objc_type=Event, objc_name="absoluteZ")
|
||||
Event_absoluteZ :: proc "c" (self: ^Event) -> Integer {
|
||||
return msgSend(Integer, self, "absoluteZ")
|
||||
}
|
||||
|
||||
@(objc_type=Event, objc_name="absolute")
|
||||
Event_absolute :: proc "c" (self: ^Event) -> (x, y, z: Integer) {
|
||||
x = self->absoluteX()
|
||||
y = self->absoluteY()
|
||||
z = self->absoluteZ()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Event, objc_name="buttonMask")
|
||||
Event_buttonMask :: proc "c" (self: ^Event) -> UInteger {
|
||||
return msgSend(UInteger, self, "buttonMask")
|
||||
}
|
||||
|
||||
@(objc_type=Event, objc_name="tilt")
|
||||
tilt :: proc "c" (self: ^Event) -> Point {
|
||||
return msgSend(Point, self, "tilt")
|
||||
}
|
||||
|
||||
@(objc_type=Event, objc_name="tangentialPressure")
|
||||
Event_tangentialPressure :: proc "c" (self: ^Event) -> f32 {
|
||||
return msgSend(f32, self, "tangentialPressure")
|
||||
}
|
||||
|
||||
@(objc_type=Event, objc_name="vendorDefined")
|
||||
Event_vendorDefined :: proc "c" (self: ^Event) -> id {
|
||||
return msgSend(id, self, "vendorDefined")
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Event, objc_name="vendorID")
|
||||
Event_vendorID :: proc "c" (self: ^Event) -> UInteger {
|
||||
return msgSend(UInteger, self, "vendorID")
|
||||
}
|
||||
@(objc_type=Event, objc_name="tabletID")
|
||||
Event_tabletID :: proc "c" (self: ^Event) -> UInteger {
|
||||
return msgSend(UInteger, self, "tabletID")
|
||||
}
|
||||
@(objc_type=Event, objc_name="pointingDeviceID")
|
||||
Event_pointingDeviceID :: proc "c" (self: ^Event) -> UInteger {
|
||||
return msgSend(UInteger, self, "pointingDeviceID")
|
||||
}
|
||||
@(objc_type=Event, objc_name="systemTabletID")
|
||||
Event_systemTabletID :: proc "c" (self: ^Event) -> UInteger {
|
||||
return msgSend(UInteger, self, "systemTabletID")
|
||||
}
|
||||
@(objc_type=Event, objc_name="vendorPointingDeviceType")
|
||||
Event_vendorPointingDeviceType :: proc "c" (self: ^Event) -> UInteger {
|
||||
return msgSend(UInteger, self, "vendorPointingDeviceType")
|
||||
}
|
||||
@(objc_type=Event, objc_name="pointingDeviceSerialNumber")
|
||||
Event_pointingDeviceSerialNumber :: proc "c" (self: ^Event) -> UInteger {
|
||||
return msgSend(UInteger, self, "pointingDeviceSerialNumber")
|
||||
}
|
||||
@(objc_type=Event, objc_name="uniqueID")
|
||||
Event_uniqueID :: proc "c" (self: ^Event) -> u64 {
|
||||
return msgSend(u64, self, "uniqueID")
|
||||
}
|
||||
@(objc_type=Event, objc_name="capabilityMask")
|
||||
Event_capabilityMask :: proc "c" (self: ^Event) -> UInteger {
|
||||
return msgSend(UInteger, self, "capabilityMask")
|
||||
}
|
||||
@(objc_type=Event, objc_name="pointingDeviceType")
|
||||
Event_pointingDeviceType :: proc "c" (self: ^Event) -> PointingDeviceType {
|
||||
return msgSend(PointingDeviceType, self, "pointingDeviceType")
|
||||
}
|
||||
@(objc_type=Event, objc_name="isEnteringProximity")
|
||||
Event_isEnteringProximity :: proc "c" (self: ^Event) -> BOOL {
|
||||
return msgSend(BOOL, self, "isEnteringProximity")
|
||||
}
|
||||
|
||||
|
||||
@(objc_type=Event, objc_name="isSwipeTrackingFromScrollEventsEnabled")
|
||||
Event_isSwipeTrackingFromScrollEventsEnabled :: proc "c" (self: ^Event) -> BOOL {
|
||||
return msgSend(BOOL, self, "isSwipeTrackingFromScrollEventsEnabled")
|
||||
}
|
||||
|
||||
+29
-1
@@ -2,4 +2,32 @@ package objc_Foundation
|
||||
|
||||
@(objc_class="NSScreen")
|
||||
Screen :: struct {using _: Object}
|
||||
// TODO: implement NSScreen
|
||||
|
||||
@(objc_type=Screen, objc_name="mainScreen")
|
||||
Screen_mainScreen :: proc "c" () -> ^Screen {
|
||||
return msgSend(^Screen, Screen, "mainScreen")
|
||||
}
|
||||
@(objc_type=Screen, objc_name="deepestScreen")
|
||||
Screen_deepestScreen :: proc "c" () -> ^Screen {
|
||||
return msgSend(^Screen, Screen, "deepestScreen")
|
||||
}
|
||||
@(objc_type=Screen, objc_name="screens")
|
||||
Screen_screens :: proc "c" () -> ^Array {
|
||||
return msgSend(^Array, Screen, "screens")
|
||||
}
|
||||
@(objc_type=Screen, objc_name="frame")
|
||||
Screen_frame :: proc "c" (self: ^Screen) -> Rect {
|
||||
return msgSend(Rect, self, "frame")
|
||||
}
|
||||
@(objc_type=Screen, objc_name="depth")
|
||||
Screen_depth :: proc "c" (self: ^Screen) -> Depth {
|
||||
return msgSend(Depth, self, "depth")
|
||||
}
|
||||
@(objc_type=Screen, objc_name="visibleFrame")
|
||||
Screen_visibleFrame :: proc "c" (self: ^Screen) -> Rect {
|
||||
return msgSend(Rect, self, "visibleFrame")
|
||||
}
|
||||
@(objc_type=Screen, objc_name="colorSpace")
|
||||
Screen_colorSpace :: proc "c" (self: ^Screen) -> ^ColorSpace {
|
||||
return msgSend(^ColorSpace, self, "colorSpace")
|
||||
}
|
||||
|
||||
+28
-21
@@ -3,20 +3,25 @@ package objc_Foundation
|
||||
import "core:strings"
|
||||
import "core:runtime"
|
||||
import "core:intrinsics"
|
||||
import NS "vendor:darwin/Foundation"
|
||||
|
||||
Rect :: struct {
|
||||
using origin: Point,
|
||||
using size: Size,
|
||||
}
|
||||
|
||||
Depth :: enum UInteger {
|
||||
onehundredtwentyeightBitRGB = 544,
|
||||
sixtyfourBitRGB = 528,
|
||||
twentyfourBitRGB = 520,
|
||||
}
|
||||
|
||||
when size_of(Float) == 8 {
|
||||
_RECT_ENCODING :: "{CGRect="+_POINT_ENCODING+_SIZE_ENCODING+"}"
|
||||
} else {
|
||||
_RECT_ENCODING :: "{NSRect="+_POINT_ENCODING+_SIZE_ENCODING+"}"
|
||||
}
|
||||
|
||||
WindowStyleFlag :: enum NS.UInteger {
|
||||
WindowStyleFlag :: enum UInteger {
|
||||
Titled = 0,
|
||||
Closable = 1,
|
||||
Miniaturizable = 2,
|
||||
@@ -30,7 +35,7 @@ WindowStyleFlag :: enum NS.UInteger {
|
||||
NonactivatingPanel = 7,
|
||||
HUDWindow = 13,
|
||||
}
|
||||
WindowStyleMask :: distinct bit_set[WindowStyleFlag; NS.UInteger]
|
||||
WindowStyleMask :: distinct bit_set[WindowStyleFlag; UInteger]
|
||||
WindowStyleMaskBorderless :: WindowStyleMask{}
|
||||
WindowStyleMaskTitled :: WindowStyleMask{.Titled}
|
||||
WindowStyleMaskClosable :: WindowStyleMask{.Closable}
|
||||
@@ -45,7 +50,7 @@ WindowStyleMaskDocModalWindow :: WindowStyleMask{.DocModalWindow}
|
||||
WindowStyleMaskNonactivatingPanel :: WindowStyleMask{.NonactivatingPanel}
|
||||
WindowStyleMaskHUDWindow :: WindowStyleMask{.HUDWindow}
|
||||
|
||||
BackingStoreType :: enum NS.UInteger {
|
||||
BackingStoreType :: enum UInteger {
|
||||
Retained = 0,
|
||||
Nonretained = 1,
|
||||
Buffered = 2,
|
||||
@@ -124,7 +129,8 @@ WindowDelegateTemplate :: struct {
|
||||
windowDidExitVersionBrowser: proc(notification: ^Notification),
|
||||
}
|
||||
|
||||
WindowDelegate :: struct { using _: Object }
|
||||
|
||||
WindowDelegate :: struct { using _: Object } // This is not the same as NSWindowDelegate
|
||||
_WindowDelegateInternal :: struct {
|
||||
using _: WindowDelegateTemplate,
|
||||
_context: runtime.Context,
|
||||
@@ -555,11 +561,8 @@ window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, cla
|
||||
return cast(^WindowDelegate)del
|
||||
}
|
||||
|
||||
@(objc_class="NSColor")
|
||||
Color :: struct {using _: Object}
|
||||
|
||||
@(objc_class="CALayer")
|
||||
Layer :: struct { using _: NS.Object }
|
||||
Layer :: struct { using _: Object }
|
||||
|
||||
@(objc_type=Layer, objc_name="contentsScale")
|
||||
Layer_contentsScale :: proc "c" (self: ^Layer) -> Float {
|
||||
@@ -589,6 +592,10 @@ View :: struct {using _: Responder}
|
||||
View_initWithFrame :: proc "c" (self: ^View, frame: Rect) -> ^View {
|
||||
return msgSend(^View, self, "initWithFrame:", frame)
|
||||
}
|
||||
@(objc_type=View, objc_name="bounds")
|
||||
View_bounds :: proc "c" (self: ^View) -> Rect {
|
||||
return msgSend(Rect, self, "bounds")
|
||||
}
|
||||
@(objc_type=View, objc_name="layer")
|
||||
View_layer :: proc "c" (self: ^View) -> ^Layer {
|
||||
return msgSend(^Layer, self, "layer")
|
||||
@@ -615,7 +622,7 @@ Window_alloc :: proc "c" () -> ^Window {
|
||||
}
|
||||
|
||||
@(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 {
|
||||
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
|
||||
@@ -650,39 +657,39 @@ Window_setFrame :: proc "c" (self: ^Window, frame: Rect) {
|
||||
msgSend(nil, self, "setFrame:", frame)
|
||||
}
|
||||
@(objc_type=Window, objc_name="opaque")
|
||||
Window_opaque :: proc "c" (self: ^Window) -> NS.BOOL {
|
||||
return msgSend(NS.BOOL, self, "opaque")
|
||||
Window_opaque :: proc "c" (self: ^Window) -> BOOL {
|
||||
return msgSend(BOOL, self, "opaque")
|
||||
}
|
||||
@(objc_type=Window, objc_name="setOpaque")
|
||||
Window_setOpaque :: proc "c" (self: ^Window, ok: NS.BOOL) {
|
||||
Window_setOpaque :: proc "c" (self: ^Window, ok: BOOL) {
|
||||
msgSend(nil, self, "setOpaque:", ok)
|
||||
}
|
||||
@(objc_type=Window, objc_name="backgroundColor")
|
||||
Window_backgroundColor :: proc "c" (self: ^Window) -> ^NS.Color {
|
||||
return msgSend(^NS.Color, self, "backgroundColor")
|
||||
Window_backgroundColor :: proc "c" (self: ^Window) -> ^Color {
|
||||
return msgSend(^Color, self, "backgroundColor")
|
||||
}
|
||||
@(objc_type=Window, objc_name="setBackgroundColor")
|
||||
Window_setBackgroundColor :: proc "c" (self: ^Window, color: ^NS.Color) {
|
||||
Window_setBackgroundColor :: proc "c" (self: ^Window, color: ^Color) {
|
||||
msgSend(nil, self, "setBackgroundColor:", color)
|
||||
}
|
||||
@(objc_type=Window, objc_name="makeKeyAndOrderFront")
|
||||
Window_makeKeyAndOrderFront :: proc "c" (self: ^Window, key: ^NS.Object) {
|
||||
Window_makeKeyAndOrderFront :: proc "c" (self: ^Window, key: ^Object) {
|
||||
msgSend(nil, self, "makeKeyAndOrderFront:", key)
|
||||
}
|
||||
@(objc_type=Window, objc_name="setTitle")
|
||||
Window_setTitle :: proc "c" (self: ^Window, title: ^NS.String) {
|
||||
Window_setTitle :: proc "c" (self: ^Window, title: ^String) {
|
||||
msgSend(nil, self, "setTitle:", title)
|
||||
}
|
||||
@(objc_type=Window, objc_name="setTitlebarAppearsTransparent")
|
||||
Window_setTitlebarAppearsTransparent :: proc "c" (self: ^Window, ok: NS.BOOL) {
|
||||
Window_setTitlebarAppearsTransparent :: proc "c" (self: ^Window, ok: BOOL) {
|
||||
msgSend(nil, self, "setTitlebarAppearsTransparent:", ok)
|
||||
}
|
||||
@(objc_type=Window, objc_name="setMovable")
|
||||
Window_setMovable :: proc "c" (self: ^Window, ok: NS.BOOL) {
|
||||
Window_setMovable :: proc "c" (self: ^Window, ok: BOOL) {
|
||||
msgSend(nil, self, "setMovable:", ok)
|
||||
}
|
||||
@(objc_type=Window, objc_name="setMovableByWindowBackground")
|
||||
Window_setMovableByWindowBackground :: proc "c" (self: ^Window, ok: NS.BOOL) {
|
||||
Window_setMovableByWindowBackground :: proc "c" (self: ^Window, ok: BOOL) {
|
||||
msgSend(nil, self, "setMovableByWindowBackground:", ok)
|
||||
}
|
||||
@(objc_type=Window, objc_name="setStyleMask")
|
||||
|
||||
Reference in New Issue
Block a user