[Change] Refactoring some more opengl mess in toolkit.c. Rectangles this time..

This commit is contained in:
Allanis 2013-03-06 12:46:17 +00:00
parent dec372e06c
commit 961875a799

View File

@ -89,8 +89,11 @@ static void window_render(Window* w);
static void toolkit_renderButton(Widget* btn, double bx, double by);
static void toolkit_renderText(Widget* txt, double bx, double by);
static void toolkit_renderImage(Widget* img, double bx, double by);
static void toolkit_renderList(Widget* lst, double bx, double by);
static void toolkit_drawOutline(double x, double y, double w,
double h, double b, glColour* c, glColour* lc);
static void toolkit_drawRect(double x, double y, double w, double h,
glColour* c, glColour* lc);
// Add a button that when pressed will trigger call, passing it's name as the
// only parameter.
@ -374,6 +377,21 @@ static void toolkit_drawOutline(double x, double y, double w, double h,
glEnd();
}
static void toolkit_drawRect(double x, double y, double w, double h,
glColour* c, glColour* lc) {
glShadeModel((lc) ? GL_SMOOTH : GL_FLAT);
glBegin(GL_QUADS);
COLOUR(*c);
glVertex2d(x, y);
glVertex2d(x+w, y);
COLOUR((lc) ? *lc : *c);
glVertex2d(x+w, y+h);
glVertex2d(x, y+h);
glEnd();
}
// Render a window.
static void window_render(Window* w) {
int i;
@ -392,25 +410,8 @@ static void window_render(Window* w) {
// Window shaded background.
// Main body.
glShadeModel(GL_SMOOTH);
glBegin(GL_QUADS);
COLOUR(*dc);
glVertex2d(x+21., y);
glVertex2d(x+w->w-21., y);
COLOUR(*c);
glVertex2d(x+w->w-21, y+0.6*w->h);
glVertex2d(x+21, y+0.6*w->h);
glEnd();
glShadeModel(GL_FLAT);
glBegin(GL_QUADS);
COLOUR(*c);
glVertex2d(x+21., y+0.6*w->h);
glVertex2d(x+w->w-21., y+0.6*w->h);
glVertex2d(x+w->w-21., y+w->h);
glVertex2d(x+21., y+w->h);
glEnd();
toolkit_drawRect(x+21, y, w->w-42., 0.6*w->h, dc, c);
toolkit_drawRect(x+21, y+0.6*w->h, w->w-42., 0.4*w->h, c, NULL);
glShadeModel(GL_SMOOTH);
// Left side.
@ -559,7 +560,7 @@ static void window_render(Window* w) {
toolkit_renderImage(&w->widgets[i], x, y);
break;
case WIDGET_LIST:
// TODO widget list rendering.
toolkit_renderList(&w->widgets[i], x, y);
break;
}
}
@ -606,25 +607,9 @@ static void toolkit_renderButton(Widget* btn, double bx, double by) {
break;
}
// Shaded base.
glShadeModel(GL_SMOOTH);
glBegin(GL_QUADS);
COLOUR(*dc);
glVertex2d(x, y+2/3*btn->h);
glVertex2d(x+btn->w, y+2/3*btn->h);
COLOUR(*c);
glVertex2d(x+btn->w, y+0.6*btn->h);
glVertex2d(x, y+0.6*btn->h);
glEnd();
glShadeModel(GL_FLAT);
glBegin(GL_QUADS);
COLOUR(*c);
glVertex2d(x, y+0.6*btn->h);
glVertex2d(x+btn->w, y+0.6*btn->h);
glVertex2d(x+btn->w, y+btn->h);
glVertex2d(x, y+btn->h);
glEnd();
// Shaded base.
toolkit_drawRect(x, y, btn->w, 0.6*btn->h, dc, c);
toolkit_drawRect(x, y+0.6*btn->h, btn->w, 0.4*btn->h, c, NULL);
// Inner outline.
toolkit_drawOutline(x, y, btn->w, btn->h, 0., lc, c);
@ -677,6 +662,14 @@ static void toolkit_renderImage(Widget* img, double bx, double by) {
img->dat.img.image->sh-1, 2., oc, NULL);
}
// Render the list.
static void toolkit_renderList(Widget* lst, double bx, double by) {
double x, y;
x = bx + lst->x;
y = by + lst->y;
}
// Render the window.
void toolkit_render(void) {
int i;