aboutsummaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-01-12 10:30:10 -0500
committerDavid Robillard <d@drobilla.net>2023-01-14 11:53:28 -0500
commitbd4f79646f623e929e6aa22bea028952b515aeef (patch)
treee2dcc2635bb2b12b9c552755b35a0343005ce88a /bindings
parent786a28e4a2bc9fce95a8d2e6cd1a4c76d2ae1a0f (diff)
downloadpugl-bd4f79646f623e929e6aa22bea028952b515aeef.tar.gz
pugl-bd4f79646f623e929e6aa22bea028952b515aeef.tar.bz2
pugl-bd4f79646f623e929e6aa22bea028952b515aeef.zip
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.
Diffstat (limited to 'bindings')
-rw-r--r--bindings/cpp/include/pugl/pugl.hpp42
1 files changed, 33 insertions, 9 deletions
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<StringHint>(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<Status>(puglSetClassName(cobj(), name));
+ return static_cast<Status>(
+ puglSetWorldString(cobj(), static_cast<PuglStringHint>(key), value));
+ }
+
+ /// @copydoc puglGetWorldString
+ const char* getString(StringHint key) noexcept
+ {
+ return puglGetWorldString(cobj(), static_cast<PuglStringHint>(key));
}
/// @copydoc puglGetTime
@@ -473,6 +490,19 @@ public:
return puglGetViewHint(cobj(), static_cast<PuglViewHint>(hint));
}
+ /// @copydoc puglSetViewString
+ Status setString(StringHint key, const char* const value) noexcept
+ {
+ return static_cast<Status>(
+ puglSetViewString(cobj(), static_cast<PuglStringHint>(key), value));
+ }
+
+ /// @copydoc puglGetViewString
+ const char* getString(StringHint key) noexcept
+ {
+ return puglGetViewString(cobj(), static_cast<PuglStringHint>(key));
+ }
+
/**
@}
@name Frame
@@ -503,12 +533,6 @@ public:
@{
*/
- /// @copydoc puglSetWindowTitle
- Status setWindowTitle(const char* title) noexcept
- {
- return static_cast<Status>(puglSetWindowTitle(cobj(), title));
- }
-
/// @copydoc puglSetParentWindow
Status setParentWindow(NativeView parent) noexcept
{