Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented SetCursor for most of the available MacOS cursors. #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 113 additions & 4 deletions src/mac/WindowMac.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "WindowMac.h"
#include <AppCore/Monitor.h>
#include <AppKit/NSCursor.h>
#include "AppMac.h"
#import "Cocoa/Cocoa.h"
#import "ViewController.h"
Expand Down Expand Up @@ -30,15 +31,15 @@
[window_ makeKeyAndOrderFront:NSApp];
[window_ setOrderedIndex:0];
[NSApp activateIgnoringOtherApps:YES];

controller_ = [[ViewController alloc] init];
[controller_ initWithWindow:this frame:frame];
[window_ setContentViewController:controller_];

delegate_ = [[WindowDelegate alloc] init];
[delegate_ initWithWindow:this];
[window_ setDelegate:delegate_];

// Move app to foreground
ProcessSerialNumber psn = {0, kCurrentProcess};
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
Expand All @@ -64,6 +65,114 @@
}

void WindowMac::SetCursor(ultralight::Cursor cursor) {
switch (cursor) {
case ultralight::kCursor_Pointer:
[[NSCursor arrowCursor] set];
break;

case ultralight::kCursor_Cross:
[[NSCursor crosshairCursor] set];
break;

case ultralight::kCursor_Hand:
[[NSCursor pointingHandCursor] set];
break;

case ultralight::kCursor_IBeam:
[[NSCursor IBeamCursor] set];
break;

case ultralight::kCursor_Wait:
break;


case ultralight::kCursor_Help:
break;

case ultralight::kCursor_EastResize:
[[NSCursor resizeRightCursor] set];
break;

case ultralight::kCursor_NorthResize:
[[NSCursor resizeUpCursor] set];
break;

case ultralight::kCursor_NorthEastResize:
break;

case ultralight::kCursor_NorthWestResize:
break;

case ultralight::kCursor_SouthResize:
[[NSCursor resizeDownCursor] set];
break;

case ultralight::kCursor_SouthEastResize:
break;

case ultralight::kCursor_SouthWestResize:
break;


case ultralight::kCursor_WestResize:
[[NSCursor resizeLeftCursor] set];
break;

case ultralight::kCursor_NorthSouthResize:
[[NSCursor resizeUpDownCursor] set];
break;

case ultralight::kCursor_EastWestResize:
[[NSCursor resizeLeftRightCursor] set];
break;

case ultralight::kCursor_NorthEastSouthWestResize:
case ultralight::kCursor_NorthWestSouthEastResize:
case ultralight::kCursor_ColumnResize:
case ultralight::kCursor_RowResize:
case ultralight::kCursor_MiddlePanning:
case ultralight::kCursor_EastPanning:
case ultralight::kCursor_NorthPanning:
case ultralight::kCursor_NorthEastPanning:
case ultralight::kCursor_NorthWestPanning:
case ultralight::kCursor_SouthPanning:
case ultralight::kCursor_SouthEastPanning:
case ultralight::kCursor_SouthWestPanning:
case ultralight::kCursor_Move:
case ultralight::kCursor_WestPanning:
break;

case ultralight::kCursor_VerticalText:
[[NSCursor IBeamCursorForVerticalLayout] set];
break;

case ultralight::kCursor_Cell:
break;

case ultralight::kCursor_ContextMenu:
[[NSCursor contextualMenuCursor] set];
break;

case ultralight::kCursor_Alias:
case ultralight::kCursor_Progress:
case ultralight::kCursor_NoDrop:
case ultralight::kCursor_Copy:
case ultralight::kCursor_None:
break;

case ultralight::kCursor_NotAllowed:
[[NSCursor operationNotAllowedCursor] set];
break;

case ultralight::kCursor_ZoomIn:
case ultralight::kCursor_ZoomOut:
case ultralight::kCursor_Grab:
case ultralight::kCursor_Grabbing:
break;

default:
break;
}
}

void WindowMac::Close() {
Expand All @@ -85,7 +194,7 @@
if (listener_)
listener_->OnResize(width, height);
}

MTKView* WindowMac::view() {
return [controller_ metalView];
}
Expand Down