cmdfx
0.3.2
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
include
cmdfx
ui
button.h
Go to the documentation of this file.
1
11
#pragma once
12
13
#include "
cmdfx/core/events.h
"
14
#include "
cmdfx/core/sprites.h
"
15
16
#ifdef __cplusplus
17
extern
"C"
{
18
#endif
19
20
// use void pointer becuase not declared yet
21
33
typedef
void (*
CmdFX_ButtonCallback
)(
34
void
* button,
CmdFX_MouseEvent
* event,
unsigned
long
long
time
35
);
36
45
typedef
struct
CmdFX_Button
{
53
CmdFX_Sprite
*
sprite
;
61
int
x
;
69
int
y
;
80
int
id
;
88
int
type
;
97
void
*
extra
;
105
CmdFX_ButtonCallback
*
callback
;
106
}
CmdFX_Button
;
107
118
CmdFX_Button
**
Canvas_getRegisteredButtons
();
119
129
int
Canvas_getRegisteredButtonsCount
();
130
142
CmdFX_Button
*
Button_create
(
143
CmdFX_Sprite
* sprite,
CmdFX_ButtonCallback
callback
144
);
145
161
CmdFX_Button
*
Button_createFilled
(
162
int
width,
int
height,
char
c,
char
* ansi,
int
z,
163
CmdFX_ButtonCallback
callback
164
);
165
175
void
Button_free
(
CmdFX_Button
* button);
176
189
int
Button_draw
(
int
x,
int
y,
CmdFX_Button
* button);
190
201
int
Button_remove
(
CmdFX_Button
* button);
202
213
int
Button_isHidden
(
CmdFX_Button
* button);
214
226
int
Button_hide
(
CmdFX_Button
* button);
227
237
int
Button_show
(
CmdFX_Button
* button);
238
254
CmdFX_Button
**
Canvas_getAllButtonsAt
(
int
x,
int
y);
255
268
CmdFX_Button
*
Canvas_getButtonAt
(
int
x,
int
y);
269
285
int
Button_setData
(
CmdFX_Button
* button,
char
** data,
char
*** ansi);
286
299
int
Button_moveTo
(
CmdFX_Button
* button,
int
x,
int
y);
300
313
int
Button_moveBy
(
CmdFX_Button
* button,
int
dx,
int
dy);
314
315
#ifdef __cplusplus
316
}
317
#endif
Canvas_getAllButtonsAt
CmdFX_Button ** Canvas_getAllButtonsAt(int x, int y)
Gets all buttons at the given position.
Button_isHidden
int Button_isHidden(CmdFX_Button *button)
Checks if a button is hidden.
Canvas_getButtonAt
CmdFX_Button * Canvas_getButtonAt(int x, int y)
Gets the button at the given position.
Canvas_getRegisteredButtons
CmdFX_Button ** Canvas_getRegisteredButtons()
Gets an array of registered buttons.
Button_show
int Button_show(CmdFX_Button *button)
Shows a button in the UI manager if it is already hidden.
Button_moveTo
int Button_moveTo(CmdFX_Button *button, int x, int y)
Moves the button to the given position.
Button_free
void Button_free(CmdFX_Button *button)
Frees the memory associated with a button.
Canvas_getRegisteredButtonsCount
int Canvas_getRegisteredButtonsCount()
Gets the number of registered buttons.
CmdFX_ButtonCallback
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
Button_create
CmdFX_Button * Button_create(CmdFX_Sprite *sprite, CmdFX_ButtonCallback callback)
Creates a new button.
Button_hide
int Button_hide(CmdFX_Button *button)
Hides a button from the UI manager.
Button_draw
int Button_draw(int x, int y, CmdFX_Button *button)
Draws the button on the screen.
Button_createFilled
CmdFX_Button * Button_createFilled(int width, int height, char c, char *ansi, int z, CmdFX_ButtonCallback callback)
Creates a new filled button.
Button_remove
int Button_remove(CmdFX_Button *button)
Removes a button from the UI manager.
Button_moveBy
int Button_moveBy(CmdFX_Button *button, int dx, int dy)
Moves the button by the given offset.
Button_setData
int Button_setData(CmdFX_Button *button, char **data, char ***ansi)
Sets the data for a button.
events.h
Events API for CmdFX.
sprites.h
Sprites API for CmdFX.
CmdFX_Button
Represents a CmdFX button.
Definition
button.h:45
CmdFX_Button::sprite
CmdFX_Sprite * sprite
The sprite associated with this button.
Definition
button.h:53
CmdFX_Button::type
int type
A unique type of the button.
Definition
button.h:88
CmdFX_Button::y
int y
The Y position of the button.
Definition
button.h:69
CmdFX_Button::extra
void * extra
A pointer to extra data associated with this button.
Definition
button.h:97
CmdFX_Button::callback
CmdFX_ButtonCallback * callback
The callback function to be called when the button is clicked.
Definition
button.h:105
CmdFX_Button::id
int id
The unique ID of the button.
Definition
button.h:80
CmdFX_Button::x
int x
The X position of the button.
Definition
button.h:61
CmdFX_MouseEvent
The payload for the CMDFX_EVENT_MOUSE event.
Definition
events.h:102
CmdFX_Sprite
Represents a sprite that can be drawn to the terminal.
Definition
sprites.h:31
Generated by
1.14.0