cmdfx 0.2.1
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
button.h
Go to the documentation of this file.
1
11#pragma once
12
13#include "cmdfx/core/sprites.h"
14#include "cmdfx/core/events.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20// use void pointer becuase not declared yet
21
33typedef void (*CmdFX_ButtonCallback)(void* button, CmdFX_MouseEvent* event, unsigned long long time);
34
100
111
122
134
150CmdFX_Button* Button_createFilled(int width, int height, char c, char* ansi, int z, CmdFX_ButtonCallback callback);
151
162
175int Button_draw(int x, int y, CmdFX_Button* button);
176
187
199
212
223
238
251
267int Button_setData(CmdFX_Button* button, char** data, char*** ansi);
268
281int Button_moveTo(CmdFX_Button* button, int x, int y);
282
295int Button_moveBy(CmdFX_Button* button, int dx, int dy);
296
297#ifdef __cplusplus
298}
299#endif
CmdFX_Button ** Canvas_getAllButtonsAt(int x, int y)
Gets all buttons at the given position.
int Button_isHidden(CmdFX_Button *button)
Checks if a button is hidden.
CmdFX_Button * Canvas_getButtonAt(int x, int y)
Gets the button at the given position.
CmdFX_Button ** Canvas_getRegisteredButtons()
Gets an array of registered buttons.
int Button_show(CmdFX_Button *button)
Shows a button in the UI manager if it is already hidden.
int Button_moveTo(CmdFX_Button *button, int x, int y)
Moves the button to the given position.
void Button_free(CmdFX_Button *button)
Frees the memory associated with a button.
int Canvas_getRegisteredButtonsCount()
Gets the number of registered buttons.
void(* CmdFX_ButtonCallback)(void *button, CmdFX_MouseEvent *event, unsigned long long time)
The callback function to be called when the button is clicked.
Definition button.h:33
CmdFX_Button * Button_create(CmdFX_Sprite *sprite, CmdFX_ButtonCallback callback)
Creates a new button.
int Button_hide(CmdFX_Button *button)
Hides a button from the UI manager.
int Button_draw(int x, int y, CmdFX_Button *button)
Draws the button on the screen.
CmdFX_Button * Button_createFilled(int width, int height, char c, char *ansi, int z, CmdFX_ButtonCallback callback)
Creates a new filled button.
int Button_remove(CmdFX_Button *button)
Removes a button from the UI manager.
int Button_moveBy(CmdFX_Button *button, int dx, int dy)
Moves the button by the given offset.
int Button_setData(CmdFX_Button *button, char **data, char ***ansi)
Sets the data for a button.
Events API for CmdFX.
Sprites API for CmdFX.
Represents a CmdFX button.
Definition button.h:42
CmdFX_Sprite * sprite
The sprite associated with this button.
Definition button.h:49
int type
A unique type of the button.
Definition button.h:81
int y
The Y position of the button.
Definition button.h:63
void * extra
A pointer to extra data associated with this button.
Definition button.h:90
CmdFX_ButtonCallback * callback
The callback function to be called when the button is clicked.
Definition button.h:98
int id
The unique ID of the button.
Definition button.h:73
int x
The X position of the button.
Definition button.h:56
The payload for the CMDFX_EVENT_MOUSE event.
Definition events.h:102
Represents a sprite that can be drawn to the terminal.
Definition sprites.h:30