From e34c838da96747717811715bfc26ee4bbf2f2f0a Mon Sep 17 00:00:00 2001 From: "arthur.jamet" Date: Fri, 4 Jun 2021 17:03:24 +0200 Subject: [PATCH] add hold callback on button --- sources/Component/Button/ButtonComponent.cpp | 10 ++++++---- sources/Component/Button/ButtonComponent.hpp | 9 ++++++--- sources/Models/GameState.hpp | 1 - 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sources/Component/Button/ButtonComponent.cpp b/sources/Component/Button/ButtonComponent.cpp index e5108127..9218a619 100644 --- a/sources/Component/Button/ButtonComponent.cpp +++ b/sources/Component/Button/ButtonComponent.cpp @@ -16,18 +16,20 @@ namespace BBM } ButtonComponent::ButtonComponent(WAL::Entity &entity, WAL::Callback<> idleCallback, - WAL::Callback<> hoverCallback, WAL::Callback<> clickCallback) + WAL::Callback<> hoverCallback, WAL::Callback<> clickCallback, WAL::Callback<> holdCallback) : WAL::Component(entity), onIdle(idleCallback), onHover(hoverCallback), - onClick(clickCallback) + onClick(clickCallback), + onHold(holdCallback) { } ButtonComponent::ButtonComponent(WAL::Entity &entity, std::function idleCallback, - std::function hoverCallback, std::function clickCallback) + std::function hoverCallback, std::function clickCallback, std::function holdCallback) : WAL::Component(entity), onIdle(idleCallback), onHover(hoverCallback), - onClick(clickCallback) + onClick(clickCallback), + onHold(holdCallback) { } } \ No newline at end of file diff --git a/sources/Component/Button/ButtonComponent.hpp b/sources/Component/Button/ButtonComponent.hpp index e40ea6e4..274f6e28 100644 --- a/sources/Component/Button/ButtonComponent.hpp +++ b/sources/Component/Button/ButtonComponent.hpp @@ -19,8 +19,11 @@ namespace BBM //! @brief onHover callback WAL::Callback<> onHover; - //! @brief onClick callback + //! @brief onClick callback, when the mouse button is released WAL::Callback<> onClick; + + //! @brief onHold callback, when the mouse button is pressed + WAL::Callback<> onHold; //! @inherit @@ -30,10 +33,10 @@ namespace BBM explicit ButtonComponent(WAL::Entity &entity); //! @brief Constructor with the 3 callback - ButtonComponent(WAL::Entity &entity, WAL::Callback<> idleCallback, WAL::Callback<> hoverCallback, WAL::Callback<> clickCallback); + ButtonComponent(WAL::Entity &entity, WAL::Callback<> idleCallback, WAL::Callback<> hoverCallback, WAL::Callback<> clickCallback, WAL::Callback<> holdCallback); //! @brief Constructor with the 3 std functions - ButtonComponent(WAL::Entity &entity, std::function idleCallback, std::function hoverCallback, std::function clickCallback); + ButtonComponent(WAL::Entity &entity, std::function idleCallback, std::function hoverCallback, std::function clickCallback, std::function holdCallback); //! @brief A Controllable component is copy constructable. ButtonComponent(const ButtonComponent &) = default; diff --git a/sources/Models/GameState.hpp b/sources/Models/GameState.hpp index 9bf81501..c35dfa33 100644 --- a/sources/Models/GameState.hpp +++ b/sources/Models/GameState.hpp @@ -22,7 +22,6 @@ namespace BBM SettingsScene, PauseMenuScene, LobbyScene, - };