forked from speed-dreams/speed-dreams-code
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
|
typedef struct
|
||||||
{
|
{
|
||||||
char *text; /* text */
|
char *text; /* text */
|
||||||
Color bgColor; /* RGBA */
|
Color bgColor; /* RGBA */
|
||||||
Color fgColor;
|
Color fgColor;
|
||||||
GfuiFontClass *font; /* ttf font */
|
GfuiFontClass *font; /* ttf font */
|
||||||
int x, y; /* label position */
|
int x, y; /* label position */
|
||||||
int align;
|
int align;
|
||||||
int maxlen;
|
int maxlen;
|
||||||
} tGfuiLabel;
|
} tGfuiLabel;
|
||||||
|
|
||||||
/* button state */
|
/* button state */
|
||||||
|
@ -195,11 +195,12 @@ typedef struct
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int labelId;
|
int labelId;
|
||||||
|
int leftButtonId, rightButtonId;
|
||||||
void *scr;
|
void *scr;
|
||||||
tComboBoxInfo *pInfo;
|
tComboBoxInfo *pInfo;
|
||||||
|
|
||||||
Color fgColor[3];
|
Color fgColor[3];
|
||||||
int comboType;
|
int comboType;
|
||||||
tfuiComboboxCallback onChange;
|
tfuiComboboxCallback onChange;
|
||||||
} tGfuiCombobox;
|
} tGfuiCombobox;
|
||||||
|
|
||||||
|
@ -209,7 +210,7 @@ typedef struct
|
||||||
void *scr;
|
void *scr;
|
||||||
tCheckBoxInfo *pInfo;
|
tCheckBoxInfo *pInfo;
|
||||||
|
|
||||||
Color fgColor[3];
|
Color fgColor[3];
|
||||||
int checkId;
|
int checkId;
|
||||||
int uncheckId;
|
int uncheckId;
|
||||||
|
|
||||||
|
|
|
@ -166,25 +166,27 @@ GfuiComboboxCreate(void *scr, int font, int x, int y, int width,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create text
|
// Create label control.
|
||||||
int xm = object->xmin + (object->xmax-object->xmin)/2;
|
int xm = object->xmin + (object->xmax-object->xmin)/2;
|
||||||
int ym = object->ymin + (object->ymax-object->ymin)/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);
|
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",
|
// Create the left arrow button control.
|
||||||
"data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
|
combobox->leftButtonId =
|
||||||
xmin, ym, GFUI_ALIGN_HL_VC, GFUI_MOUSE_UP,
|
GfuiGrButtonCreate(scr, "data/img/arrow-left-disabled.png", "data/img/arrow-left.png",
|
||||||
(void*)(object->id), gfuiLeftArrow,
|
"data/img/arrow-left.png", "data/img/arrow-left-pushed.png",
|
||||||
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
|
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",
|
// Create the right arrow button control.
|
||||||
"data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
|
combobox->rightButtonId =
|
||||||
xmax,ym, GFUI_ALIGN_HR_VC, GFUI_MOUSE_UP,
|
GfuiGrButtonCreate(scr, "data/img/arrow-right-disabled.png", "data/img/arrow-right.png",
|
||||||
(void*)(object->id), gfuiRightArrow,
|
"data/img/arrow-right.png", "data/img/arrow-right-pushed.png",
|
||||||
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
|
object->xmax, ym, GFUI_ALIGN_HR_VC, GFUI_MOUSE_UP,
|
||||||
|
(void*)(object->id), gfuiRightArrow,
|
||||||
|
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
|
||||||
|
|
||||||
gfuiAddObject(screen, object);
|
gfuiAddObject(screen, object);
|
||||||
|
|
||||||
|
|
|
@ -483,14 +483,24 @@ GfuiEnable(void *scr, int id, int flag)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curObject->widget == GFUI_BUTTON)
|
switch (curObject->widget)
|
||||||
{
|
{
|
||||||
if (curObject->state == GFUI_DISABLE)
|
case GFUI_BUTTON:
|
||||||
curObject->u.button.state = GFUI_BTN_RELEASED;
|
if (curObject->state == GFUI_DISABLE)
|
||||||
else
|
curObject->u.button.state = GFUI_BTN_DISABLE;
|
||||||
curObject->u.button.state = GFUI_BTN_RELEASED;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue