From 1dce4defe62b5e0ed70460b52c444dc51a701e18 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 22 Jan 2025 18:42:11 -0500 Subject: Make puglSetSizeHint() consistent with puglSetSize() In general, it's more convenient to have full-width integers as parameters, since C will promote any arithmetic on smaller types to them anyway. Using narrow types here, then, doesn't really make anything stricter, just forces an annoying cast when lots of warnings are enabled, which is likely unchecked. Better to handle it here, since it's more convenient, and the integer range checks the compiler can do aren't correct anyway (the max width/height is intentionally smaller than the max PuglSpan, so it can fit in a signed 16-bit integer). --- include/pugl/pugl.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'include/pugl') diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h index e3ab504..b70b91d 100644 --- a/include/pugl/pugl.h +++ b/include/pugl/pugl.h @@ -1234,8 +1234,8 @@ PUGL_API PuglStatus puglSetSizeHint(PuglView* view, PuglSizeHint hint, - PuglSpan width, - PuglSpan height); + unsigned width, + unsigned height); /** @} @@ -1820,7 +1820,7 @@ static inline PUGL_DEPRECATED_BY("puglSetSizeHint") void puglInitWindowMinSize(PuglView* view, int width, int height) { - puglSetSizeHint(view, PUGL_MIN_SIZE, (PuglSpan)width, (PuglSpan)height); + puglSetSizeHint(view, PUGL_MIN_SIZE, (unsigned)width, (unsigned)height); } /** @@ -1841,8 +1841,8 @@ puglInitWindowAspectRatio(PuglView* view, int maxX, int maxY) { - puglSetSizeHint(view, PUGL_MIN_ASPECT, (PuglSpan)minX, (PuglSpan)minY); - puglSetSizeHint(view, PUGL_MAX_ASPECT, (PuglSpan)maxX, (PuglSpan)maxY); + puglSetSizeHint(view, PUGL_MIN_ASPECT, (unsigned)minX, (unsigned)minY); + puglSetSizeHint(view, PUGL_MAX_ASPECT, (unsigned)maxX, (unsigned)maxY); } /** @@ -2081,7 +2081,7 @@ PuglStatus puglSetDefaultSize(PuglView* view, int width, int height) { return puglSetSizeHint( - view, PUGL_DEFAULT_SIZE, (PuglSpan)width, (PuglSpan)height); + view, PUGL_DEFAULT_SIZE, (unsigned)width, (unsigned)height); } /** @@ -2098,7 +2098,7 @@ PuglStatus puglSetMinSize(PuglView* view, int width, int height) { return puglSetSizeHint( - view, PUGL_MIN_SIZE, (PuglSpan)width, (PuglSpan)height); + view, PUGL_MIN_SIZE, (unsigned)width, (unsigned)height); } /** @@ -2115,7 +2115,7 @@ PuglStatus puglSetMaxSize(PuglView* view, int width, int height) { return puglSetSizeHint( - view, PUGL_MAX_SIZE, (PuglSpan)width, (PuglSpan)height); + view, PUGL_MAX_SIZE, (unsigned)width, (unsigned)height); } /** @@ -2139,10 +2139,10 @@ PuglStatus puglSetAspectRatio(PuglView* view, int minX, int minY, int maxX, int maxY) { const PuglStatus st0 = - puglSetSizeHint(view, PUGL_MIN_ASPECT, (PuglSpan)minX, (PuglSpan)minY); + puglSetSizeHint(view, PUGL_MIN_ASPECT, (unsigned)minX, (unsigned)minY); const PuglStatus st1 = - puglSetSizeHint(view, PUGL_MAX_ASPECT, (PuglSpan)maxX, (PuglSpan)maxY); + puglSetSizeHint(view, PUGL_MAX_ASPECT, (unsigned)maxX, (unsigned)maxY); return st0 ? st0 : st1; } -- cgit v1.2.1