Re #333 Made customizable the size of combo-boxes' arrow images + updated menus using it + better tips/texts for new Graphics options

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

Former-commit-id: 331dc470c6e50426286d163a0944c8c4a54af549
Former-commit-id: c716a6cca6fe95de82608dfa11c12507597f591f
This commit is contained in:
pouillot 2012-01-07 15:56:07 +00:00
parent 4a21b74f19
commit 64558c3ce4
5 changed files with 43 additions and 11 deletions

View file

@ -82,8 +82,32 @@ gfuiRightArrow(void *idv)
combobox->onChange(combobox->pInfo);
}
/** Add combo-box like control to a screen.
@ingroup gui
@param scr Screen
@param font Font id
@param x X position on screen (0 = left)
@param y Y position on screen (0 = bottom)
@param width Width on the screen
@param arrowsWidth Width of the arrow buttons on the screen (0 = image width)
@param arrowsHeight Height of the arrow buttons on the screen (0 = image height)
@param pszText Text to display
@param maxlen Maximum length of the dsiaplyed text
<br>0 for the text length.
@param fgColor Pointer on static RGBA color array (0 => default)
@param fgFocusColor Pointer on static RGBA focused color array (0 => fgColor)
@param userData User data attached to the combo-box
@param onChange Change callback function
@param userDataOnFocus Parameter to the Focus (and lost) callback
@param onFocus Focus callback function
@param onFocusLost Focus Lost callback function
@return ComboBox Id
<br>-1 Error
*/
int
GfuiComboboxCreate(void *scr, int font, int x, int y, int width,
int arrowsWidth, int arrowsHeight,
const char *pszText, int maxlen,
const float *fgColor, const float *fgFocusColor,
void *userData, tfuiComboboxCallback onChange,
@ -113,17 +137,17 @@ GfuiComboboxCreate(void *scr, int font, int x, int y, int width,
// Initialize the left and right arrow button children.
// Warning: All the arrow images are supposed to be the same size.
// TODO: Make graphic properties XML-customizable (images, ...)
// TODO: Make image files customizable.
gfuiGrButtonInit(&combobox->leftButton,
"data/img/arrow-left-disabled.png", "data/img/arrow-left.png",
"data/img/arrow-left-focused.png", "data/img/arrow-left-pushed.png",
x, y, 0, 0, GFUI_MOUSE_UP,
(void*)(object->id), gfuiLeftArrow, 0, 0, 0);
x, y, arrowsWidth, arrowsHeight,
GFUI_MOUSE_UP, (void*)(object->id), gfuiLeftArrow, 0, 0, 0);
gfuiGrButtonInit(&combobox->rightButton,
"data/img/arrow-right-disabled.png", "data/img/arrow-right.png",
"data/img/arrow-right-focused.png", "data/img/arrow-right-pushed.png",
x + width - combobox->leftButton.width, y, 0, 0, GFUI_MOUSE_UP,
(void*)(object->id), gfuiRightArrow, 0, 0, 0);
x + width - combobox->leftButton.width, y, arrowsWidth, arrowsHeight,
GFUI_MOUSE_UP, (void*)(object->id), gfuiRightArrow, 0, 0, 0);
// Compute total height (text or buttons)
int height = gfuiFont[font]->getHeight();
@ -144,7 +168,7 @@ GfuiComboboxCreate(void *scr, int font, int x, int y, int width,
// Initialize the label child (beware of y if the buttons are higher than the text).
int yl = y;
if (height > gfuiFont[font]->getHeight())
yl += (height - gfuiFont[font]->getHeight()) / 2;
yl += (height - gfuiFont[font]->getHeight()) / 2;
gfuiLabelInit(&combobox->label, pszText, maxlen,
x + combobox->leftButton.width, yl,

View file

@ -60,7 +60,7 @@ gfuiInitLabel(void)
@ingroup gui
@param label The label to initialize
@param text Text to display
@param maxlen Maximum length of the button string (used when the label is changed)
@param maxlen Maximum length of the displayed text (used when the label is changed)
<br>0 for the text length.
@param x Position of the label on the screen (pixels)
@param y Position of the label on the screen (pixels)

View file

@ -695,16 +695,19 @@ GfuiMenuCreateComboboxControl(void* hscr, void* hparm, const char* pszName,
int id = -1;
const int x = (int)GfParmGetNum(hparm,strControlPath.c_str(),GFMNU_ATTR_X,NULL,0.0);
const int y = (int)GfParmGetNum(hparm,strControlPath.c_str(),GFMNU_ATTR_Y,NULL,0.0);
const int x = (int)GfParmGetNum(hparm,strControlPath.c_str(), GFMNU_ATTR_X, NULL, 0.0);
const int y = (int)GfParmGetNum(hparm,strControlPath.c_str(), GFMNU_ATTR_Y, NULL, 0.0);
std::string strFontName = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_FONT, "");
const int font = gfuiMenuGetFontId(strFontName.c_str());
int width = (int)GfParmGetNum(hparm,strControlPath.c_str(), GFMNU_ATTR_WIDTH,NULL,0.0);
int width = (int)GfParmGetNum(hparm,strControlPath.c_str(), GFMNU_ATTR_WIDTH, NULL, 0.0);
if (width == 0)
width = 200;
const int nArrowsWidth = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_ARROWS_WIDTH, NULL, 0);
const int nArrowsHeight = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_ARROWS_HEIGHT, NULL, 0);
const char* pszText = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_TEXT, "");
const int maxlen = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_MAX_LEN, 0, 0);
@ -737,7 +740,8 @@ GfuiMenuCreateComboboxControl(void* hscr, void* hparm, const char* pszName,
if (focusColor.alpha)
aFocusColor = focusColor.toFloatRGBA();
id = GfuiComboboxCreate(hscr, font, x, y, width, pszText, maxlen, aColor, aFocusColor,
id = GfuiComboboxCreate(hscr, font, x, y, width, nArrowsWidth, nArrowsHeight,
pszText, maxlen, aColor, aFocusColor,
userData, onChange, userDataOnFocus, onFocus, onFocusLost);
return id;

View file

@ -91,6 +91,9 @@ extern bool gfuiMenuGetBoolean(const char* pszValue, bool bDefault = false);
#define GFMNU_ATTR_IMAGE_WIDTH "image width"
#define GFMNU_ATTR_IMAGE_HEIGHT "image height"
#define GFMNU_ATTR_ARROWS_WIDTH "arrows width"
#define GFMNU_ATTR_ARROWS_HEIGHT "arrows height"
#define GFMNU_ATTR_SCROLLBAR_POS "scrollbar pos"
#define GFMNU_ATTR_SCROLLBAR_WIDTH "scrollbar width"
#define GFMNU_ATTR_SCROLLBAR_BUTTONS_HEIGHT "scrollbar buttons height"

View file

@ -463,6 +463,7 @@ TGFCLIENT_API void GfuiProgressbarSetValue(void* scr, int id, float value);
/* Combo Boxes */
TGFCLIENT_API int GfuiComboboxCreate(void* scr, int font, int x, int y, int width,
int arrowsWidth, int arrowsHeight,
const char* pszText, int maxlen,
const float* fgColor, const float* fgFocusColor,
void* userData, tfuiComboboxCallback onChange,