libGumball 0.0.2
C23-Based, libGimbal-powered UI Library
Loading...
Searching...
No Matches
gumball_button.h
Go to the documentation of this file.
1#ifndef GUM_BUTTON_H
2#define GUM_BUTTON_H
3
4// View this file's documentation online: https://libgumball.psyops.studio/gumball__button_8h.html
5
6/*! \file
7 * \ref GUM_Button "GUM_Button data structure and hierarchy graph"
8 * \ingroup elements
9 *
10 * GUM_Button is a basic button element that can be selected and pressed,
11 * firing a signal you can connect a callback to.
12 *
13 * \todo
14 * - Add a way to override cursor movement to the desired GUM_Button pointer.
15 * - Button highlighting animations
16 * - Make variables private
17 * - Document signals
18 *
19 * \author 2025 Agustín Bellagamba
20 * \copyright MIT License
21*/
22
23#include "gumball_widget.h"
24
25/*! \name Type System
26 * \brief Type UUID and cast operators
27 * @{
28*/
29#define GUM_BUTTON_TYPE (GBL_TYPEID (GUM_Button)) //!< Returns the GUM_Button Type UUID
30#define GUM_BUTTON(self) (GBL_CAST (GUM_Button, self)) //!< Casts an instance of a compatible element to a GUM_Button
31#define GUM_BUTTON_CLASS(klass) (GBL_CLASS_CAST (GUM_Button, klass)) //!< Casts a class of a compatible element to a GUM_ButtonClass
32#define GUM_BUTTON_CLASSOF(self) (GBL_CLASSOF (GUM_Button, self)) //!< Casts an instance of a compatible element to a GUM_ButtonClass
33//! @}
34
35#define GBL_SELF_TYPE GUM_Button
36
37GBL_DECLS_BEGIN
38GBL_FORWARD_DECLARE_STRUCT(GUM_Button);
39
40/*!
41 * \struct GUM_ButtonClass
42 * \extends GUM_WidgetClass
43 * \brief GUM_Button structure
44 *
45 * GUM_ButtonClass derives from GUM_WidgetClass, adding nothing new.
46*/
47GBL_CLASS_DERIVE_EMPTY(GUM_Button, GUM_Widget)
48
49/*!
50 * \class GUM_Button
51 * \extends GUM_Widget
52 * \brief Basic button element
53 *
54*/
55
56/*!
57 * \name Properties
58 * \brief Button properties you can set/get at or after creation.
59 * \note You can also set/get properties from parent classes (see \ref GUM_Button).
60 * @{
61*/
62GBL_INSTANCE_DERIVE(GUM_Button, GUM_Widget)
63 bool isActive; //!< If this button can be pressed. Default value is true
64 bool isSelectable; //!< If this button can be selected. Default value is true
65 //! \cond
66 bool isSelected; // If this button is currently selected
67 //! \endcond
68 bool isSelectedByDefault; //!< If this button should be selected by default when the cursor doesn't have a button selected. Default value is false
69GBL_INSTANCE_END
70//! @}
71
72GBL_PROPERTIES(GUM_Button,
73 (isActive, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
74 (isSelectable, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
75 (isSelectedByDefault, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE)
76)
77
78//! \cond
79GBL_SIGNALS(GUM_Button,
80 (onPressPrimary, (GBL_INSTANCE_TYPE, pReceiver)), //!< \copydoc \ref gum_button_clicked
81 (onPressSecondary, (GBL_INSTANCE_TYPE, pReceiver)), //!< For secondary actions (e.g., right-click)
82 (onPressTertiary, (GBL_INSTANCE_TYPE, pReceiver)) //!< For tertiary actions (e.g., middle-click)
83)
84
85GblType GUM_Button_type(void);
86//! \endcond
87
88//! Returns a new GUM_Button. Optionally takes in a list of Name/Value pairs for properties
89#define GUM_Button_create(/* propertyName, propertyValue */ ...) GBL_NEW(GUM_Button __VA_OPT__(,) __VA_ARGS__)
90
91GBL_DECLS_END
92
93#undef GBL_SELF_TYPE
94
95#endif // GUM_BUTTON_H
bool isSelectable
If this button can be selected.
Definition gumball_button.h:64
bool isSelectedByDefault
If this button should be selected by default when the cursor doesn't have a button selected.
Definition gumball_button.h:68