59 int x,
int y,
int align,
int mouse,
71 object->id = screen->
curId++;
74 button = &(
object->u.grbutton);
88 object->xmin = x - width;
91 object->ymax =
y + height;
94 object->xmin = x - width;
96 object->ymin =
y - height / 2;
97 object->ymax =
y + height / 2;
100 object->xmin = x - width;
102 object->ymin =
y - height;
106 object->xmin = x - width / 2;
107 object->xmax = x + width / 2;
109 object->ymax =
y + height;
112 object->xmin = x - width / 2;
113 object->xmax = x + width / 2;
114 object->ymin =
y - height / 2;
115 object->ymax =
y + height / 2;
118 object->xmin = x - width / 2;
119 object->xmax = x + width / 2;
120 object->ymin =
y - height;
125 object->xmax = x + width;
127 object->ymax =
y + height;
131 object->xmax = x + width;
132 object->ymin =
y - height / 2;
133 object->ymax =
y + height / 2;
137 object->xmax = x + width;
138 object->ymin =
y - height;
145 button->
width = width;
153GfuiGrButtonCreate(
void *scr,
const char *disabled,
const char *enabled,
const char *focused,
const char *pushed,
154 int x,
int y,
int align,
int mouse,
189 id =
GfuiButtonCreateAction(scr, text, font, x,
y, width, align, mouse,
onPush, onFocus,
onFocusLost);
192 if (curObject != NULL) {
194 curObject = curObject->
next;
195 if (curObject->
id ==
id) {
197 button = &(curObject->
u.
button);
202 }
while (curObject != screen->
objects);
241 object->id = screen->
curId++;
244 button = &(
object->u.button);
265 label = &(button->
label);
266 label->
text = (
char*)calloc(1, 100);
267 strncpy(label->
text, text, 100);
268 label->
text[99] =
'\0';
272 width =
gfuiFont[font]->getWidth((
const char *)text);
275 label->
align = align;
279 label->
x =
object->xmin = x;
280 label->
y =
y - 2 *
gfuiFont[font]->getDescender();
282 object->xmax = x + width;
286 object->xmin = x - width / 2;
287 label->
x = x -
gfuiFont[font]->getWidth((
const char *)text) / 2;
288 label->
y =
y - 2 *
gfuiFont[font]->getDescender();
290 object->xmax = x + width / 2;
294 label->
x =
object->xmin = x - width;
295 label->
y =
y - 2 *
gfuiFont[font]->getDescender();
301#define HORIZ_MARGIN 10
310GfuiButtonCreate(
void *scr,
const char *text,
int font,
int x,
int y,
int width,
int align,
int mouse,
363 if (curObject != NULL) {
365 curObject = curObject->
next;
366 if (curObject->
id ==
id) {
368 oldmax = curObject->
xmax;
369 oldmin = curObject->
xmin;
371 curObject->
xmax = oldmax;
372 curObject->
xmin = oldmin;
376 }
while (curObject != screen->
objects);
392 if (curObject != NULL) {
394 curObject = curObject->
next;
395 if (curObject->
focus) {
397 return curObject->
id;
429 if (bgColor[3] != 0.0) {
438 glBegin(GL_LINE_STRIP);
446 label = &(button->
label);
463 }
else if (obj->
focus) {
469 glRasterPos2i(obj->
xmin, obj->
ymin);
471 glDrawPixels(button->
width, button->
height, GL_RGBA, GL_UNSIGNED_BYTE, img);
489 }
else if (action == 1) {
514 }
else if (action == 1) {
552 }
else if (action == 1) {
573 }
else if (action == 1) {
603 label = &(button->
label);
static void onPush(tCmdInfo *cmdInfo)
static void onFocusLost(void)
int GfuiButtonGetFocused(void)
Get the Id of the button focused in the current screen.
int GfuiButtonStateCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Add a state button to a screen.
int GfuiGrButtonCreate(void *scr, const char *disabled, const char *enabled, const char *focused, const char *pushed, int x, int y, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Create an image button using callbacks with caller-supplied data.
int GfuiLeanButtonCreateAction(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Create a text button without horizontal margins.
int GfuiButtonCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Create a text button using callbacks with caller-supplied data.
void GfuiButtonSetText(void *scr, int id, const char *text)
Change the label of a button.
int GfuiButtonStateCreateAction(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Create a text button that toggles between pressed and released while focused.
int GfuiGrButtonCreateAction(void *scr, const char *disabled, const char *enabled, const char *focused, const char *pushed, int x, int y, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Add a graphical button to a screen.
int GfuiButtonCreateAction(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Add a button to a screen.
int GfuiLeanButtonCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Create a marginless text button using callbacks with caller-supplied data.
unsigned char * GfImgReadPng(const char *filename, int *widthp, int *heightp, float screen_gamma)
Load an image from disk to a buffer in RGBA mode.
void GfScrGetSize(int *scrw, int *scrh, int *vieww, int *viewh)
Get the screen and viewport sizes.
void gfuiReleaseAction(tGfuiAction *action)
tGfuiAction gfuiMakeAction(void *userData, tfuiCallback callback)
float GfuiColor[GFUI_COLORNB][4]
tGfuiAction * gfuiCreateAction(const tGfuiAction &action)
void gfuiRunAction(const tGfuiAction *action)
void gfuiSetLabelText(tGfuiObject *object, tGfuiLabel *label, const char *text)
#define GFUI_BTN_RELEASED
#define GFUI_BGBTNENABLED
#define GFUI_BGBTNDISABLED
void gfuiPrintString(int x, int y, GfuiFontClass *font, const char *string)
void gfuiAddObject(tGfuiScreen *screen, tGfuiObject *object)
struct GfuiObject tGfuiObject
tGfuiObject * gfuiGetObject(void *scr, int id)
#define GFUI_FOCUS_MOUSE_MOVE
GfuiFontClass * gfuiFont[FONT_NB]
union GfuiObject::@107216344126174123112226307372375007210201317144 u
The Gaming Framework API (client part).
void(* tfuiCallback)(void *)
std::function< void()> tGfuiAction