From bd4f79646f623e929e6aa22bea028952b515aeef Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 12 Jan 2023 10:30:10 -0500 Subject: Add general string hint interface This replaces the window title and class name APIs with a more general one that can be easily extended to other things, like icon names, more detailed application hints, and so on. --- bindings/cpp/include/pugl/pugl.hpp | 42 ++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'bindings/cpp') diff --git a/bindings/cpp/include/pugl/pugl.hpp b/bindings/cpp/include/pugl/pugl.hpp index 109e947..90c5de6 100644 --- a/bindings/cpp/include/pugl/pugl.hpp +++ b/bindings/cpp/include/pugl/pugl.hpp @@ -68,6 +68,16 @@ private: using Rect = PuglRect; ///< @copydoc PuglRect +/// @copydoc PuglStringHint +enum class StringHint { + className = 1, ///< @copydoc PUGL_CLASS_NAME + windowTitle, ///< @copydoc PUGL_WINDOW_TITLE +}; + +static_assert(static_cast(PUGL_WINDOW_TITLE) == + StringHint::windowTitle, + ""); + /** @defgroup puglpp_events Events @{ @@ -306,10 +316,17 @@ public: /// @copydoc puglGetNativeWorld void* nativeWorld() noexcept { return puglGetNativeWorld(cobj()); } - /// @copydoc puglSetClassName - Status setClassName(const char* const name) noexcept + /// @copydoc puglSetWorldString + Status setString(StringHint key, const char* const value) noexcept { - return static_cast(puglSetClassName(cobj(), name)); + return static_cast( + puglSetWorldString(cobj(), static_cast(key), value)); + } + + /// @copydoc puglGetWorldString + const char* getString(StringHint key) noexcept + { + return puglGetWorldString(cobj(), static_cast(key)); } /// @copydoc puglGetTime @@ -473,6 +490,19 @@ public: return puglGetViewHint(cobj(), static_cast(hint)); } + /// @copydoc puglSetViewString + Status setString(StringHint key, const char* const value) noexcept + { + return static_cast( + puglSetViewString(cobj(), static_cast(key), value)); + } + + /// @copydoc puglGetViewString + const char* getString(StringHint key) noexcept + { + return puglGetViewString(cobj(), static_cast(key)); + } + /** @} @name Frame @@ -503,12 +533,6 @@ public: @{ */ - /// @copydoc puglSetWindowTitle - Status setWindowTitle(const char* title) noexcept - { - return static_cast(puglSetWindowTitle(cobj(), title)); - } - /// @copydoc puglSetParentWindow Status setParentWindow(NativeView parent) noexcept { -- cgit v1.2.1