libGumball 0.0.1
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 an 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,
46 * adding nothing new.
47*/
48GBL_CLASS_DERIVE_EMPTY(GUM_Button, GUM_Widget)
49
50/*!
51 * \class GUM_Button
52 * \extends GUM_Widget
53 * \brief Basic button element
54 *
55*/
56
57/*!
58 * \name Properties
59 * \brief Button properties you can set/get at or after creation.
60 * \note You can also set/get properties from parent classes (see \ref GUM_Button).
61 * @{
62*/
63GBL_INSTANCE_DERIVE(GUM_Button, GUM_Widget)
64 bool isActive; //!< If this button can be pressed. Default value is true
65 bool isSelectable; //!< If this button can be selected. Default value is true
66 //! \cond
67 bool isSelected; // If this button is currently selected
68 //! \endcond
69 bool isSelectedByDefault; //!< If this button should be selected by default when the cursor doesn't have a button selected. Default value is false
70GBL_INSTANCE_END
71//! @}
72
73GBL_PROPERTIES(GUM_Button,
74 (isActive, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
75 (isSelectable, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
76 (isSelectedByDefault, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE)
77)
78
79//! \cond
80GBL_SIGNALS(GUM_Button,
81 (onPressPrimary, (GBL_INSTANCE_TYPE, pReceiver)), //!< \copydoc \ref gum_button_clicked
82 (onPressSecondary, (GBL_INSTANCE_TYPE, pReceiver)), //!< For secondary actions (e.g., right-click)
83 (onPressTertiary, (GBL_INSTANCE_TYPE, pReceiver)) //!< For tertiary actions (e.g., middle-click)
84)
85
86GblType GUM_Button_type(void);
87//! \endcond
88
89//! Returns a new GUM_Button. Optionally takes in a list of Name/Value pairs for properties
90#define GUM_Button_create(/* propertyName, propertyValue */ ...) GBL_NEW(GUM_Button __VA_OPT__(,) __VA_ARGS__)
91
92GBL_DECLS_END
93
94#undef GBL_SELF_TYPE
95
96#endif // GUM_BUTTON_H
bool isSelectable
If this button can be selected.
Definition gumball_button.h:65
bool isSelectedByDefault
If this button should be selected by default when the cursor doesn't have a button selected.
Definition gumball_button.h:69