From 02276d122b804412cb4223fb32fdfe2578764d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 22 Nov 2018 16:53:22 +0100 Subject: [PATCH] Audio: return self-reference from all Source APIs. So I can e.g. do source .pause() .setOffsetInSeconds(1.5); to seek the track. --- doc/changelog.dox | 6 ++++++ src/Magnum/Audio/Source.h | 24 ++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 082ed61b0..15c723449 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -76,6 +76,12 @@ r>>) @subsection changelog-latest-changes Changes and improvements +@subsubsection changelog-latest-changes-audio Audio library + +- @ref Audio::Source::play(), @ref Audio::Source::pause(), + @ref Audio::Source::rewind() and @ref Audio::Source::stop() now return + a self-reference like all other methods for easier method chaining + @subsubsection changelog-latest-changes-gl GL library - New @ref GL::Context::State::BindScratchVao state to make external OpenGL diff --git a/src/Magnum/Audio/Source.h b/src/Magnum/Audio/Source.h index c4bae6dbe..72c0328f7 100644 --- a/src/Magnum/Audio/Source.h +++ b/src/Magnum/Audio/Source.h @@ -586,39 +586,55 @@ class MAGNUM_AUDIO_EXPORT Source { /** * @brief Play + * @return Reference to self (for method chaining) * * @see @ref play(std::initializer_list>), * @ref state(), @ref pause(), @ref stop(), @ref rewind(), * @fn_al_keyword{SourcePlay} */ - void play() { alSourcePlay(_id); } + Source& play() { + alSourcePlay(_id); + return *this; + } /** * @brief Pause + * @return Reference to self (for method chaining) * * @see @ref pause(std::initializer_list>), * @ref state(), @ref play(), @ref stop(), @ref rewind(), * @fn_al_keyword{SourcePause} */ - void pause() { alSourcePause(_id); } + Source& pause() { + alSourcePause(_id); + return *this; + } /** * @brief Stop + * @return Reference to self (for method chaining) * * @see @ref stop(std::initializer_list>), * @ref state(), @ref play(), @ref pause(), @ref rewind(), * @fn_al_keyword{SourceStop} */ - void stop() { alSourceStop(_id); } + Source& stop() { + alSourceStop(_id); + return *this; + } /** * @brief Rewind + * @return Reference to self (for method chaining) * * @see @ref rewind(std::initializer_list>), * @ref state(), @ref play(), @ref pause(), @ref stop(), * @fn_al_keyword{SourceRewind} */ - void rewind() { alSourceRewind(_id); } + Source& rewind() { + alSourceRewind(_id); + return *this; + } /** * @brief Whether the source is looping