libGumball 0.0.1
C23-Based, libGimbal-powered UI Library
Loading...
Searching...
No Matches
gumball_container.h
Go to the documentation of this file.
1#ifndef GUM_CONTAINER_H
2#define GUM_CONTAINER_H
3
4// View this file's documentation online: https://libgumball.psyops.studio/gumball__container_8h.html
5
6/*! \file
7 * \ref GUM_Container "GUM_Container data structure and hierarchy graph"
8 * \ingroup elements
9 *
10 * GUM_Container is a container element that can hold other widgets.
11 * It can be used to group widgets together, and to optionally automatically resize / align them as needed.
12 *
13 * \todo
14 * - Make variables private
15 * - Make orientation an enum
16 * - Add scrolling
17 *
18 * \author 2025 Agustín Bellagamba
19 * \copyright MIT License
20*/
21
22#include "gumball_widget.h"
23
24/*! \name Type System
25 * \brief Type UUID and cast operators
26 * @{
27*/
28#define GUM_CONTAINER_TYPE (GBL_TYPEID (GUM_Container)) //!< Returns the GUM_Container Type UUID
29#define GUM_CONTAINER(self) (GBL_CAST (GUM_Container, self)) //!< Casts an instance of a compatible element to a GUM_Container
30#define GUM_CONTAINER_CLASS(klass) (GBL_CLASS_CAST (GUM_Container, klass)) //!< Casts an class of a compatible element to a GUM_ContainerClass
31#define GUM_CONTAINER_CLASSOF(self) (GBL_CLASSOF (GUM_Container, self)) //!< Casts an instance of a compatible element to a GUM_Container
32//! @}
33
34#define GBL_SELF_TYPE GUM_Container
35
36GBL_DECLS_BEGIN
37GBL_FORWARD_DECLARE_STRUCT(GUM_Container);
38
39/*!
40 \struct GUM_ContainerClass
41 \extends GUM_WidgetClass
42 \brief GUM_Container structure
43
44 GUM_ContainerClass derives from GUM_WidgetClass,
45 adding nothing new.
46*/
47GBL_CLASS_DERIVE_EMPTY(GUM_Container, GUM_Widget)
48
49/*!
50 * \class GUM_Container
51 * \extends GUM_Widget
52 * \brief Container element
53 *
54*/
55
56/*!
57 \name Properties
58 \brief Properties you can set/get at or after creation.
59 \note You can also set/get properties from parent classes (see \ref GUM_Container).
60 @{
61*/
62GBL_INSTANCE_DERIVE(GUM_Container, GUM_Widget)
63 char orientation; //!< 'h' for horizontal, 'v' for vertical layout of child widgets. Default value is 'v' \warning This is planned to be replaced by an enum.
64 bool resizeWidgets; //!< If child widgets should be resized to take an equal amount of space. Default value is true
65 bool alignWidgets; //!< If child widgets should be aligned. Default value is true
66 float padding; //!< The space between the container's border and its child widgets. Default value is 5
67 float margin; //!< The space between child widgets. Default value is 5
68GBL_INSTANCE_END
69//! @}
70
71GBL_PROPERTIES(GUM_Container,
72 (orientation, GBL_GENERIC, (READ, WRITE), GBL_CHAR_TYPE),
73 (resizeWidgets, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
74 (alignWidgets, GBL_GENERIC, (READ, WRITE), GBL_BOOL_TYPE),
75 (padding, GBL_GENERIC, (READ, WRITE), GBL_FLOAT_TYPE),
76 (margin, GBL_GENERIC, (READ, WRITE), GBL_FLOAT_TYPE)
77)
78
79GblType GUM_Container_type(void);
80
81//! Returns a new GUM_Container. Optionally takes in a list of Name/Value pairs for properties
82#define GUM_Container_create(/* propertyName, propertyValue */ ...) GBL_NEW(GUM_Container __VA_OPT__(,) __VA_ARGS__)
83
84GBL_DECLS_END
85#undef GBL_SELF_TYPE
86
87#endif // GUM_CONTAINER_H
float padding
The space between the container's border and its child widgets.
Definition gumball_container.h:66
bool resizeWidgets
If child widgets should be resized to take an equal amount of space.
Definition gumball_container.h:64
float margin
The space between child widgets.
Definition gumball_container.h:67
bool alignWidgets
If child widgets should be aligned.
Definition gumball_container.h:65