Fixed ComboBox enable/disable support + Button disabled state
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@2614 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 874a6d4af5f0c12c01be6c21f81f3b33c70efd12 Former-commit-id: 5e05d2b682cad5ed862516477f38bcf196e35094
This commit is contained in:
parent
38c0ed6634
commit
1154b49798
3 changed files with 40 additions and 27 deletions
|
@ -62,12 +62,12 @@ Color GetColor(const float* color);
|
|||
typedef struct
|
||||
{
|
||||
char *text; /* text */
|
||||
Color bgColor; /* RGBA */
|
||||
Color fgColor;
|
||||
Color bgColor; /* RGBA */
|
||||
Color fgColor;
|
||||
GfuiFontClass *font; /* ttf font */
|
||||
int x, y; /* label position */
|
||||
int align;
|
||||
int maxlen;
|
||||
int x, y; /* label position */
|
||||
int align;
|
||||
int maxlen;
|
||||
} tGfuiLabel;
|
||||
|
||||
/* button state */
|
||||
|
@ -195,11 +195,12 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
int labelId;
|
||||
int leftButtonId, rightButtonId;
|
||||
void *scr;
|
||||
tComboBoxInfo *pInfo;
|
||||
|
||||
Color fgColor[3];
|
||||
int comboType;
|
||||
Color fgColor[3];
|
||||
int comboType;
|
||||
tfuiComboboxCallback onChange;
|
||||
} tGfuiCombobox;
|
||||
|
||||
|
@ -209,7 +210,7 @@ typedef struct
|
|||
void *scr;
|
||||
tCheckBoxInfo *pInfo;
|
||||
|
||||
Color fgColor[3];
|
||||
Color fgColor[3];
|
||||
int checkId;
|
||||
int uncheckId;
|
||||
|
||||
|
|
|
@ -166,25 +166,27 @@ GfuiComboboxCreate(void *scr, int font, int x, int y, int width,
|
|||
break;
|
||||
}
|
||||
|
||||
//Create text
|
||||
// Create label control.
|
||||
int xm = object->xmin + (object->xmax-object->xmin)/2;
|
||||
int ym = object->ymin + (object->ymax-object->ymin)/2;
|
||||
int xmax = object->xmax;
|
||||
int xmin = object->xmin;
|
||||
|
||||
combobox->labelId = GfuiLabelCreate(scr, pszText, font, xm, ym, GFUI_ALIGN_HC_VC, 99);
|
||||
|
||||
GfuiGrButtonCreate(scr, "data/img/arrow-left.png", "data/img/arrow-left.png",
|
||||
"data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
|
||||
xmin, ym, GFUI_ALIGN_HL_VC, GFUI_MOUSE_UP,
|
||||
(void*)(object->id), gfuiLeftArrow,
|
||||
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
|
||||
// Create the left arrow button control.
|
||||
combobox->leftButtonId =
|
||||
GfuiGrButtonCreate(scr, "data/img/arrow-left-disabled.png", "data/img/arrow-left.png",
|
||||
"data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
|
||||
object->xmin, ym, GFUI_ALIGN_HL_VC, GFUI_MOUSE_UP,
|
||||
(void*)(object->id), gfuiLeftArrow,
|
||||
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
|
||||
|
||||
GfuiGrButtonCreate(scr, "data/img/arrow-right.png", "data/img/arrow-right.png",
|
||||
"data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
|
||||
xmax,ym, GFUI_ALIGN_HR_VC, GFUI_MOUSE_UP,
|
||||
(void*)(object->id), gfuiRightArrow,
|
||||
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
|
||||
// Create the right arrow button control.
|
||||
combobox->rightButtonId =
|
||||
GfuiGrButtonCreate(scr, "data/img/arrow-right-disabled.png", "data/img/arrow-right.png",
|
||||
"data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
|
||||
object->xmax, ym, GFUI_ALIGN_HR_VC, GFUI_MOUSE_UP,
|
||||
(void*)(object->id), gfuiRightArrow,
|
||||
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
|
||||
|
||||
gfuiAddObject(screen, object);
|
||||
|
||||
|
|
|
@ -483,14 +483,24 @@ GfuiEnable(void *scr, int id, int flag)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (curObject->widget == GFUI_BUTTON)
|
||||
switch (curObject->widget)
|
||||
{
|
||||
if (curObject->state == GFUI_DISABLE)
|
||||
curObject->u.button.state = GFUI_BTN_RELEASED;
|
||||
else
|
||||
curObject->u.button.state = GFUI_BTN_RELEASED;
|
||||
}
|
||||
case GFUI_BUTTON:
|
||||
if (curObject->state == GFUI_DISABLE)
|
||||
curObject->u.button.state = GFUI_BTN_DISABLE;
|
||||
else
|
||||
curObject->u.button.state = GFUI_BTN_RELEASED;
|
||||
break;
|
||||
|
||||
case GFUI_COMBOBOX:
|
||||
GfuiEnable(scr, curObject->u.combobox.leftButtonId, flag);
|
||||
GfuiEnable(scr, curObject->u.combobox.rightButtonId, flag);
|
||||
GfuiEnable(scr, curObject->u.combobox.labelId, flag);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue