Further widget updates.
This commit is contained in:
parent
fb16e8e8f0
commit
8a9dcb1ff7
|
@ -490,7 +490,6 @@ struct Widget {
|
||||||
int minValue;
|
int minValue;
|
||||||
int maxValue;
|
int maxValue;
|
||||||
int visible;
|
int visible;
|
||||||
int enabled;
|
|
||||||
int numOptions;
|
int numOptions;
|
||||||
char **options;
|
char **options;
|
||||||
void (*action)(void);
|
void (*action)(void);
|
||||||
|
|
|
@ -106,7 +106,7 @@ static void updateWidgetValue(int dir)
|
||||||
|
|
||||||
void drawWidgets(void)
|
void drawWidgets(void)
|
||||||
{
|
{
|
||||||
int i, j, x;
|
int i, j, x, tw, th, outline;
|
||||||
Widget *w;
|
Widget *w;
|
||||||
|
|
||||||
for (i = 0 ; i < numWidgets ; i++)
|
for (i = 0 ; i < numWidgets ; i++)
|
||||||
|
@ -128,26 +128,32 @@ void drawWidgets(void)
|
||||||
|
|
||||||
drawText(w->x + w->w / 2, w->y + 2, 24, TA_CENTER, colors.white, w->label);
|
drawText(w->x + w->w / 2, w->y + 2, 24, TA_CENTER, colors.white, w->label);
|
||||||
|
|
||||||
|
outline = (w == selectedWidget) ? 255 : 192;
|
||||||
|
|
||||||
switch (w->type)
|
switch (w->type)
|
||||||
{
|
{
|
||||||
case WT_BUTTON:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WT_SLIDER:
|
case WT_SLIDER:
|
||||||
drawRect(w->x + w->w + 25, w->y, 500 * (w->value * 1.0 / w->maxValue), 40, 0, 128, 0, 255);
|
drawRect(w->x + w->w + 25, w->y, 500 * (w->value * 1.0 / w->maxValue), 40, 0, 128, 0, 255);
|
||||||
drawOutlineRect(w->x + w->w + 25, w->y, 500, 40, 0, 255, 0, 255);
|
drawOutlineRect(w->x + w->w + 25, w->y, 500, 40, 0, outline, 0, 255);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WT_SPINNER:
|
case WT_SPINNER:
|
||||||
|
x = w->x + w->w + 25;
|
||||||
for (j = 0 ; j < w->numOptions ; j++)
|
for (j = 0 ; j < w->numOptions ; j++)
|
||||||
{
|
{
|
||||||
x = w->x + w->w + 25 + (125 * j);
|
textSize(w->options[j], 24, &tw, &th);
|
||||||
|
|
||||||
|
tw += 25;
|
||||||
|
|
||||||
if (j == w->value)
|
if (j == w->value)
|
||||||
{
|
{
|
||||||
drawRect(x, w->y, 100, w->h, 0, 128, 0, 255);
|
drawRect(x, w->y, tw, w->h, 0, 128, 0, 255);
|
||||||
drawOutlineRect(x, w->y, 100, w->h, 0, 255, 0, 255);
|
drawOutlineRect(x, w->y, tw, w->h, 0, outline, 0, 255);
|
||||||
}
|
}
|
||||||
drawText(x + 50, w->y + 2, 24, TA_CENTER, colors.white, w->options[j]);
|
|
||||||
|
drawText(x + tw / 2, w->y + 2, 24, TA_CENTER, colors.white, w->options[j]);
|
||||||
|
|
||||||
|
x += tw + 25;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -178,7 +184,7 @@ static void selectWidget(int dir)
|
||||||
|
|
||||||
selectedWidget = &widgets[widgetIndex];
|
selectedWidget = &widgets[widgetIndex];
|
||||||
|
|
||||||
} while (!selectedWidget->enabled && !selectedWidget->visible);
|
} while (!selectedWidget->visible);
|
||||||
|
|
||||||
if (oldWidgetIndex != widgetIndex)
|
if (oldWidgetIndex != widgetIndex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,7 @@ extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int
|
||||||
extern Texture *getTexture(const char *filename);
|
extern Texture *getTexture(const char *filename);
|
||||||
extern Atlas *getImageFromAtlas(char *filename);
|
extern Atlas *getImageFromAtlas(char *filename);
|
||||||
extern void blitRect(SDL_Texture *texture, int x, int y, SDL_Rect *srcRect, int center);
|
extern void blitRect(SDL_Texture *texture, int x, int y, SDL_Rect *srcRect, int center);
|
||||||
|
extern void textSize(const char *text, int size, int *w, int *h);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
Loading…
Reference in New Issue