Re #307 More cleanup in tgfclient API + fixed bad default font for GfuiMenuBackQuitButtonCreate

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3590 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: a65673c0498c490991b8e096eac8256f344dc354
Former-commit-id: 4aed56d3746341cb7fd648f31d22c6001c217968
This commit is contained in:
pouillot 2011-05-19 21:11:32 +00:00
parent 0d7641ac34
commit 292e72c1bc
4 changed files with 36 additions and 78 deletions

View file

@ -63,7 +63,6 @@ GfuiMenuDefaultKeysAdd(void *scr)
GfuiAddKey(scr, GFUIK_PAGEDOWN, "Select Next Entry", NULL, gfuiSelectNext, NULL); GfuiAddKey(scr, GFUIK_PAGEDOWN, "Select Next Entry", NULL, gfuiSelectNext, NULL);
GfuiAddKey(scr, GFUIK_F1, "Help", scr, GfuiHelpScreen, NULL); GfuiAddKey(scr, GFUIK_F1, "Help", scr, GfuiHelpScreen, NULL);
GfuiAddKey(scr, GFUIK_F12, "Screen-Shot", NULL, GfuiScreenShot, NULL); GfuiAddKey(scr, GFUIK_F12, "Screen-Shot", NULL, GfuiScreenShot, NULL);
} }
/** Create a new menu screen. /** Create a new menu screen.
@ -98,44 +97,6 @@ onFocusLostHideTip(void *cbinfo)
GfuiVisibilitySet(((tMnuCallbackInfo*)cbinfo)->screen, ((tMnuCallbackInfo*)cbinfo)->labelId, 0); GfuiVisibilitySet(((tMnuCallbackInfo*)cbinfo)->screen, ((tMnuCallbackInfo*)cbinfo)->labelId, 0);
} }
/** Add a button to a menu screen.
@ingroup gui
@param scr Screen (menu) handle
@param text Text of the button
@param tip Text of the tip displayed when the button is focused
@param userData Parameter of the Push function
@param style Alignment horizontally/vertically
@param onpush Callback when the button is pushed
@return Button 3
*/
int
GfuiMenuButtonCreate(void *scr, const char *text, const char *tip,
void *userData, const int style, tfuiCallback onpush)
{
int nbItems = ((tGfuiScreen*)scr)->nbItems++;
if (nbItems > 22) {
GfTrace("Too many items in that menu !!!\n");
return -1;
}
int xpos = 270;
int ypos = 380 - 30 * (nbItems % 11);
tMnuCallbackInfo *cbinfo = (tMnuCallbackInfo*)calloc(1, sizeof(tMnuCallbackInfo));
cbinfo->screen = scr;
cbinfo->labelId = GfuiTipCreate(scr, tip, strlen(tip));
GfuiVisibilitySet(scr, cbinfo->labelId, 0);
int bId = GfuiButtonCreate(scr, text, GFUI_FONT_LARGE, xpos, ypos, GFUI_BTNSZ, style, 0,
userData, onpush,
(void*)cbinfo, onFocusShowTip, onFocusLostHideTip);
return bId;
}//GfuiMenuButtonCreate
/** Add a button to a menu screen. /** Add a button to a menu screen.
@ingroup gui @ingroup gui
@param scr Screen (menu) handle @param scr Screen (menu) handle
@ -143,28 +104,17 @@ GfuiMenuButtonCreate(void *scr, const char *text, const char *tip,
@param tip Text of the tip displayed when the button is focused @param tip Text of the tip displayed when the button is focused
@param userData Parameter of the Push function @param userData Parameter of the Push function
@param onpush Callback when the button is pushed @param onpush Callback when the button is pushed
@param align Alignment horizontally/vertically
@return Button Id @return Button Id
*/ */
int int
GfuiMenuButtonCreateEx(void *scr, const char *text, const char *tip, void *userData, tfuiCallback onpush,int xpos,int ypos,int fontSize,int align) GfuiMenuButtonCreate(void *scr, const char *text, const char *tip,
void *userDataOnPush, tfuiCallback onPush,
int xpos, int ypos, int fontSize, int align)
{ {
tMnuCallbackInfo *cbinfo; tMnuCallbackInfo *cbinfo;
//int xpos, ypos;
//int nbItems = ((tGfuiScreen*)scr)->nbItems++;
int bId; int bId;
/*
if (nbItems < 11) {
ypos = ypos - 30 * nbItems;
} else {
if (nbItems > 22) {
GfTrace("Too many items in that menu !!!\n");
return -1;
}
//xpos = 380;
ypos = ypos - 30 * (nbItems - 11);
}
*/
cbinfo = (tMnuCallbackInfo*)calloc(1, sizeof(tMnuCallbackInfo)); cbinfo = (tMnuCallbackInfo*)calloc(1, sizeof(tMnuCallbackInfo));
cbinfo->screen = scr; cbinfo->screen = scr;
cbinfo->labelId = GfuiTipCreate(scr, tip, strlen(tip)); cbinfo->labelId = GfuiTipCreate(scr, tip, strlen(tip));
@ -172,7 +122,7 @@ GfuiMenuButtonCreateEx(void *scr, const char *text, const char *tip, void *userD
GfuiVisibilitySet(scr, cbinfo->labelId, 0); GfuiVisibilitySet(scr, cbinfo->labelId, 0);
bId = GfuiButtonCreate(scr, text, fontSize, xpos, ypos, GFUI_BTNSZ, align, 0, bId = GfuiButtonCreate(scr, text, fontSize, xpos, ypos, GFUI_BTNSZ, align, 0,
userData, onpush, userDataOnPush, onPush,
(void*)cbinfo, onFocusShowTip, onFocusLostHideTip); (void*)cbinfo, onFocusShowTip, onFocusLostHideTip);
return bId; return bId;

View file

@ -341,7 +341,7 @@ TGFCLIENT_API void GfuiUnSelectCurrent(void);
#define GFUI_FONT_DIGIT 8 #define GFUI_FONT_DIGIT 8
TGFCLIENT_API int GfuiLabelCreate(void* scr, const char* text, TGFCLIENT_API int GfuiLabelCreate(void* scr, const char* text,
int font, int x, int y, int align, int maxlen, int font, int x, int y, int align, int maxlen,
const float* fgColorPtr = 0, const float* fgFocusColorPtr = 0, const float* fgColor = 0, const float* fgFocusColor = 0,
void* userDataOnFocus = 0, tfuiCallback onFocus = 0, tfuiCallback onFocusLost = 0); void* userDataOnFocus = 0, tfuiCallback onFocus = 0, tfuiCallback onFocusLost = 0);
TGFCLIENT_API void GfuiSetTipPosition(int x,int y); TGFCLIENT_API void GfuiSetTipPosition(int x,int y);
@ -463,11 +463,14 @@ TGFCLIENT_API void GfuiStaticImageSetActive(void* scr, int id, int index);
TGFCLIENT_API void* GfuiMenuScreenCreate(const char* title); TGFCLIENT_API void* GfuiMenuScreenCreate(const char* title);
TGFCLIENT_API void GfuiMenuDefaultKeysAdd(void* scr); TGFCLIENT_API void GfuiMenuDefaultKeysAdd(void* scr);
TGFCLIENT_API int GfuiMenuButtonCreate(void* menu, const char* text, const char* tip, void* userData, const int style, tfuiCallback onpush); TGFCLIENT_API int GfuiMenuButtonCreate(void *scr, const char *text, const char *tip,
void *userDataOnPush, tfuiCallback onPush,
int xpos, int ypos,
int fontSize = GFUI_FONT_LARGE, int align = GFUI_ALIGN_HC_VB);
TGFCLIENT_API int GfuiMenuBackQuitButtonCreate(void* scr, const char* text, const char* tip, TGFCLIENT_API int GfuiMenuBackQuitButtonCreate(void* scr, const char* text, const char* tip,
void* userData, tfuiCallback onpush, void* userData, tfuiCallback onpush,
int xpos = 320, int ypos = 40, int xpos = 320, int ypos = 40,
int fontSize = GFUI_BTNSZ, int align = GFUI_ALIGN_HC_VB); int fontSize = GFUI_FONT_LARGE, int align = GFUI_ALIGN_HC_VB);
/******************************************* /*******************************************
* New XML based Menu Management Interface * * New XML based Menu Management Interface *
@ -487,6 +490,7 @@ TGFCLIENT_API int GfuiMenuCreateComboboxControl(void* menuHandle, void* param, c
TGFCLIENT_API int GfuiMenuCreateCheckboxControl(void* menuHandle, void* param, const char* pControlName, void* userData, tfuiCheckboxCallback onChange); TGFCLIENT_API int GfuiMenuCreateCheckboxControl(void* menuHandle, void* param, const char* pControlName, void* userData, tfuiCheckboxCallback onChange);
TGFCLIENT_API int GfuiMenuCreateProgressbarControl(void* menuHandle, void* param, const char* pControlName); TGFCLIENT_API int GfuiMenuCreateProgressbarControl(void* menuHandle, void* param, const char* pControlName);
/***************************** /*****************************
* Texture / image interface * * Texture / image interface *
*****************************/ *****************************/

View file

@ -853,16 +853,17 @@ RmNetworkMenu(void *)
str = GfParmGetStr(params, RM_SECT_HEADER, RM_ATTR_NAME, 0); str = GfParmGetStr(params, RM_SECT_HEADER, RM_ATTR_NAME, 0);
if (str) { if (str) {
GfuiTitleCreate(racemanMenuHdle, str, strlen(str)); GfuiTitleCreate(racemanMenuHdle, str, strlen(str));
} }
GfuiMenuButtonCreate(racemanMenuHdle, GfuiMenuButtonCreate(racemanMenuHdle,
"Host Online Race", "Host a race", "Host Online Race", "Host a race",
NULL, GFUI_ALIGN_HL_VB, RmNetworkHostMenu); NULL, RmNetworkHostMenu,
270, 380, GFUI_FONT_LARGE, GFUI_ALIGN_HL_VB);
GfuiMenuButtonCreate(racemanMenuHdle, GfuiMenuButtonCreate(racemanMenuHdle,
"Connect to Online Race", "Connect to a race on Internet or Network", "Connect to Online Race", "Connect to a race on Internet or Network",
NULL, GFUI_ALIGN_HL_VB, NetworkClientMenu); NULL, NetworkClientMenu,
270, 350, GFUI_FONT_LARGE, GFUI_ALIGN_HL_VB);
GfuiMenuBackQuitButtonCreate(racemanMenuHdle, GfuiMenuBackQuitButtonCreate(racemanMenuHdle,
"Back", "Return to previous Menu", "Back", "Return to previous Menu",

View file

@ -140,10 +140,8 @@ typedef struct {
static void* static void*
rmStopRaceScreen(const char *title, const tButtonDesc aButtons[], int nButtons, int nCancelIndex) rmStopRaceScreen(const char *title, const tButtonDesc aButtons[], int nButtons, int nCancelIndex)
{ {
void *screenHdle = 0;
// Create screen, load menu XML descriptor and create static controls. // Create screen, load menu XML descriptor and create static controls.
screenHdle = GfuiScreenCreate(NULL, NULL, NULL, NULL, NULL, 1); void *screenHdle = GfuiScreenCreate(NULL, NULL, NULL, NULL, NULL, 1);
void *menuXMLDescHdle = GfuiMenuLoad("stopracemenu.xml"); void *menuXMLDescHdle = GfuiMenuLoad("stopracemenu.xml");
@ -154,11 +152,14 @@ rmStopRaceScreen(const char *title, const tButtonDesc aButtons[], int nButtons,
GfuiLabelSetText(screenHdle, titleId, title); GfuiLabelSetText(screenHdle, titleId, title);
// Create specified buttons, left aligned. // Create specified buttons, left aligned.
const int xpos = 270;
int ypos = 380;
for (int nButInd = 0; nButInd < nButtons; nButInd++) for (int nButInd = 0; nButInd < nButtons; nButInd++)
{ {
const int id = const int id =
GfuiMenuButtonCreate(screenHdle, aButtons[nButInd].label, aButtons[nButInd].tip, GfuiMenuButtonCreate(screenHdle, aButtons[nButInd].label, aButtons[nButInd].tip,
aButtons[nButInd].screen, GFUI_ALIGN_HL_VB, GfuiScreenActivate); aButtons[nButInd].screen, GfuiScreenActivate,
xpos, ypos, GFUI_FONT_LARGE, GFUI_ALIGN_HL_VB);
GfuiButtonShowBox(screenHdle, id, false); GfuiButtonShowBox(screenHdle, id, false);
GfuiColor c, fc, pc; GfuiColor c, fc, pc;
@ -169,6 +170,8 @@ rmStopRaceScreen(const char *title, const tButtonDesc aButtons[], int nButtons,
GfuiButtonSetColor(screenHdle, id, c); GfuiButtonSetColor(screenHdle, id, c);
GfuiButtonSetFocusColor(screenHdle, id, fc); GfuiButtonSetFocusColor(screenHdle, id, fc);
GfuiButtonSetPushedColor(screenHdle, id, pc); GfuiButtonSetPushedColor(screenHdle, id, pc);
ypos -= 30;
} }
// Close menu XML descriptor. // Close menu XML descriptor.