Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-10-19 13:45:07 +0000
committerStijn Buys <ingar@osirion.org>2008-10-19 13:45:07 +0000
commit56cdfd3822d2800abdd2f912ab7f76a5764793a7 (patch)
tree2656c7ef694117e0554ae4a47bb09629c78ed8af /src/ui/paint.cc
parente6f1fad441a7737549f463ebac1c9de062b5173d (diff)
scrollpane widget, updated chatbox
Diffstat (limited to 'src/ui/paint.cc')
-rw-r--r--src/ui/paint.cc77
1 files changed, 37 insertions, 40 deletions
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);
+}
+
}
}