libGumball 0.0.1
C23-Based, libGimbal-powered UI Library
Loading...
Searching...
No Matches
gumball_common.h File Reference

Go to the source code of this file.

Macros

#define GUM_update(obj)
#define GUM_add_child(self, child)
#define GUM_remove_child(self, child)
#define GUM_get_child_at(self, index)
#define GUM_unref(obj)
#define GUM_connect(emitter, signal, callback, ...)
#define GUM_userData()
#define GUM_draw(...)
#define GUM_draw_disable(obj)
#define GUM_draw_enable(obj)
#define GUM_draw_disableAll(obj)
#define GUM_draw_enableAll(obj)
#define GUM_property(obj, name, ...)
#define GUM_setProperty(obj, name, ...)

Detailed Description

gumball_common is a collection of macros that are common to all elements in libGumball.

Author
2025 Agustín Bellagamba

Macro Definition Documentation

◆ GUM_update

#define GUM_update ( obj)

Takes in a UI element, updates it and all of its children.

◆ GUM_add_child

#define GUM_add_child ( self,
child )

Takes in two UI elements, adds the second one as a child of the first.

◆ GUM_remove_child

#define GUM_remove_child ( self,
child )

Takes in two UI elements, removes the second one as a child of the first.

◆ GUM_get_child_at

#define GUM_get_child_at ( self,
index )

Takes in a UI element and an index, returns the child of that element at that index as a GblObject that you can cast to the appropriate type.

Example:

GUM_Widget *pChild = GUM_WIDGET(GUM_get_child_at(pObj, 0));
Basic widget element.
#define GUM_get_child_at(self, index)
Takes in a UI element and an index, returns the child of that element at that index as a GblObject th...
Definition gumball_common.h:35
#define GUM_WIDGET(self)
Casts an instance of a compatible element to a GUM_Widget.
Definition gumball_widget.h:38

◆ GUM_unref

#define GUM_unref ( obj)

Decrements the reference count of a UI element, freeing it if it reaches zero.

Also recursively unrefs all of its children.

◆ GUM_connect

#define GUM_connect ( emitter,
signal,
callback,
... )
Connects an element's (typically a GUM_Button) signal to a callback.
The callback should take in a pointer to the UI element type that emitted the signal, and return void.
Optionally takes in userdata (a void* of whatever you want to pass in).
See GUM_Button for signal names
void buttonCallback(GUM_Button *pButton) {
void *ud = GUM_userData();
printf("Button pressed!\n");
printf("UserData: %i\n", *(int*)ud);
}
auto pButton = GUM_Button_create();
int data = 42;
GUM_connect(pButton, "onPressPrimary", buttonCallback, &data);
Basic button element.
Definition gumball_button.h:48
#define GUM_connect(emitter, signal, callback,...)
Definition gumball_common.h:60
#define GUM_userData()
Inside a callback connected to a signal, returns the userdata that was passed in.
Definition gumball_common.h:63

})

◆ GUM_userData

#define GUM_userData ( )

Inside a callback connected to a signal, returns the userdata that was passed in.

◆ GUM_draw

#define GUM_draw ( ...)

Draws all the UI elements in the draw queue.

Drawable elements are added to the draw queue when they are created Elements are drawn from z-index 0 to z-index 255, with 255 being the front If two elements have the same z-index, they are drawn in the order they were created (or enabled!) Optionally takes in a GUM_Renderer if your backend needs one (defaults to nullptr)

◆ GUM_draw_disable

#define GUM_draw_disable ( obj)

Disables drawing for a given element.

◆ GUM_draw_enable

#define GUM_draw_enable ( obj)

Enables drawing for a given element.

◆ GUM_draw_disableAll

#define GUM_draw_disableAll ( obj)

Disables drawing for a given element and all of its children.

◆ GUM_draw_enableAll

#define GUM_draw_enableAll ( obj)

Enables drawing for a given element and all of its children.

◆ GUM_property

#define GUM_property ( obj,
name,
... )

Looks up the property of an element by name, storing its value in the pointer passed as a variadic argument.

◆ GUM_setProperty

#define GUM_setProperty ( obj,
name,
... )

Sets the property with the given name to the value given by the pointer passed through the variadic argument list.