Add container background texture
parent
3009f08a76
commit
971d432963
|
@ -11,7 +11,25 @@ Container::~Container()
|
|||
|
||||
void Container::OnPaint() const
|
||||
{
|
||||
if (this->colour.a) {
|
||||
if (this->back) {
|
||||
float tw = (float)w / tex->w[TEX_BACK];
|
||||
float th = (float)h / tex->h[TEX_BACK];
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, tex->tex[TEX_BACK]);
|
||||
glBegin(GL_QUADS);
|
||||
glColor4f(colour.r, colour.g, colour.b, colour.a);
|
||||
glTexCoord2f(.0, .0);
|
||||
glVertex2f( x, y);
|
||||
glTexCoord2f(.0, th);
|
||||
glVertex2f( x, h + y);
|
||||
glTexCoord2f(tw, th);
|
||||
glVertex2f(w + x, h + y);
|
||||
glTexCoord2f(tw, .0);
|
||||
glVertex2f(w + x, y);
|
||||
glEnd();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
} else if (this->colour.a) {
|
||||
glBegin(GL_QUADS);
|
||||
glColor4f(colour.r, colour.g, colour.b, colour.a);
|
||||
glVertex2f( x, y);
|
||||
|
@ -20,16 +38,15 @@ void Container::OnPaint() const
|
|||
glVertex2f(w + x, y);
|
||||
glEnd();
|
||||
}
|
||||
/*
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glColor3f(0.0, 0.0, 0.0);
|
||||
glVertex2f( x, y);
|
||||
glVertex2f( x, h + y);
|
||||
glVertex2f(w + x, h + y);
|
||||
glVertex2f(w + x, y);
|
||||
// glVertex2f( x, y);
|
||||
glEnd();
|
||||
*/
|
||||
|
||||
/* glBegin(GL_LINE_LOOP);
|
||||
glColor4f(1, 1, 1, 0.25f);
|
||||
glVertex2f( x + .5f, y + .5f);
|
||||
glVertex2f( x + .5f, h + y - .5f);
|
||||
glVertex2f(w + x - .5f, h + y - .5f);
|
||||
glVertex2f(w + x - .5f, y + .5f);
|
||||
glEnd();*/
|
||||
|
||||
std::list<Widget *>::const_iterator it;
|
||||
for (it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->OnPaint();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
struct Container : Widget {
|
||||
std::list<Widget *> children;
|
||||
Colour colour;
|
||||
bool back;
|
||||
|
||||
~Container();
|
||||
|
||||
|
|
Loading…
Reference in New Issue