Implemented extra cursors on macOS

This commit is contained in:
Jonny Paton 2018-04-10 20:52:38 -07:00 committed by Lukas Dürrenberger
parent 1cd7ad6a24
commit 0bcb2992a7
2 changed files with 40 additions and 15 deletions

View File

@ -53,21 +53,24 @@ public:
/// Refer to the following table to determine which cursor /// Refer to the following table to determine which cursor
/// is available on which platform. /// is available on which platform.
/// ///
/// Type | Linux | Mac OS X | Windows | /// Type | Linux | Mac OS X | Windows
/// ------------------------------------|:-----:|:--------:|:--------:| /// ------------------------------------|:-----:|:--------:|:--------:
/// sf::Cursor::Arrow | yes | yes | yes | /// sf::Cursor::Arrow | yes | yes | yes
/// sf::Cursor::ArrowWait | no | no | yes | /// sf::Cursor::ArrowWait | no | no | yes
/// sf::Cursor::Wait | yes | no | yes | /// sf::Cursor::Wait | yes | no | yes
/// sf::Cursor::Text | yes | yes | yes | /// sf::Cursor::Text | yes | yes | yes
/// sf::Cursor::Hand | yes | yes | yes | /// sf::Cursor::Hand | yes | yes | yes
/// sf::Cursor::SizeHorizontal | yes | yes | yes | /// sf::Cursor::SizeHorizontal | yes | yes | yes
/// sf::Cursor::SizeVertical | yes | yes | yes | /// sf::Cursor::SizeVertical | yes | yes | yes
/// sf::Cursor::SizeTopLeftBottomRight | no | no | yes | /// sf::Cursor::SizeTopLeftBottomRight | no | yes* | yes
/// sf::Cursor::SizeBottomLeftTopRight | no | no | yes | /// sf::Cursor::SizeBottomLeftTopRight | no | yes* | yes
/// sf::Cursor::SizeAll | yes | no | yes | /// sf::Cursor::SizeAll | yes | no | yes
/// sf::Cursor::Cross | yes | yes | yes | /// sf::Cursor::Cross | yes | yes | yes
/// sf::Cursor::Help | yes | no | yes | /// sf::Cursor::Help | yes | yes* | yes
/// sf::Cursor::NotAllowed | yes | yes | yes | /// sf::Cursor::NotAllowed | yes | yes | yes
///
/// * These cursor types are undocumented so may not
/// be available on all versions, but have been tested on 10.13
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
enum Type enum Type

View File

@ -65,6 +65,16 @@ bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hot
return m_cursor != nil; return m_cursor != nil;
} }
////////////////////////////////////////////////////////////
bool loadFromSelector(SEL selector, NSCursorRef& cursor)
{
if ([NSCursor respondsToSelector:selector])
{
cursor = [NSCursor performSelector:selector];
return true;
}
return false;
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool CursorImpl::loadFromSystem(Cursor::Type type) bool CursorImpl::loadFromSystem(Cursor::Type type)
@ -80,6 +90,18 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
case Cursor::SizeVertical: m_cursor = [NSCursor resizeUpDownCursor]; break; case Cursor::SizeVertical: m_cursor = [NSCursor resizeUpDownCursor]; break;
case Cursor::Cross: m_cursor = [NSCursor crosshairCursor]; break; case Cursor::Cross: m_cursor = [NSCursor crosshairCursor]; break;
case Cursor::NotAllowed: m_cursor = [NSCursor operationNotAllowedCursor]; break; case Cursor::NotAllowed: m_cursor = [NSCursor operationNotAllowedCursor]; break;
// These cursor types are undocumented, may not be available on some platforms
case Cursor::SizeBottomLeftTopRight:
return loadFromSelector(@selector(_windowResizeNorthEastSouthWestCursor), m_cursor);
case Cursor::SizeTopLeftBottomRight:
return loadFromSelector(@selector(_windowResizeNorthWestSouthEastCursor), m_cursor);
case Cursor::SizeAll:
return loadFromSelector(@selector(_moveCursor), m_cursor);
case Cursor::Wait:
return loadFromSelector(@selector(_waitCursor), m_cursor);
case Cursor::Help:
return loadFromSelector(@selector(_helpCursor), m_cursor);
} }
// Since we didn't allocate the cursor ourself, we have to retain it // Since we didn't allocate the cursor ourself, we have to retain it