diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-04 20:12:34 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-04 20:12:34 +0100 |
commit | 6454975779acb39d7d546e11855a07a952e68e5b (patch) | |
tree | 3c13741ebbeb36f4df85654b232dcfbce8c66e4b /src/crepe/api/Button.h | |
parent | b0a7296eb4319d123c88b34f162c28d0717c98e4 (diff) |
loeks feedback changes
Diffstat (limited to 'src/crepe/api/Button.h')
-rw-r--r-- | src/crepe/api/Button.h | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/crepe/api/Button.h b/src/crepe/api/Button.h index 06d64d6..043cc78 100644 --- a/src/crepe/api/Button.h +++ b/src/crepe/api/Button.h @@ -7,25 +7,21 @@ namespace crepe { /** - * \class Button * \brief Represents a clickable UI button, derived from the UiObject class. * - * This class provides functionality for a button in the UI, including toggle state, - * click handling, and mouse hover detection. A callback function can be provided to - * handle button clicks. */ -class Button : public UiObject { +class Button : public UIObject { public: /** * \brief Constructs a Button with the specified game object ID and dimensions. * * \param id The unique ID of the game object associated with this button. - * \param width The width of the button. - * \param height The height of the button. + * \param Dimensions The width and height of the UIObject + * \param offset The offset relative this GameObjects Transform * \param is_toggle Optional flag to indicate if the button is a toggle button. Defaults to false. * \param on_click callback function that will be invoked when the button is clicked. */ - Button(game_object_id_t id, int width, int height, std::function<void()> on_click, + Button(game_object_id_t id, vec2 dimensions,vec2 offset, std::function<void()> on_click, bool is_toggle = false); /** @@ -50,7 +46,7 @@ public: * This function is triggered when the mouse cursor moves over the button, allowing * custom actions like visual effects, highlighting, or sound effects. */ - std::function<void()> on_enter = nullptr; + std::function<void()> on_mouse_enter = nullptr; /** * \brief Callback function to be executed when the mouse exits the button's boundaries. @@ -58,14 +54,15 @@ public: * This function is triggered when the mouse cursor moves out of the button's area, * allowing custom actions like resetting visual effects or playing exit-related effects. */ - std::function<void()> on_exit = nullptr; + std::function<void()> on_mouse_exit = nullptr; private: + //! friend relation for is_pressed and hover variables friend class InputSystem; /** - * \brief Indicates whether the button is currently pressed. + * \brief Indicates whether the toggle button is pressed * - * This state is true when the button is actively pressed and false otherwise. + * This state indicates if the toggle button is pressed or not */ bool is_pressed = false; @@ -77,12 +74,6 @@ private: bool hover = false; public: - /** - * \brief Retrieves the maximum number of instances allowed for this button type. - * - * \return Always returns 1, as only a single instance of this type is allowed. - */ - virtual int get_instances_max() const override { return 1; } }; } // namespace crepe |