GBAlatro
A Demake of Balatro for the GBA
Loading...
Searching...
No Matches
button.h File Reference

A button structure containing the common button functionalities Including highlight and pressing functionalities. More...

#include <tonc_types.h>

Go to the source code of this file.

Data Structures

struct  Button
 A button representation. More...
 

Macros

#define BTN_HIGHLIGHT_COLOR   0xFFFF
 
#define BUTTON_SFX_VOLUME   154
 

Typedefs

typedef void(* ButtonOnPressedFunc) (void)
 The function to be called when the button is pressed.
 
typedef bool(* ButtonCanBePressedFunc) (void)
 Returns true if the button should be activated when pressed.
 

Functions

void button_set_highlight (Button *button, bool highlight)
 Set the button highlight on or off.
 
void button_press (Button *button)
 Execute a button press, by calling the button's on_pressed function. This checks the button's can_be_pressed function and will do nothing if returns false.
 

Detailed Description

A button structure containing the common button functionalities Including highlight and pressing functionalities.

Definition in file button.h.

Macro Definition Documentation

◆ BTN_HIGHLIGHT_COLOR

#define BTN_HIGHLIGHT_COLOR   0xFFFF

Definition at line 13 of file button.h.

◆ BUTTON_SFX_VOLUME

#define BUTTON_SFX_VOLUME   154

Definition at line 15 of file button.h.

Typedef Documentation

◆ ButtonCanBePressedFunc

typedef bool(* ButtonCanBePressedFunc) (void)

Returns true if the button should be activated when pressed.

Definition at line 25 of file button.h.

◆ ButtonOnPressedFunc

typedef void(* ButtonOnPressedFunc) (void)

The function to be called when the button is pressed.

Definition at line 20 of file button.h.

Function Documentation

◆ button_press()

void button_press ( Button button)

Execute a button press, by calling the button's on_pressed function. This checks the button's can_be_pressed function and will do nothing if returns false.

Button presses should go through this function rather than directly call on_pressed.

Parameters
buttonThe button being pressed. No-op on NULL.

Definition at line 18 of file button.c.

◆ button_set_highlight()

void button_set_highlight ( Button button,
bool  highlight 
)

Set the button highlight on or off.

Parameters
buttonThe button to modify. No-op on NULL.
highlighttrue to highlight, false to unhighlight.

Definition at line 8 of file button.c.