diff --git a/TextButtonInstance.cpp b/TextButtonInstance.cpp index e9d32ec..de70aff 100644 --- a/TextButtonInstance.cpp +++ b/TextButtonInstance.cpp @@ -45,4 +45,25 @@ TextButtonInstance::TextButtonInstance(void) TextButtonInstance::~TextButtonInstance(void) { +} + +void TextButtonInstance::drawObj(RenderDevice* rd) +{ + Vector3 point1; + Vector3 point2; + if(floatBottom) + { + point1 = Vector3(boxBegin.x, rd->getHeight() + boxBegin.y,0); + point2 = Vector3(boxEnd.x, rd->getHeight() + boxEnd.y,0); + + } + else + { + point1 = Vector3(boxBegin.x, boxBegin.y,0); + point2 = Vector3(boxEnd.x, boxEnd.y,0); + } + Draw::box(Box(point1, point2), rd, boxColor, boxOutlineColor); + Vector2 RelativeTo = Vector2(point1.x + fontLocationRelativeTo.x, point1.y + fontLocationRelativeTo.y); + font->draw2D(rd, title, RelativeTo, textSize, textColor, textOutlineColor); + } \ No newline at end of file diff --git a/TextButtonInstance.h b/TextButtonInstance.h index acdc068..b574872 100644 --- a/TextButtonInstance.h +++ b/TextButtonInstance.h @@ -29,5 +29,6 @@ public: bool floatRight; bool visible; int textSize; - -}; + void drawObj(G3D::RenderDevice*); + +}; \ No newline at end of file diff --git a/main.cpp b/main.cpp index d8329e8..27b982c 100644 --- a/main.cpp +++ b/main.cpp @@ -519,23 +519,7 @@ void drawButtons(RenderDevice* rd) if(instance->className == "TextButton" && instance->parent == dataModel) { TextButtonInstance* tbi = (TextButtonInstance*)instance; - Vector3 point1; - Vector3 point2; - if(tbi->floatBottom) - { - point1 = Vector3(tbi->boxBegin.x, rd->getHeight() + tbi->boxBegin.y,0); - point2 = Vector3(tbi->boxEnd.x, rd->getHeight() + tbi->boxEnd.y,0); - - } - else - { - point1 = Vector3(tbi->boxBegin.x, tbi->boxBegin.y,0); - point2 = Vector3(tbi->boxEnd.x, tbi->boxEnd.y,0); - } - Draw::box(Box(point1, point2), rd, tbi->boxColor, tbi->boxOutlineColor); - Vector2 RelativeTo = Vector2(point1.x + tbi->fontLocationRelativeTo.x, point1.y + tbi->fontLocationRelativeTo.y); - tbi->font->draw2D(rd, tbi->title, RelativeTo, tbi->textSize, tbi->textColor, tbi->textOutlineColor); - + tbi->drawObj(rd); } } } @@ -666,9 +650,9 @@ void Demo::onGraphics(RenderDevice* rd) { glTexCoord2d( 1.0,0.0 ); glVertex2f( 70, 0+offset ); glTexCoord2d( 1.0,1.0 ); - glVertex2f( 70, 65+offset ); + glVertex2f( 70, 60+offset ); glTexCoord2d( 0.0,1.0 ); - glVertex2f( 10, 65+offset ); + glVertex2f( 10, 60+offset ); glEnd(); glDisable( GL_TEXTURE_2D );