From 1cd37cad0a06fbb15c44fd59dd6b2c12a0812a76 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 20 May 2022 14:23:41 -0400 Subject: Add a uniform API for setting size hints This collapses many functions into one, which makes the API more easily extensible and reduces code size. --- bindings/cpp/include/pugl/pugl.hpp | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'bindings/cpp/include') diff --git a/bindings/cpp/include/pugl/pugl.hpp b/bindings/cpp/include/pugl/pugl.hpp index 5387c91..5b47fe6 100644 --- a/bindings/cpp/include/pugl/pugl.hpp +++ b/bindings/cpp/include/pugl/pugl.hpp @@ -327,6 +327,15 @@ public: using Backend = PuglBackend; ///< @copydoc PuglBackend using NativeView = PuglNativeView; ///< @copydoc PuglNativeView +/// @copydoc PuglSizeHint +enum class SizeHint { + defaultSize, ///< @copydoc PUGL_DEFAULT_SIZE + minSize, ///< @copydoc PUGL_MIN_SIZE + maxSize, ///< @copydoc PUGL_MAX_SIZE + minAspect, ///< @copydoc PUGL_MIN_ASPECT + maxAspect, ///< @copydoc PUGL_MAX_ASPECT +}; + /// @copydoc PuglViewHint enum class ViewHint { useCompatProfile, ///< @copydoc PUGL_USE_COMPAT_PROFILE @@ -458,29 +467,11 @@ public: return static_cast(puglSetFrame(cobj(), frame)); } - /// @copydoc puglSetDefaultSize - Status setDefaultSize(int width, int height) noexcept - { - return static_cast(puglSetDefaultSize(cobj(), width, height)); - } - - /// @copydoc puglSetMinSize - Status setMinSize(int width, int height) noexcept - { - return static_cast(puglSetMinSize(cobj(), width, height)); - } - - /// @copydoc puglSetMaxSize - Status setMaxSize(int width, int height) noexcept - { - return static_cast(puglSetMaxSize(cobj(), width, height)); - } - - /// @copydoc puglSetAspectRatio - Status setAspectRatio(int minX, int minY, int maxX, int maxY) noexcept + /// @copydoc puglSetSizeHint + Status setSizeHint(SizeHint hint, PuglSpan width, PuglSpan height) noexcept { return static_cast( - puglSetAspectRatio(cobj(), minX, minY, maxX, maxY)); + puglSetSizeHint(cobj(), static_cast(hint), width, height)); } /** -- cgit v1.2.1