From 654dc1a4124869cbbe17848d459c43685b5a4089 Mon Sep 17 00:00:00 2001 From: Corentin Schreiber Date: Sat, 7 Oct 2023 18:14:27 +0100 Subject: [PATCH 1/2] Fixed doc and added play/pause/stop --- include/lxgui/gui_animated_texture.hpp | 31 +++++++++++++++++++++++--- src/gui_animated_texture_glues.cpp | 12 ++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/include/lxgui/gui_animated_texture.hpp b/include/lxgui/gui_animated_texture.hpp index 269f92381..fb811de08 100644 --- a/include/lxgui/gui_animated_texture.hpp +++ b/include/lxgui/gui_animated_texture.hpp @@ -57,7 +57,7 @@ class animated_texture : public layered_region { float get_state() const; /** - * \brief Check if this animated_texture is paused + * \brief Check if this animated_texture is paused. * \return 'true' if paused, 'false' otherwise */ float is_paused() const; @@ -90,11 +90,36 @@ class animated_texture : public layered_region { void set_state(float state); /** - * \brief Check if this animated_texture is paused - * \return 'true' if paused, 'false' otherwise + * \brief Play or pause this animated_texture. + * \param is_paused 'true' to pause, 'false' to play */ void set_paused(bool is_paused); + /** + * \brief Play this animated_texture. + * \note Has no effect if already playing + */ + + void play() { + set_paused(false); + } + + /** + * \brief Pause this animated_texture. + * \note Has no effect if already paused + */ + void pause() { + set_paused(true); + } + + /** + * \brief Stop this animated_texture (stop playing and reset to start). + */ + void stop() { + set_paused(true); + set_state(0.0f); + } + /** * \brief Sets this texture's texture file. * \param file_name The file from which to read data diff --git a/src/gui_animated_texture_glues.cpp b/src/gui_animated_texture_glues.cpp index 15e934383..936dd9ae5 100644 --- a/src/gui_animated_texture_glues.cpp +++ b/src/gui_animated_texture_glues.cpp @@ -46,6 +46,18 @@ void animated_texture::register_on_lua(sol::state& lua) { return std::make_tuple(color.r, color.g, color.b, color.a); }); + /** @function pause + */ + type.set_function("pause", member_function<&animated_texture::pause>()); + + /** @function play + */ + type.set_function("play", member_function<&animated_texture::play>()); + + /** @function stop + */ + type.set_function("stop", member_function<&animated_texture::stop>()); + /** @function set_speed */ type.set_function("set_speed", member_function<&animated_texture::set_speed>()); From 56d82bec67bb3fb68e07229ba506b984c0d2ade8 Mon Sep 17 00:00:00 2001 From: Corentin Schreiber Date: Sat, 7 Oct 2023 18:15:58 +0100 Subject: [PATCH 2/2] Removed extra whitespace --- include/lxgui/gui_animated_texture.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/lxgui/gui_animated_texture.hpp b/include/lxgui/gui_animated_texture.hpp index fb811de08..705cd900a 100644 --- a/include/lxgui/gui_animated_texture.hpp +++ b/include/lxgui/gui_animated_texture.hpp @@ -99,7 +99,6 @@ class animated_texture : public layered_region { * \brief Play this animated_texture. * \note Has no effect if already playing */ - void play() { set_paused(false); }