Skip to content

Commit

Permalink
Merge pull request #4 from wilsonk/osx_initial
Browse files Browse the repository at this point in the history
Osx initial
  • Loading branch information
ZILtoid1991 authored Nov 17, 2024
2 parents 7228a41 + 1c1d8c9 commit 2b0f7c0
Show file tree
Hide file tree
Showing 35 changed files with 1,875 additions and 62 deletions.
123 changes: 123 additions & 0 deletions carbon/events.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
module carbon.events;

import cocoa.foundation;

import objc.runtime;
@ObjectiveC final extern(C++) @nogc nothrow:

enum {
kVK_ANSI_A = 0x00,
kVK_ANSI_S = 0x01,
kVK_ANSI_D = 0x02,
kVK_ANSI_F = 0x03,
kVK_ANSI_H = 0x04,
kVK_ANSI_G = 0x05,
kVK_ANSI_Z = 0x06,
kVK_ANSI_X = 0x07,
kVK_ANSI_C = 0x08,
kVK_ANSI_V = 0x09,
kVK_ANSI_B = 0x0B,
kVK_ANSI_Q = 0x0C,
kVK_ANSI_W = 0x0D,
kVK_ANSI_E = 0x0E,
kVK_ANSI_R = 0x0F,
kVK_ANSI_Y = 0x10,
kVK_ANSI_T = 0x11,
kVK_ANSI_1 = 0x12,
kVK_ANSI_2 = 0x13,
kVK_ANSI_3 = 0x14,
kVK_ANSI_4 = 0x15,
kVK_ANSI_6 = 0x16,
kVK_ANSI_5 = 0x17,
kVK_ANSI_Equal = 0x18,
kVK_ANSI_9 = 0x19,
kVK_ANSI_7 = 0x1A,
kVK_ANSI_Minus = 0x1B,
kVK_ANSI_8 = 0x1C,
kVK_ANSI_0 = 0x1D,
kVK_ANSI_RightBracket = 0x1E,
kVK_ANSI_O = 0x1F,
kVK_ANSI_U = 0x20,
kVK_ANSI_LeftBracket = 0x21,
kVK_ANSI_I = 0x22,
kVK_ANSI_P = 0x23,
kVK_ANSI_L = 0x25,
kVK_ANSI_J = 0x26,
kVK_ANSI_Quote = 0x27,
kVK_ANSI_K = 0x28,
kVK_ANSI_Semicolon = 0x29,
kVK_ANSI_Backslash = 0x2A,
kVK_ANSI_Comma = 0x2B,
kVK_ANSI_Slash = 0x2C,
kVK_ANSI_N = 0x2D,
kVK_ANSI_M = 0x2E,
kVK_ANSI_Period = 0x2F,
kVK_ANSI_Grave = 0x32,
kVK_ANSI_KeypadDecimal = 0x41,
kVK_ANSI_KeypadMultiply = 0x43,
kVK_ANSI_KeypadPlus = 0x45,
kVK_ANSI_KeypadClear = 0x47,
kVK_ANSI_KeypadDivide = 0x4B,
kVK_ANSI_KeypadEnter = 0x4C,
kVK_ANSI_KeypadMinus = 0x4E,
kVK_ANSI_KeypadEquals = 0x51,
kVK_ANSI_Keypad0 = 0x52,
kVK_ANSI_Keypad1 = 0x53,
kVK_ANSI_Keypad2 = 0x54,
kVK_ANSI_Keypad3 = 0x55,
kVK_ANSI_Keypad4 = 0x56,
kVK_ANSI_Keypad5 = 0x57,
kVK_ANSI_Keypad6 = 0x58,
kVK_ANSI_Keypad7 = 0x59,
kVK_ANSI_Keypad8 = 0x5B,
kVK_ANSI_Keypad9 = 0x5C,

kVK_Return = 0x24,
kVK_Tab = 0x30,
kVK_Space = 0x31,
kVK_Delete = 0x33,
kVK_Escape = 0x35,
kVK_Command = 0x37,
kVK_Shift = 0x38,
kVK_CapsLock = 0x39,
kVK_Option = 0x3A,
kVK_Control = 0x3B,
kVK_RightShift = 0x3C,
kVK_RightOption = 0x3D,
kVK_RightControl = 0x3E,
kVK_Function = 0x3F,
kVK_F17 = 0x40,
kVK_VolumeUp = 0x48,
kVK_VolumeDown = 0x49,
kVK_Mute = 0x4A,
kVK_F18 = 0x4F,
kVK_F19 = 0x50,
kVK_F20 = 0x5A,
kVK_F5 = 0x60,
kVK_F6 = 0x61,
kVK_F7 = 0x62,
kVK_F3 = 0x63,
kVK_F8 = 0x64,
kVK_F9 = 0x65,
kVK_F11 = 0x67,
kVK_F13 = 0x69,
kVK_F16 = 0x6A,
kVK_F14 = 0x6B,
kVK_F10 = 0x6D,
kVK_F12 = 0x6F,
kVK_F15 = 0x71,
kVK_Help = 0x72,
kVK_Home = 0x73,
kVK_PageUp = 0x74,
kVK_ForwardDelete = 0x75,
kVK_F4 = 0x76,
kVK_End = 0x77,
kVK_F2 = 0x78,
kVK_PageDown = 0x79,
kVK_F1 = 0x7A,
kVK_LeftArrow = 0x7B,
kVK_RightArrow = 0x7C,
kVK_DownArrow = 0x7D,
kVK_UpArrow = 0x7E
}

38 changes: 38 additions & 0 deletions cocoa/foundation.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module cocoa.foundation;

import objc.runtime;

extern(C) bool CGEventSourceKeyState(int stateID, ushort keyCode) nothrow @nogc;

version(watchOS) {
alias CGFloat = float;
} else {
alias CGFloat = double;
}

struct CGPoint {
CGFloat x;
CGFloat y;
}

struct CGSize {
CGFloat width;
CGFloat height;
}

struct CGRect {
CGPoint origin;
CGSize size;
}

enum NSEventModifierFlags : NSUInteger {
AlphaShiftKeyMask = 1 << 16,
ShiftKeyMask = 1 << 17,
ControlKeyMask = 1 << 18,
AlternateKeyMask = 1 << 19,
CommandKeyMask = 1 << 20,
NumericPadKeyMask = 1 << 21,
HelpKeyMask = 1 << 22,
FunctionKeyMask = 1 << 23
}

37 changes: 37 additions & 0 deletions cocoa/gamecontroller.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module cocoa.gamecontroller;

import objc.runtime;
import cocoa.foundation;

enum GCHapticsLocality {
Left = 1,
Right = 2
}

@ObjectiveC final extern(C++):
@nogc nothrow:

class GCController {
mixin ObjcExtend!NSObject;

@selector("haptics")
GCHaptics haptics() @trusted nothrow;
}

class GCHaptics {
mixin ObjcExtend!NSObject;

@selector("createEngine:")
GCHapticsEngine createEngine(NSInteger locality) @trusted nothrow;

@selector("cancelAll")
void cancelAll() @trusted nothrow;
}

class GCHapticsEngine {
mixin ObjcExtend!NSObject;

@selector("createContinuousEvent:intensity:")
void createContinuousEvent(CGFloat intensity) @trusted nothrow;
}

26 changes: 26 additions & 0 deletions cocoa/nsappdelegate.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module cocoa.nsappdelegate;

import objc.meta : selector, ObjcExtend, ObjectiveC;
import objc.runtime;
import cocoa.foundation;
import cocoa.nsapplication;
import cocoa.nswindow;
import cocoa.nsnotification;

@ObjectiveC extern(C++):
@nogc nothrow:

interface NSApplicationDelegate {
}

@ObjectiveC final extern(C++):
class AppDelegate {
mixin ObjcExtend!NSObject;

static AppDelegate alloc() @selector("alloc") nothrow @nogc;
AppDelegate initialize() @selector("init");

void applicationDidFinishLaunching(NSNotification notification) @selector("applicationDidFinishLaunching:");
BOOL applicationShouldTerminateAfterLastWindowClosed(NSApplication sender) @selector("applicationShouldTerminateAfterLastWindowClosed:");
}

63 changes: 63 additions & 0 deletions cocoa/nsapplication.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module cocoa.nsapplication;

import cocoa.nswindow;
import cocoa.foundation;
import cocoa.nsevent;
import cocoa.nsdate;
import cocoa.nsmenu;

import objc.runtime;
@ObjectiveC final extern(C++):
@nogc nothrow:

enum NSApplicationActivationPolicy : NSInteger {
Regular = 0,
Accessory = 1,
Prohibited = 2
}

class NSApplication {
mixin ObjcExtend!NSObject;

nothrow @nogc:
@selector("sharedApplication")
static NSApplication sharedApplication();

@selector("run")
void run();

@selector("terminate:")
void terminate(NSObject sender);

@selector("activateIgnoringOtherApps:")
void activateIgnoringOtherApps(BOOL flag);

@selector("setActivationPolicy:")
BOOL setActivationPolicy(NSApplicationActivationPolicy activationPolicy);

@selector("mainWindow")
NSWindow mainWindow();

@selector("windows")
NSArray_!NSWindow windows();

@selector("keyWindow")
NSWindow keyWindow();

@selector("nextEventMatchingMask:untilDate:inMode:dequeue:")
NSEvent nextEventMatchingMask(NSUInteger mask, NSDate date, NSString mode, BOOL dequeue);

@selector("sendEvent:")
void sendEvent(NSEvent event);

@selector("setMainMenu:")
void setMainMenu(NSMenu);

@selector("setDelegate:")
void setDelegate(NSObject);
}

extern(D) NSApplication NSApp() @property nothrow @nogc {
return NSApplication.sharedApplication();
}

94 changes: 94 additions & 0 deletions cocoa/nscursor.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
module cocoa.nscursor;

import objc.runtime;
import cocoa.foundation;

@ObjectiveC final extern(C++):
@nogc nothrow:

class NSCursor {
mixin ObjcExtend!NSObject;

nothrow @nogc:
@selector("arrowCursor")
static NSCursor arrowCursor() nothrow @nogc;

@selector("IBeamCursor")
static NSCursor IBeamCursor() nothrow @nogc;

@selector("IBeamCursorForVerticalLayout")
static NSCursor IBeamCursorForVerticalLayout() nothrow @nogc;

@selector("crosshairCursor")
static NSCursor crosshairCursor() nothrow @nogc;

@selector("closedHandCursor")
static NSCursor closedHandCursor() nothrow @nogc;

@selector("contextualMenuCursor")
static NSCursor contextualMenuCursor() nothrow @nogc;

@selector("disappearingItemCursor")
static NSCursor disappearingItemCursor() nothrow @nogc;

@selector("dragCopyCursor")
static NSCursor dragCopyCursor() nothrow @nogc;

@selector("dragLinkCursor")
static NSCursor dragLinkCursor() nothrow @nogc;

@selector("operationNotAllowedCursor")
static NSCursor operationNotAllowedCursor() nothrow @nogc;

@selector("pointingHandCursor")
static NSCursor pointingHandCursor() nothrow @nogc;

@selector("_windowResizeNorthWestSouthEastCursor")
static NSCursor windowResizeNorthWestSouthEastCursor() nothrow @nogc;

@selector("_windowResizeNorthEastSouthWestCursor")
static NSCursor windowResizeNorthEastSouthWestCursor() nothrow @nogc;

@selector("_windowResizeSouthWestCursor")
static NSCursor windowResizeSouthWestCursor() nothrow @nogc;

@selector("_windowResizeSouthEastCursor")
static NSCursor windowResizeSouthEastCursor() nothrow @nogc;

@selector("_windowResizeNorthWestCursor")
static NSCursor windowResizeNorthWestCursor() nothrow @nogc;

@selector("_windowResizeNorthEastCursor")
static NSCursor windowResizeNorthEastCursor() nothrow @nogc;

@selector("resizeDownCursor")
static NSCursor resizeDownCursor() nothrow @nogc;

@selector("resizeLeftCursor")
static NSCursor resizeLeftCursor() nothrow @nogc;

@selector("resizeLeftRightCursor")
static NSCursor resizeLeftRightCursor() nothrow @nogc;

@selector("resizeRightCursor")
static NSCursor resizeRightCursor() nothrow @nogc;

@selector("resizeUpCursor")
static NSCursor resizeUpCursor() nothrow @nogc;

@selector("resizeUpDownCursor")
static NSCursor resizeUpDownCursor() nothrow @nogc;

@selector("openHandCursor")
static NSCursor openHandCursor() nothrow @nogc;

@selector("zoomInCursor")
static NSCursor zoomInCursor() nothrow @nogc;

@selector("zoomOutCursor")
static NSCursor zoomOutCursor() nothrow @nogc;

@selector("set")
void set() nothrow @nogc;
}

Loading

0 comments on commit 2b0f7c0

Please sign in to comment.