diff options
-rw-r--r-- | include/pugl/pugl.h | 11 | ||||
-rw-r--r-- | src/mac.m | 4 | ||||
-rw-r--r-- | src/types.h | 2 | ||||
-rw-r--r-- | src/win.c | 2 | ||||
-rw-r--r-- | test/test_utils.h | 4 |
5 files changed, 14 insertions, 9 deletions
diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h index 779cc80..17fa3de 100644 --- a/include/pugl/pugl.h +++ b/include/pugl/pugl.h @@ -859,10 +859,11 @@ typedef enum { PUGL_RESIZABLE, ///< True if view should be resizable PUGL_IGNORE_KEY_REPEAT, ///< True if key repeat events are ignored PUGL_REFRESH_RATE, ///< Refresh rate in Hz - - PUGL_NUM_VIEW_HINTS } PuglViewHint; +/// The number of #PuglViewHint values +#define PUGL_NUM_VIEW_HINTS ((unsigned)PUGL_REFRESH_RATE + 1u) + /// A special view hint value typedef enum { PUGL_DONT_CARE = -1, ///< Use best available value @@ -907,6 +908,9 @@ typedef enum { PUGL_MAX_ASPECT } PuglSizeHint; +/// The number of #PuglSizeHint values +#define PUGL_NUM_SIZE_HINTS ((unsigned)PUGL_MAX_ASPECT + 1u) + /// A function called when an event occurs typedef PuglStatus (*PuglEventFunc)(PuglView* view, const PuglEvent* event); @@ -1260,6 +1264,9 @@ typedef enum { PUGL_CURSOR_UP_DOWN, ///< Up/down arrow for vertical resize } PuglCursor; +/// The number of #PuglCursor values +#define PUGL_NUM_CURSORS ((unsigned)PUGL_CURSOR_UP_DOWN + 1u) + /** Grab the keyboard input focus. @@ -998,7 +998,7 @@ updateSizeHint(PuglView* const view, const PuglSizeHint hint) static void updateSizeHints(PuglView* const view) { - for (unsigned i = 0u; i <= PUGL_MAX_ASPECT; ++i) { + for (unsigned i = 0u; i < PUGL_NUM_SIZE_HINTS; ++i) { updateSizeHint(view, (PuglSizeHint)i); } } @@ -1542,7 +1542,7 @@ puglSetSizeHint(PuglView* const view, const PuglSpan width, const PuglSpan height) { - if ((unsigned)hint > (unsigned)PUGL_MAX_ASPECT) { + if ((unsigned)hint >= PUGL_NUM_SIZE_HINTS) { return PUGL_BAD_PARAMETER; } diff --git a/src/types.h b/src/types.h index aa028b1..dc2e29f 100644 --- a/src/types.h +++ b/src/types.h @@ -46,7 +46,7 @@ struct PuglViewImpl { PuglRect frame; PuglConfigureEvent lastConfigure; PuglHints hints; - PuglViewSize sizeHints[(unsigned)PUGL_MAX_ASPECT + 1u]; + PuglViewSize sizeHints[PUGL_NUM_SIZE_HINTS]; bool visible; }; @@ -1127,7 +1127,7 @@ puglSetSizeHint(PuglView* const view, const PuglSpan width, const PuglSpan height) { - if ((unsigned)hint > (unsigned)PUGL_MAX_ASPECT) { + if ((unsigned)hint >= PUGL_NUM_SIZE_HINTS) { return PUGL_BAD_PARAMETER; } diff --git a/test/test_utils.h b/test/test_utils.h index b7a8f42..359f51d 100644 --- a/test/test_utils.h +++ b/test/test_utils.h @@ -254,8 +254,6 @@ puglViewHintString(const PuglViewHint hint) return "Ignore key repeat"; case PUGL_REFRESH_RATE: return "Refresh rate"; - case PUGL_NUM_VIEW_HINTS: - break; } return "Unknown"; @@ -264,7 +262,7 @@ puglViewHintString(const PuglViewHint hint) static inline void printViewHints(const PuglView* view) { - for (int i = 0; i < PUGL_NUM_VIEW_HINTS; ++i) { + for (unsigned i = 0; i < PUGL_NUM_VIEW_HINTS; ++i) { const PuglViewHint hint = (PuglViewHint)i; fprintf(stderr, "%s: %d\n", |