diff options
Diffstat (limited to 'src/crepe/api/Button.h')
-rw-r--r-- | src/crepe/api/Button.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/crepe/api/Button.h b/src/crepe/api/Button.h new file mode 100644 index 0000000..d42527e --- /dev/null +++ b/src/crepe/api/Button.h @@ -0,0 +1,48 @@ +#pragma once + +#include <functional> + +#include "Event.h" +#include "UIObject.h" + +namespace crepe { + +/** + * \brief Button component. + * + * This component creates a clickable surface at the transform location with the specified width and height. + * + * The Button can be used in scripts by subscribing a EventHandler to the following events: + * - ButtonPressEvent + * - ButtonEnterEvent + * - ButtonExitEvent + * \see EventManager + * + */ +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 dimensions The width and height of the UIObject + * \param offset The offset relative this GameObjects Transform + */ + Button(game_object_id_t id, const vec2 & dimensions, const vec2 & offset); + /** + * \brief Get the maximum number of instances for this component + * + * Since the button Event transfers the GameObject Metadata it will be the same for each button so only one button is allowed per GameObject + * + * \return 1 + */ + virtual int get_instances_max() const { return 1; } + +private: + //! friend relation hover variable + friend class InputSystem; + //! Indicates whether the mouse is currently hovering over the button + bool hover = false; +}; + +} // namespace crepe |