mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Make Cursor::Type a scoped enumeration
This commit is contained in:
parent
b9fdc1de7b
commit
df2f56fe83
@ -56,28 +56,28 @@ public:
|
||||
/// is available on which platform.
|
||||
///
|
||||
/// Type | Linux | macOS | Windows |
|
||||
/// ------------------------------------|:-----:|:-----:|:--------:|
|
||||
/// sf::Cursor::Arrow | yes | yes | yes |
|
||||
/// sf::Cursor::ArrowWait | no | no | yes |
|
||||
/// sf::Cursor::Wait | yes | no | yes |
|
||||
/// sf::Cursor::Text | yes | yes | yes |
|
||||
/// sf::Cursor::Hand | yes | yes | yes |
|
||||
/// sf::Cursor::SizeHorizontal | yes | yes | yes |
|
||||
/// sf::Cursor::SizeVertical | yes | yes | yes |
|
||||
/// sf::Cursor::SizeTopLeftBottomRight | no | yes* | yes |
|
||||
/// sf::Cursor::SizeBottomLeftTopRight | no | yes* | yes |
|
||||
/// sf::Cursor::SizeLeft | yes | yes** | yes** |
|
||||
/// sf::Cursor::SizeRight | yes | yes** | yes** |
|
||||
/// sf::Cursor::SizeTop | yes | yes** | yes** |
|
||||
/// sf::Cursor::SizeBottom | yes | yes** | yes** |
|
||||
/// sf::Cursor::SizeTopLeft | yes | yes** | yes** |
|
||||
/// sf::Cursor::SizeTopRight | yes | yes** | yes** |
|
||||
/// sf::Cursor::SizeBottomLeft | yes | yes** | yes** |
|
||||
/// sf::Cursor::SizeBottomRight | yes | yes** | yes** |
|
||||
/// sf::Cursor::SizeAll | yes | no | yes |
|
||||
/// sf::Cursor::Cross | yes | yes | yes |
|
||||
/// sf::Cursor::Help | yes | yes* | yes |
|
||||
/// sf::Cursor::NotAllowed | yes | yes | yes |
|
||||
/// ------------------------------------------|:-----:|:-----:|:--------:|
|
||||
/// sf::Cursor::Type::Arrow | yes | yes | yes |
|
||||
/// sf::Cursor::Type::ArrowWait | no | no | yes |
|
||||
/// sf::Cursor::Type::Wait | yes | no | yes |
|
||||
/// sf::Cursor::Type::Text | yes | yes | yes |
|
||||
/// sf::Cursor::Type::Hand | yes | yes | yes |
|
||||
/// sf::Cursor::Type::SizeHorizontal | yes | yes | yes |
|
||||
/// sf::Cursor::Type::SizeVertical | yes | yes | yes |
|
||||
/// sf::Cursor::Type::SizeTopLeftBottomRight | no | yes* | yes |
|
||||
/// sf::Cursor::Type::SizeBottomLeftTopRight | no | yes* | yes |
|
||||
/// sf::Cursor::Type::SizeLeft | yes | yes** | yes** |
|
||||
/// sf::Cursor::Type::SizeRight | yes | yes** | yes** |
|
||||
/// sf::Cursor::Type::SizeTop | yes | yes** | yes** |
|
||||
/// sf::Cursor::Type::SizeBottom | yes | yes** | yes** |
|
||||
/// sf::Cursor::Type::SizeTopLeft | yes | yes** | yes** |
|
||||
/// sf::Cursor::Type::SizeTopRight | yes | yes** | yes** |
|
||||
/// sf::Cursor::Type::SizeBottomLeft | yes | yes** | yes** |
|
||||
/// sf::Cursor::Type::SizeBottomRight | yes | yes** | yes** |
|
||||
/// sf::Cursor::Type::SizeAll | yes | no | yes |
|
||||
/// sf::Cursor::Type::Cross | yes | yes | yes |
|
||||
/// sf::Cursor::Type::Help | yes | yes* | yes |
|
||||
/// sf::Cursor::Type::NotAllowed | yes | yes | yes |
|
||||
///
|
||||
/// * These cursor types are undocumented so may not
|
||||
/// be available on all versions, but have been tested on 10.13
|
||||
@ -85,7 +85,7 @@ public:
|
||||
/// ** On Windows and macOS, double-headed arrows are used
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Type
|
||||
enum class Type
|
||||
{
|
||||
Arrow, //!< Arrow cursor (default)
|
||||
ArrowWait, //!< Busy arrow cursor
|
||||
@ -250,7 +250,7 @@ private:
|
||||
/// // ... create window as usual ...
|
||||
///
|
||||
/// sf::Cursor cursor;
|
||||
/// if (cursor.loadFromSystem(sf::Cursor::Hand))
|
||||
/// if (cursor.loadFromSystem(sf::Cursor::Type::Hand))
|
||||
/// window.setMouseCursor(cursor);
|
||||
/// \endcode
|
||||
///
|
||||
|
@ -179,24 +179,24 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
|
||||
{
|
||||
default: return false;
|
||||
|
||||
case Cursor::Arrow: shape = XC_arrow; break;
|
||||
case Cursor::Wait: shape = XC_watch; break;
|
||||
case Cursor::Text: shape = XC_xterm; break;
|
||||
case Cursor::Hand: shape = XC_hand2; break;
|
||||
case Cursor::SizeHorizontal: shape = XC_sb_h_double_arrow; break;
|
||||
case Cursor::SizeVertical: shape = XC_sb_v_double_arrow; break;
|
||||
case Cursor::SizeLeft: shape = XC_left_side; break;
|
||||
case Cursor::SizeRight: shape = XC_right_side; break;
|
||||
case Cursor::SizeTop: shape = XC_top_side; break;
|
||||
case Cursor::SizeBottom: shape = XC_bottom_side; break;
|
||||
case Cursor::SizeTopLeft: shape = XC_top_left_corner; break;
|
||||
case Cursor::SizeBottomRight: shape = XC_bottom_right_corner; break;
|
||||
case Cursor::SizeBottomLeft: shape = XC_bottom_left_corner; break;
|
||||
case Cursor::SizeTopRight: shape = XC_top_right_corner; break;
|
||||
case Cursor::SizeAll: shape = XC_fleur; break;
|
||||
case Cursor::Cross: shape = XC_crosshair; break;
|
||||
case Cursor::Help: shape = XC_question_arrow; break;
|
||||
case Cursor::NotAllowed: shape = XC_X_cursor; break;
|
||||
case Cursor::Type::Arrow: shape = XC_arrow; break;
|
||||
case Cursor::Type::Wait: shape = XC_watch; break;
|
||||
case Cursor::Type::Text: shape = XC_xterm; break;
|
||||
case Cursor::Type::Hand: shape = XC_hand2; break;
|
||||
case Cursor::Type::SizeHorizontal: shape = XC_sb_h_double_arrow; break;
|
||||
case Cursor::Type::SizeVertical: shape = XC_sb_v_double_arrow; break;
|
||||
case Cursor::Type::SizeLeft: shape = XC_left_side; break;
|
||||
case Cursor::Type::SizeRight: shape = XC_right_side; break;
|
||||
case Cursor::Type::SizeTop: shape = XC_top_side; break;
|
||||
case Cursor::Type::SizeBottom: shape = XC_bottom_side; break;
|
||||
case Cursor::Type::SizeTopLeft: shape = XC_top_left_corner; break;
|
||||
case Cursor::Type::SizeBottomRight: shape = XC_bottom_right_corner; break;
|
||||
case Cursor::Type::SizeBottomLeft: shape = XC_bottom_left_corner; break;
|
||||
case Cursor::Type::SizeTopRight: shape = XC_top_right_corner; break;
|
||||
case Cursor::Type::SizeAll: shape = XC_fleur; break;
|
||||
case Cursor::Type::Cross: shape = XC_crosshair; break;
|
||||
case Cursor::Type::Help: shape = XC_question_arrow; break;
|
||||
case Cursor::Type::NotAllowed: shape = XC_X_cursor; break;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
|
@ -135,27 +135,27 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
|
||||
// clang-format off
|
||||
switch (type)
|
||||
{
|
||||
case Cursor::Arrow: shape = IDC_ARROW; break;
|
||||
case Cursor::ArrowWait: shape = IDC_APPSTARTING; break;
|
||||
case Cursor::Wait: shape = IDC_WAIT; break;
|
||||
case Cursor::Text: shape = IDC_IBEAM; break;
|
||||
case Cursor::Hand: shape = IDC_HAND; break;
|
||||
case Cursor::SizeHorizontal: shape = IDC_SIZEWE; break;
|
||||
case Cursor::SizeVertical: shape = IDC_SIZENS; break;
|
||||
case Cursor::SizeTopLeftBottomRight: shape = IDC_SIZENWSE; break;
|
||||
case Cursor::SizeBottomLeftTopRight: shape = IDC_SIZENESW; break;
|
||||
case Cursor::SizeLeft: shape = IDC_SIZEWE; break;
|
||||
case Cursor::SizeRight: shape = IDC_SIZEWE; break;
|
||||
case Cursor::SizeTop: shape = IDC_SIZENS; break;
|
||||
case Cursor::SizeBottom: shape = IDC_SIZENS; break;
|
||||
case Cursor::SizeTopLeft: shape = IDC_SIZENWSE; break;
|
||||
case Cursor::SizeBottomRight: shape = IDC_SIZENWSE; break;
|
||||
case Cursor::SizeBottomLeft: shape = IDC_SIZENESW; break;
|
||||
case Cursor::SizeTopRight: shape = IDC_SIZENESW; break;
|
||||
case Cursor::SizeAll: shape = IDC_SIZEALL; break;
|
||||
case Cursor::Cross: shape = IDC_CROSS; break;
|
||||
case Cursor::Help: shape = IDC_HELP; break;
|
||||
case Cursor::NotAllowed: shape = IDC_NO; break;
|
||||
case Cursor::Type::Arrow: shape = IDC_ARROW; break;
|
||||
case Cursor::Type::ArrowWait: shape = IDC_APPSTARTING; break;
|
||||
case Cursor::Type::Wait: shape = IDC_WAIT; break;
|
||||
case Cursor::Type::Text: shape = IDC_IBEAM; break;
|
||||
case Cursor::Type::Hand: shape = IDC_HAND; break;
|
||||
case Cursor::Type::SizeHorizontal: shape = IDC_SIZEWE; break;
|
||||
case Cursor::Type::SizeVertical: shape = IDC_SIZENS; break;
|
||||
case Cursor::Type::SizeTopLeftBottomRight: shape = IDC_SIZENWSE; break;
|
||||
case Cursor::Type::SizeBottomLeftTopRight: shape = IDC_SIZENESW; break;
|
||||
case Cursor::Type::SizeLeft: shape = IDC_SIZEWE; break;
|
||||
case Cursor::Type::SizeRight: shape = IDC_SIZEWE; break;
|
||||
case Cursor::Type::SizeTop: shape = IDC_SIZENS; break;
|
||||
case Cursor::Type::SizeBottom: shape = IDC_SIZENS; break;
|
||||
case Cursor::Type::SizeTopLeft: shape = IDC_SIZENWSE; break;
|
||||
case Cursor::Type::SizeBottomRight: shape = IDC_SIZENWSE; break;
|
||||
case Cursor::Type::SizeBottomLeft: shape = IDC_SIZENESW; break;
|
||||
case Cursor::Type::SizeTopRight: shape = IDC_SIZENESW; break;
|
||||
case Cursor::Type::SizeAll: shape = IDC_SIZEALL; break;
|
||||
case Cursor::Type::Cross: shape = IDC_CROSS; break;
|
||||
case Cursor::Type::Help: shape = IDC_HELP; break;
|
||||
case Cursor::Type::NotAllowed: shape = IDC_NO; break;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
|
@ -87,34 +87,34 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
|
||||
{
|
||||
default: return false;
|
||||
|
||||
case Cursor::Arrow: newCursor = [NSCursor arrowCursor]; break;
|
||||
case Cursor::Text: newCursor = [NSCursor IBeamCursor]; break;
|
||||
case Cursor::Hand: newCursor = [NSCursor pointingHandCursor]; break;
|
||||
case Cursor::SizeHorizontal: newCursor = [NSCursor resizeLeftRightCursor]; break;
|
||||
case Cursor::SizeVertical: newCursor = [NSCursor resizeUpDownCursor]; break;
|
||||
case Cursor::Cross: newCursor = [NSCursor crosshairCursor]; break;
|
||||
case Cursor::NotAllowed: newCursor = [NSCursor operationNotAllowedCursor]; break;
|
||||
case Cursor::SizeLeft: newCursor = [NSCursor resizeLeftRightCursor]; break;
|
||||
case Cursor::SizeRight: newCursor = [NSCursor resizeLeftRightCursor]; break;
|
||||
case Cursor::SizeTop: newCursor = [NSCursor resizeUpDownCursor]; break;
|
||||
case Cursor::SizeBottom: newCursor = [NSCursor resizeUpDownCursor]; break;
|
||||
case Cursor::Type::Arrow: newCursor = [NSCursor arrowCursor]; break;
|
||||
case Cursor::Type::Text: newCursor = [NSCursor IBeamCursor]; break;
|
||||
case Cursor::Type::Hand: newCursor = [NSCursor pointingHandCursor]; break;
|
||||
case Cursor::Type::SizeHorizontal: newCursor = [NSCursor resizeLeftRightCursor]; break;
|
||||
case Cursor::Type::SizeVertical: newCursor = [NSCursor resizeUpDownCursor]; break;
|
||||
case Cursor::Type::Cross: newCursor = [NSCursor crosshairCursor]; break;
|
||||
case Cursor::Type::NotAllowed: newCursor = [NSCursor operationNotAllowedCursor]; break;
|
||||
case Cursor::Type::SizeLeft: newCursor = [NSCursor resizeLeftRightCursor]; break;
|
||||
case Cursor::Type::SizeRight: newCursor = [NSCursor resizeLeftRightCursor]; break;
|
||||
case Cursor::Type::SizeTop: newCursor = [NSCursor resizeUpDownCursor]; break;
|
||||
case Cursor::Type::SizeBottom: newCursor = [NSCursor resizeUpDownCursor]; break;
|
||||
|
||||
// These cursor types are undocumented, may not be available on some platforms
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wundeclared-selector"
|
||||
case Cursor::SizeTopRight:
|
||||
case Cursor::SizeBottomLeft:
|
||||
case Cursor::SizeBottomLeftTopRight:
|
||||
case Cursor::Type::SizeTopRight:
|
||||
case Cursor::Type::SizeBottomLeft:
|
||||
case Cursor::Type::SizeBottomLeftTopRight:
|
||||
newCursor = loadFromSelector(@selector(_windowResizeNorthEastSouthWestCursor));
|
||||
break;
|
||||
|
||||
case Cursor::SizeTopLeft:
|
||||
case Cursor::SizeBottomRight:
|
||||
case Cursor::SizeTopLeftBottomRight:
|
||||
case Cursor::Type::SizeTopLeft:
|
||||
case Cursor::Type::SizeBottomRight:
|
||||
case Cursor::Type::SizeTopLeftBottomRight:
|
||||
newCursor = loadFromSelector(@selector(_windowResizeNorthWestSouthEastCursor));
|
||||
break;
|
||||
|
||||
case Cursor::Help:
|
||||
case Cursor::Type::Help:
|
||||
newCursor = loadFromSelector(@selector(_helpCursor));
|
||||
break;
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -51,19 +51,19 @@ TEST_CASE("[Window] sf::Cursor", runDisplayTests())
|
||||
SECTION("loadFromSystem()")
|
||||
{
|
||||
sf::Cursor cursor;
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Hand));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::SizeHorizontal));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::SizeVertical));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::SizeLeft));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::SizeRight));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::SizeTop));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::SizeBottom));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::SizeTopLeft));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::SizeTopRight));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::SizeBottomLeft));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::SizeBottomRight));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Cross));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Help));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::NotAllowed));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::Hand));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::SizeHorizontal));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::SizeVertical));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::SizeLeft));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::SizeRight));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::SizeTop));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::SizeBottom));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::SizeTopLeft));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::SizeTopRight));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::SizeBottomLeft));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::SizeBottomRight));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::Cross));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::Help));
|
||||
CHECK(cursor.loadFromSystem(sf::Cursor::Type::NotAllowed));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user