bug fix for improper button drawing on low end graphic cards
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@1741 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: b888cc81392c6a6d2f57d572cc770a42e6e7c83a Former-commit-id: 6d71edc3d71bfebb006a32c6c7e522528e903ffa
This commit is contained in:
parent
37b6c7f74a
commit
8bad7baa1c
3 changed files with 137 additions and 15 deletions
|
@ -41,6 +41,106 @@ gfuiButtonInit(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
GfuiGrButtonCreateEx(void *scr, const char *disabled, const char *enabled, const char *focused, const char *pushed,
|
||||||
|
int x, int y, int imageWidth,int imageHeight,int align, int mouse,
|
||||||
|
void *userDataOnPush, tfuiCallback onPush,
|
||||||
|
void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
|
||||||
|
{
|
||||||
|
tGfuiGrButton *button;
|
||||||
|
tGfuiObject *object;
|
||||||
|
tGfuiScreen *screen = (tGfuiScreen*)scr;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
object = (tGfuiObject*)calloc(1, sizeof(tGfuiObject));
|
||||||
|
object->widget = GFUI_GRBUTTON;
|
||||||
|
object->focusMode = GFUI_FOCUS_MOUSE_MOVE;
|
||||||
|
object->id = screen->curId++;
|
||||||
|
object->visible = 1;
|
||||||
|
|
||||||
|
button = &(object->u.grbutton);
|
||||||
|
button->state = GFUI_BTN_RELEASED;
|
||||||
|
button->userDataOnPush = userDataOnPush;
|
||||||
|
button->onPush = onPush;
|
||||||
|
button->userDataOnFocus = userDataOnFocus;
|
||||||
|
button->onFocus = onFocus;
|
||||||
|
button->onFocusLost = onFocusLost;
|
||||||
|
button->mouseBehaviour = mouse;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
button->disabled = GfImgReadTex(disabled, w, h);
|
||||||
|
button->enabled = GfImgReadTex(enabled, w, h);
|
||||||
|
button->focused = GfImgReadTex(focused, w, h);
|
||||||
|
button->pushed = GfImgReadTex(pushed, w, h);
|
||||||
|
|
||||||
|
switch (align) {
|
||||||
|
case GFUI_ALIGN_HR_VB:
|
||||||
|
object->xmin = x - imageWidth;
|
||||||
|
object->xmax = x;
|
||||||
|
object->ymin = y;
|
||||||
|
object->ymax = y + imageHeight;
|
||||||
|
break;
|
||||||
|
case GFUI_ALIGN_HR_VC:
|
||||||
|
object->xmin = x - imageWidth;
|
||||||
|
object->xmax = x;
|
||||||
|
object->ymin = y - imageHeight / 2;
|
||||||
|
object->ymax = y + imageHeight / 2;
|
||||||
|
break;
|
||||||
|
case GFUI_ALIGN_HR_VT:
|
||||||
|
object->xmin = x - imageWidth;
|
||||||
|
object->xmax = x;
|
||||||
|
object->ymin = y - imageHeight;
|
||||||
|
object->ymax = y;
|
||||||
|
break;
|
||||||
|
case GFUI_ALIGN_HC_VB:
|
||||||
|
object->xmin = x - imageWidth / 2;
|
||||||
|
object->xmax = x + imageWidth / 2;
|
||||||
|
object->ymin = y;
|
||||||
|
object->ymax = y + imageHeight;
|
||||||
|
break;
|
||||||
|
case GFUI_ALIGN_HC_VC:
|
||||||
|
object->xmin = x - imageWidth / 2;
|
||||||
|
object->xmax = x + imageWidth / 2;
|
||||||
|
object->ymin = y - imageHeight / 2;
|
||||||
|
object->ymax = y + imageHeight / 2;
|
||||||
|
break;
|
||||||
|
case GFUI_ALIGN_HC_VT:
|
||||||
|
object->xmin = x - imageWidth / 2;
|
||||||
|
object->xmax = x + imageWidth / 2;
|
||||||
|
object->ymin = y - imageHeight;
|
||||||
|
object->ymax = y;
|
||||||
|
break;
|
||||||
|
case GFUI_ALIGN_HL_VB:
|
||||||
|
object->xmin = x;
|
||||||
|
object->xmax = x + imageWidth;
|
||||||
|
object->ymin = y;
|
||||||
|
object->ymax = y + imageHeight;
|
||||||
|
break;
|
||||||
|
case GFUI_ALIGN_HL_VC:
|
||||||
|
object->xmin = x;
|
||||||
|
object->xmax = x + imageWidth;
|
||||||
|
object->ymin = y - imageHeight / 2;
|
||||||
|
object->ymax = y + imageHeight / 2;
|
||||||
|
break;
|
||||||
|
case GFUI_ALIGN_HL_VT:
|
||||||
|
object->xmin = x;
|
||||||
|
object->xmax = x + imageWidth;
|
||||||
|
object->ymin = y - imageHeight;
|
||||||
|
object->ymax = y;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
button->width = imageWidth;
|
||||||
|
button->height = imageHeight;
|
||||||
|
|
||||||
|
gfuiAddObject(screen, object);
|
||||||
|
return object->id;
|
||||||
|
}
|
||||||
|
|
||||||
/** Add a graphical button to a screen.
|
/** Add a graphical button to a screen.
|
||||||
@ingroup gui
|
@ingroup gui
|
||||||
@param scr Screen
|
@param scr Screen
|
||||||
|
|
|
@ -547,29 +547,47 @@ CreateImageButtonControl(void *menuHandle,void *param,const char *pControlName,v
|
||||||
onFocusLost = remInfo;
|
onFocusLost = remInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* pszDisabledImage = GfParmGetStr(param, pControlName, "disabledimage", "");
|
std::string strEnabledImage,strDisabledImage,strFocusedImage,strPushedImage;
|
||||||
const char* pszEnabledImage = GfParmGetStr(param, pControlName, "enabledimage", "");
|
|
||||||
const char* pszFocusedImage = GfParmGetStr(param, pControlName, "focusedimage", "");
|
strDisabledImage = GfParmGetStr(param, pControlName, "disabledimage", "");
|
||||||
const char* pszPushedImage = GfParmGetStr(param, pControlName, "pushedimage", "");
|
strEnabledImage = GfParmGetStr(param, pControlName, "enabledimage", "");
|
||||||
|
strFocusedImage = GfParmGetStr(param, pControlName, "focusedimage", "");
|
||||||
|
strPushedImage = GfParmGetStr(param, pControlName, "pushedimage", "");
|
||||||
|
|
||||||
const int x = (int)GfParmGetNum(param,pControlName,"x",NULL,0.0);
|
const int x = (int)GfParmGetNum(param,pControlName,"x",NULL,0.0);
|
||||||
const int y = (int)GfParmGetNum(param,pControlName,"y",NULL,0.0);
|
const int y = (int)GfParmGetNum(param,pControlName,"y",NULL,0.0);
|
||||||
//const int w = (int)GfParmGetNum(param,pControlName,"width",NULL,0.0);
|
const int w = (int)GfParmGetNum(param,pControlName,"width",NULL,0.0);
|
||||||
//const int h = (int)GfParmGetNum(param,pControlName,"height",NULL,0.0);
|
const int h = (int)GfParmGetNum(param,pControlName,"height",NULL,0.0);
|
||||||
|
|
||||||
const char* pszAlignH = GfParmGetStr(param, pControlName, "alignH", "");
|
const char* pszAlignH = GfParmGetStr(param, pControlName, "alignH", "");
|
||||||
const char* pszAlignV = GfParmGetStr(param, pControlName, "alignV", "");
|
const char* pszAlignV = GfParmGetStr(param, pControlName, "alignV", "");
|
||||||
const int alignment = GetAlignment(pszAlignH,pszAlignV);
|
const int alignment = GetAlignment(pszAlignH,pszAlignV);
|
||||||
|
int id = -1;
|
||||||
|
|
||||||
return GfuiGrButtonCreate(menuHandle,
|
if ((w ==0)&&(h==0))
|
||||||
pszDisabledImage,pszEnabledImage,
|
{
|
||||||
pszFocusedImage,pszPushedImage,
|
id = GfuiGrButtonCreate(menuHandle,
|
||||||
x,y,alignment,GFUI_MOUSE_UP,
|
strDisabledImage.c_str(),strEnabledImage.c_str(),strFocusedImage.c_str(),strPushedImage.c_str(),
|
||||||
userdata,
|
x,y,alignment,GFUI_MOUSE_UP
|
||||||
|
,userdata,
|
||||||
onpush,
|
onpush,
|
||||||
userDataOnFocus,
|
userDataOnFocus,
|
||||||
onFocus,
|
onFocus,
|
||||||
onFocusLost);
|
onFocusLost);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id = GfuiGrButtonCreateEx(menuHandle,
|
||||||
|
strDisabledImage.c_str(),strEnabledImage.c_str(),strFocusedImage.c_str(),strPushedImage.c_str(),
|
||||||
|
x,y,w,h,alignment,GFUI_MOUSE_UP
|
||||||
|
,userdata,
|
||||||
|
onpush,
|
||||||
|
userDataOnFocus,
|
||||||
|
onFocus,
|
||||||
|
onFocusLost);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -207,6 +207,10 @@ extern int GfuiGrButtonCreate(void *scr, const char *disabled, const char *enabl
|
||||||
int x, int y, int align, int mouse,
|
int x, int y, int align, int mouse,
|
||||||
void *userDataOnPush, tfuiCallback onPush,
|
void *userDataOnPush, tfuiCallback onPush,
|
||||||
void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost);
|
void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost);
|
||||||
|
extern int GfuiGrButtonCreateEx(void *scr, const char *disabled, const char *enabled, const char *focused, const char *pushed,
|
||||||
|
int x, int y, int imageWidth,int imageHeight,int align, int mouse,
|
||||||
|
void *userDataOnPush, tfuiCallback onPush,
|
||||||
|
void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost);
|
||||||
|
|
||||||
extern void GfuiButtonSetText(void *scr, int id, const char *text);
|
extern void GfuiButtonSetText(void *scr, int id, const char *text);
|
||||||
extern int GfuiButtonGetFocused(void);
|
extern int GfuiButtonGetFocused(void);
|
||||||
|
|
Loading…
Reference in a new issue