diff options
author | falkTX <falktx@falktx.com> | 2022-05-27 00:30:12 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-12-24 19:47:25 -0500 |
commit | cdfb8223301faba2c478c805b35ca457e6547629 (patch) | |
tree | f024df90192e74ff11f1e9eeb766825758f9f691 | |
parent | ebf23245ce3dff82d804c957ad928fe11457311f (diff) | |
download | pugl-cdfb8223301faba2c478c805b35ca457e6547629.tar.gz pugl-cdfb8223301faba2c478c805b35ca457e6547629.tar.bz2 pugl-cdfb8223301faba2c478c805b35ca457e6547629.zip |
Add diagonal cursors
-rw-r--r-- | examples/pugl_cursor_demo.c | 4 | ||||
-rw-r--r-- | include/pugl/pugl.h | 16 | ||||
-rw-r--r-- | src/mac.m | 17 | ||||
-rw-r--r-- | src/win.c | 16 | ||||
-rw-r--r-- | src/x11.c | 6 |
5 files changed, 41 insertions, 18 deletions
diff --git a/examples/pugl_cursor_demo.c b/examples/pugl_cursor_demo.c index c9839da..ccece41 100644 --- a/examples/pugl_cursor_demo.c +++ b/examples/pugl_cursor_demo.c @@ -8,9 +8,9 @@ #include <stdbool.h> -static const int N_CURSORS = 7; +static const int N_CURSORS = 9; static const int N_ROWS = 2; -static const int N_COLS = 4; +static const int N_COLS = 5; typedef struct { PuglWorld* world; diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h index b928c9e..67b1e60 100644 --- a/include/pugl/pugl.h +++ b/include/pugl/pugl.h @@ -1261,13 +1261,15 @@ puglPostRedisplayRect(PuglView* view, PuglRect rect); Windows. */ typedef enum { - PUGL_CURSOR_ARROW, ///< Default pointing arrow - PUGL_CURSOR_CARET, ///< Caret (I-Beam) for text entry - PUGL_CURSOR_CROSSHAIR, ///< Cross-hair - PUGL_CURSOR_HAND, ///< Hand with a pointing finger - PUGL_CURSOR_NO, ///< Operation not allowed - PUGL_CURSOR_LEFT_RIGHT, ///< Left/right arrow for horizontal resize - PUGL_CURSOR_UP_DOWN, ///< Up/down arrow for vertical resize + PUGL_CURSOR_ARROW, ///< Default pointing arrow + PUGL_CURSOR_CARET, ///< Caret (I-Beam) for text entry + PUGL_CURSOR_CROSSHAIR, ///< Cross-hair + PUGL_CURSOR_HAND, ///< Hand with a pointing finger + PUGL_CURSOR_NO, ///< Operation not allowed + PUGL_CURSOR_LEFT_RIGHT, ///< Left/right arrow for horizontal resize + PUGL_CURSOR_UP_DOWN, ///< Up/down arrow for vertical resize + PUGL_CURSOR_UP_LEFT_DOWN_RIGHT, ///< Diagonal arrow for down/right resize + PUGL_CURSOR_UP_RIGHT_DOWN_LEFT, ///< Diagonal arrow for down/left resize } PuglCursor; /// The number of #PuglCursor values @@ -1672,6 +1672,19 @@ puglGetClipboard(PuglView* const view, } static NSCursor* +extendedCursor(const SEL cursorSelector) +{ + if (cursorSelector && [NSCursor respondsToSelector:cursorSelector]) { + const id object = [NSCursor performSelector:cursorSelector]; + if ([object isKindOfClass:[NSCursor class]]) { + return (NSCursor*)object; + } + } + + return NULL; +} + +static NSCursor* puglGetNsCursor(const PuglCursor cursor) { switch (cursor) { @@ -1689,6 +1702,10 @@ puglGetNsCursor(const PuglCursor cursor) return [NSCursor resizeLeftRightCursor]; case PUGL_CURSOR_UP_DOWN: return [NSCursor resizeUpDownCursor]; + case PUGL_CURSOR_UP_LEFT_DOWN_RIGHT: + return extendedCursor(@selector(_windowResizeNorthWestSouthEastCursor)); + case PUGL_CURSOR_UP_RIGHT_DOWN_LEFT: + return extendedCursor(@selector(_windowResizeNorthEastSouthWestCursor)); } return NULL; @@ -1295,13 +1295,15 @@ puglPaste(PuglView* const view) } static const char* const cursor_ids[] = { - IDC_ARROW, // ARROW - IDC_IBEAM, // CARET - IDC_CROSS, // CROSSHAIR - IDC_HAND, // HAND - IDC_NO, // NO - IDC_SIZEWE, // LEFT_RIGHT - IDC_SIZENS, // UP_DOWN + IDC_ARROW, // ARROW + IDC_IBEAM, // CARET + IDC_CROSS, // CROSSHAIR + IDC_HAND, // HAND + IDC_NO, // NO + IDC_SIZEWE, // LEFT_RIGHT + IDC_SIZENS, // UP_DOWN + IDC_SIZENWSE, // UP_LEFT_DOWN_RIGHT + IDC_SIZENESW, // UP_RIGHT_DOWN_LEFT }; PuglStatus @@ -66,7 +66,7 @@ enum WmClientStateMessageAction { WM_STATE_TOGGLE }; -#define NUM_CURSORS ((unsigned)PUGL_CURSOR_UP_DOWN + 1U) +#define NUM_CURSORS ((unsigned)PUGL_CURSOR_UP_RIGHT_DOWN_LEFT + 1U) #ifdef HAVE_XCURSOR static const char* const cursor_names[NUM_CURSORS] = { @@ -76,7 +76,9 @@ static const char* const cursor_names[NUM_CURSORS] = { "pointer", // HAND "not-allowed", // NO "sb_h_double_arrow", // LEFT_RIGHT - "sb_v_double_arrow" // UP_DOWN + "sb_v_double_arrow", // UP_DOWN + "size_fdiag", // UP_LEFT_DOWN_RIGHT + "size_bdiag", // UP_RIGHT_DOWN_LEFT }; #endif |