static int active;
static int radius;
static TTF_Font *font[3] = { NULL, NULL, NULL };
-static int scale[3] = { 1, 1, 1 };
static GLuint digit_text[3][11];
static GLuint digit_list[3][11];
int s0 = s / 26;
int s1 = s / 13;
int s2 = s / 7;
- int m;
-
- /* Make sure text size doesn't exceed the maximum texture size. */
-
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m);
-
- scale[0] = 1;
- scale[1] = 1;
- scale[2] = 1;
-
- while (s0 > m) { s0 /= 2; scale[0] *= 2; }
- while (s1 > m) { s1 /= 2; scale[1] *= 2; }
- while (s2 > m) { s2 /= 2; scale[2] *= 2; }
memset(widget, 0, sizeof (struct widget) * MAXWIDGET);
digit_text[i][j] = make_image_from_font(NULL, NULL,
&digit_w[i][j],
&digit_h[i][j],
- text, font[i], scale[i]);
+ text, font[i]);
digit_list[i][j] = gui_list(-digit_w[i][j] / 2,
-digit_h[i][j] / 2,
+digit_w[i][j],
digit_text[i][j] = make_image_from_font(NULL, NULL,
&digit_w[i][10],
&digit_h[i][10],
- ":", font[i], scale[i]);
+ ":", font[i]);
digit_list[i][j] = gui_list(-digit_w[i][10] / 2,
-digit_h[i][10] / 2,
+digit_w[i][10],
if (glIsTexture(widget[id].text_img))
glDeleteTextures(1, &widget[id].text_img);
- widget[id].text_img = make_image_from_file(NULL, NULL, NULL, NULL, file);
+ widget[id].text_img = make_image_from_file(file);
}
void gui_set_label(int id, const char *text)
glDeleteLists(widget[id].text_obj, 1);
widget[id].text_img = make_image_from_font(NULL, NULL, &w, &h,
- text, font[widget[id].size],
- scale[widget[id].size]);
+ text, font[widget[id].size]);
widget[id].text_obj = gui_list(-w / 2, -h / 2, w, h,
widget[id].color0, widget[id].color1);
}
if ((id = gui_widget(pd, GUI_IMAGE)))
{
- widget[id].text_img = make_image_from_file(NULL, NULL,
- NULL, NULL, file);
- widget[id].w = w;
- widget[id].h = h;
+ widget[id].text_img = make_image_from_file(file);
+ widget[id].w = w;
+ widget[id].h = h;
}
return id;
}
widget[id].text_img = make_image_from_font(NULL, NULL,
&widget[id].w,
&widget[id].h,
- text, font[size],
- scale[size]);
+ text, font[size]);
widget[id].size = size;
widget[id].token = token;
widget[id].value = value;
widget[id].text_img = make_image_from_font(NULL, NULL,
&widget[id].w,
&widget[id].h,
- text, font[size],
- scale[size]);
+ text, font[size]);
widget[id].size = size;
widget[id].color0 = c0 ? c0 : gui_yel;
widget[id].color1 = c1 ? c1 : gui_red;
if (widget[id].w < widget[id].h && widget[id].w > 0)
widget[id].w = widget[id].h;
-
/* Padded text elements look a little nicer. */
if (widget[id].w < config_get_d(CONFIG_WIDTH))
widget[id].w += radius;
if (widget[id].h < config_get_d(CONFIG_HEIGHT))
widget[id].h += radius;
+
+ /* A button should be at least wide enough to accomodate the rounding. */
+
+ if (widget[id].w < 2 * radius)
+ widget[id].w = 2 * radius;
+ if (widget[id].h < 2 * radius)
+ widget[id].h = 2 * radius;
}
static void gui_widget_up(int id)
{
if (id)
{
- glPushAttrib(GL_LIGHTING_BIT |
- GL_COLOR_BUFFER_BIT |
- GL_DEPTH_BUFFER_BIT);
config_push_ortho();
{
- glEnable(GL_BLEND);
glEnable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glPushAttrib(GL_TEXTURE_BIT);
{
glDisable(GL_TEXTURE_2D);
gui_paint_rect(id, 0);
- }
- glPopAttrib();
- gui_paint_text(id);
+ glEnable(GL_TEXTURE_2D);
+ gui_paint_text(id);
+
+ glColor4fv(gui_wht);
+ }
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ glDisable(GL_COLOR_MATERIAL);
}
config_pop_matrix();
- glPopAttrib();
}
}