From 56cdfd3822d2800abdd2f912ab7f76a5764793a7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 19 Oct 2008 13:45:07 +0000 Subject: scrollpane widget, updated chatbox --- src/ui/paint.cc | 77 +++++++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 40 deletions(-) (limited to 'src/ui/paint.cc') diff --git a/src/ui/paint.cc b/src/ui/paint.cc index d50e3b5..45b7eea 100644 --- a/src/ui/paint.cc +++ b/src/ui/paint.cc @@ -32,7 +32,7 @@ void color_code(const char c) render::Text::setcolor(c); } -void border(math::Vector2f const &location, math::Vector2f const &size) +void border(const math::Vector2f &location, const math::Vector2f &size) { using namespace render::gl; @@ -44,7 +44,7 @@ void border(math::Vector2f const &location, math::Vector2f const &size) end(); } -void rectangle(math::Vector2f const &location, math::Vector2f const &size) +void rectangle(const math::Vector2f &location, const math::Vector2f &size) { using namespace render::gl; @@ -56,9 +56,9 @@ void rectangle(math::Vector2f const &location, math::Vector2f const &size) end(); } -void bitmap(math::Vector2f const &location, math::Vector2f const &size, std::string const &texture) +// draw a bitmap +void bitmap(const math::Vector2f &location, const math::Vector2f &size, std::string const &texture) { - using namespace render::gl; render::Textures::bind("bitmaps/" + texture); @@ -82,41 +82,8 @@ void bitmap(math::Vector2f const &location, math::Vector2f const &size, std::str disable(GL_TEXTURE_2D); } -void text_centered(math::Vector2f const &location, math::Vector2f const &size, std::string const &text, Font const *font) -{ - using namespace render::gl; - - render::Text::setfont(font->name().c_str(), font->width(), font->height()); - enable(GL_TEXTURE_2D); - - math::Vector2f v(location); - - v.x += (size.x - aux::text_strip(text).size() * font->width()) /2.0f; - v.y += (size.y - font->height()) / 2.0f; - - render::Text::draw(v.x, v.y, text); - - disable(GL_TEXTURE_2D); -} - -void text(math::Vector2f const &location, Font const *font, std::stringstream & textstream) -{ - using namespace render::gl; - render::Text::setfont(font->name().c_str(), font->width(), font->height()); - - // enable OpenGL textures - enable(GL_TEXTURE_2D); - - render::Text::draw(location.x, location.y, textstream); - - // disable texturing - disable(GL_TEXTURE_2D); -} - -void text(math::Vector2f const &location, math::Vector2f const &size, - Font const *font, - std::string const &text, - unsigned int align) +// draw aligned text +void label(const math::Vector2f &location, const math::Vector2f &size, const Font *font, const std::string &text, unsigned int align) { unsigned int align_horizontal = (align & 0x000F); if (!align_horizontal) @@ -167,11 +134,41 @@ void text(math::Vector2f const &location, math::Vector2f const &size, render::Text::draw(v.x, v.y, text); - // disable texturing + // disable OpenGL textures disable(GL_TEXTURE_2D); } +// draw unaligned text +void text(const math::Vector2f &location, const math::Vector2f &size, const Font *font, const std::string &text) +{ + using namespace render::gl; + render::Text::setfont(font->name().c_str(), font->width(), font->height()); + + // enable OpenGL textures + enable(GL_TEXTURE_2D); + + render::Text::draw(location.x, location.y, text); + + // disable OpenGL textures + disable(GL_TEXTURE_2D); +} + +// draw unaligned text +void text(const math::Vector2f &location, const math::Vector2f &size, const Font *font, std::stringstream & textstream) +{ + using namespace render::gl; + render::Text::setfont(font->name().c_str(), font->width(), font->height()); + + // enable OpenGL textures + enable(GL_TEXTURE_2D); + + render::Text::draw(location.x, location.y, textstream); + + // disable OpenGL textures + disable(GL_TEXTURE_2D); +} + } } -- cgit v1.2.3