More EMouseCursor options

This commit is contained in:
Luke Street 2021-05-25 09:23:50 -04:00
parent 8dd258fc62
commit 78028c6237
8 changed files with 83 additions and 13 deletions

View File

@ -191,7 +191,18 @@ enum class EWindowStyle {
};
ENABLE_BITWISE_ENUM(EWindowStyle)
enum class EMouseCursor { None = 0, Pointer = 1, HorizontalArrow = 2, VerticalArrow = 3, IBeam = 4, Crosshairs = 5 };
enum class EMouseCursor {
None = 0,
Pointer = 1,
HorizontalArrow = 2,
VerticalArrow = 3,
IBeam = 4,
Crosshairs = 5,
BottomRightArrow = 6,
BottomLeftArrow = 7,
Hand = 8,
NotAllowed = 9,
};
enum class EClipboardType { None = 0, String = 1, UTF8String = 2, PNGImage = 3 };

View File

@ -19,6 +19,10 @@
#error ARC Required
#endif
#ifndef USE_PRIVATE_APIS
#define USE_PRIVATE_APIS 1
#endif
namespace boo {
class WindowCocoa;
@ -1311,18 +1315,41 @@ public:
case EMouseCursor::Pointer:
[[NSCursor arrowCursor] set];
break;
#if !USE_PRIVATE_APIS
case EMouseCursor::HorizontalArrow:
[[NSCursor resizeLeftRightCursor] set];
break;
case EMouseCursor::VerticalArrow:
[[NSCursor resizeUpDownCursor] set];
break;
#endif
case EMouseCursor::IBeam:
[[NSCursor IBeamCursor] set];
break;
case EMouseCursor::Crosshairs:
[[NSCursor crosshairCursor] set];
break;
case EMouseCursor::Hand:
[[NSCursor pointingHandCursor] set];
break;
case EMouseCursor::NotAllowed:
[[NSCursor operationNotAllowedCursor] set];
break;
#if USE_PRIVATE_APIS
// Private API cursors
case EMouseCursor::HorizontalArrow:
[(NSCursor*)[[NSCursor class] performSelector:@selector(_windowResizeEastWestCursor)] set];
break;
case EMouseCursor::VerticalArrow:
[(NSCursor*)[[NSCursor class] performSelector:@selector(_windowResizeNorthSouthCursor)] set];
break;
case EMouseCursor::BottomRightArrow:
[(NSCursor*)[[NSCursor class] performSelector:@selector(_windowResizeNorthWestSouthEastCursor)] set];
break;
case EMouseCursor::BottomLeftArrow:
[(NSCursor*)[[NSCursor class] performSelector:@selector(_windowResizeNorthEastSouthWestCursor)] set];
break;
#endif
default:
break;
}

View File

@ -488,11 +488,15 @@ int ApplicationRun(IApplication::EPlatformType platform, IApplicationCallback& c
#endif
WIN32_CURSORS.m_arrow = LoadCursor(nullptr, IDC_ARROW);
WIN32_CURSORS.m_hResize = LoadCursor(nullptr, IDC_SIZEWE);
WIN32_CURSORS.m_vResize = LoadCursor(nullptr, IDC_SIZENS);
WIN32_CURSORS.m_weResize = LoadCursor(nullptr, IDC_SIZEWE);
WIN32_CURSORS.m_nsResize = LoadCursor(nullptr, IDC_SIZENS);
WIN32_CURSORS.m_ibeam = LoadCursor(nullptr, IDC_IBEAM);
WIN32_CURSORS.m_crosshairs = LoadCursor(nullptr, IDC_CROSS);
WIN32_CURSORS.m_wait = LoadCursor(nullptr, IDC_WAIT);
WIN32_CURSORS.m_nwseResize = LoadCursor(nullptr, IDC_SIZENWSE);
WIN32_CURSORS.m_neswResize = LoadCursor(nullptr, IDC_SIZENESW);
WIN32_CURSORS.m_hand = LoadCursor(nullptr, IDC_HAND);
WIN32_CURSORS.m_notAllowed = LoadCursor(nullptr, IDC_NO);
/* One class for *all* boo windows */
WNDCLASS wndClass = {0, WindowProc, 0, 0, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"BooWindow"};

View File

@ -145,11 +145,15 @@ struct HWNDEvent {
struct Win32Cursors {
HCURSOR m_arrow;
HCURSOR m_hResize;
HCURSOR m_vResize;
HCURSOR m_weResize;
HCURSOR m_nsResize;
HCURSOR m_ibeam;
HCURSOR m_crosshairs;
HCURSOR m_wait;
HCURSOR m_nwseResize;
HCURSOR m_neswResize;
HCURSOR m_hand;
HCURSOR m_notAllowed;
};
namespace boo {
extern Win32Cursors WIN32_CURSORS;

View File

@ -841,13 +841,21 @@ class WindowWin32 : public IWindow {
case EMouseCursor::Pointer:
return WIN32_CURSORS.m_arrow;
case EMouseCursor::HorizontalArrow:
return WIN32_CURSORS.m_hResize;
return WIN32_CURSORS.m_weResize;
case EMouseCursor::VerticalArrow:
return WIN32_CURSORS.m_vResize;
return WIN32_CURSORS.m_nsResize;
case EMouseCursor::IBeam:
return WIN32_CURSORS.m_ibeam;
case EMouseCursor::Crosshairs:
return WIN32_CURSORS.m_crosshairs;
case EMouseCursor::BottomRightArrow:
return WIN32_CURSORS.m_nwseResize;
case EMouseCursor::BottomLeftArrow:
return WIN32_CURSORS.m_neswResize;
case EMouseCursor::Hand:
return WIN32_CURSORS.m_hand;
case EMouseCursor::NotAllowed:
return WIN32_CURSORS.m_notAllowed;
default:
break;
}

View File

@ -347,11 +347,15 @@ public:
m_xDefaultScreen = DefaultScreen(m_xDisp);
X_CURSORS.m_pointer = XCreateFontCursor(m_xDisp, XC_left_ptr);
X_CURSORS.m_hArrow = XCreateFontCursor(m_xDisp, XC_sb_h_double_arrow);
X_CURSORS.m_vArrow = XCreateFontCursor(m_xDisp, XC_sb_v_double_arrow);
X_CURSORS.m_weArrow = XCreateFontCursor(m_xDisp, XC_sb_h_double_arrow);
X_CURSORS.m_nsArrow = XCreateFontCursor(m_xDisp, XC_sb_v_double_arrow);
X_CURSORS.m_ibeam = XCreateFontCursor(m_xDisp, XC_xterm);
X_CURSORS.m_crosshairs = XCreateFontCursor(m_xDisp, XC_cross);
X_CURSORS.m_wait = XCreateFontCursor(m_xDisp, XC_watch);
X_CURSORS.m_nwseResize = XCreateFontCursor(m_xDisp, XC_lr_angle);
X_CURSORS.m_neswResize = XCreateFontCursor(m_xDisp, XC_ll_angle);
X_CURSORS.m_hand = XCreateFontCursor(m_xDisp, XC_hand2);
X_CURSORS.m_notAllowed = XCreateFontCursor(m_xDisp, XC_pirate);
/* The xkb extension requests that the X server does not
* send repeated keydown events when a key is held */

View File

@ -701,13 +701,21 @@ class WindowXlib final : public IWindow {
case EMouseCursor::Pointer:
return X_CURSORS.m_pointer;
case EMouseCursor::HorizontalArrow:
return X_CURSORS.m_hArrow;
return X_CURSORS.m_weArrow;
case EMouseCursor::VerticalArrow:
return X_CURSORS.m_vArrow;
return X_CURSORS.m_nsArrow;
case EMouseCursor::IBeam:
return X_CURSORS.m_ibeam;
case EMouseCursor::Crosshairs:
return X_CURSORS.m_crosshairs;
case EMouseCursor::BottomLeftArrow:
return X_CURSORS.m_nwseResize;
case EMouseCursor::BottomRightArrow:
return X_CURSORS.m_neswResize;
case EMouseCursor::Hand:
return X_CURSORS.m_hand;
case EMouseCursor::NotAllowed:
return X_CURSORS.m_notAllowed;
default:
break;
}

View File

@ -6,11 +6,15 @@ namespace boo {
struct XlibCursors {
Cursor m_pointer;
Cursor m_hArrow;
Cursor m_vArrow;
Cursor m_weArrow;
Cursor m_nsArrow;
Cursor m_ibeam;
Cursor m_crosshairs;
Cursor m_wait;
Cursor m_nwseResize;
Cursor m_neswResize;
Cursor m_hand;
Cursor m_notAllowed;
};
extern XlibCursors X_CURSORS;