From 06212c7d8dc20b11f49d54e42f8299740f90a231 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 9 Nov 2008 17:44:24 +0000 Subject: improved client notifications, minor bugfixes --- src/ui/scrollpane.cc | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/ui/scrollpane.cc') diff --git a/src/ui/scrollpane.cc b/src/ui/scrollpane.cc index 69bc159..a1de7d5 100644 --- a/src/ui/scrollpane.cc +++ b/src/ui/scrollpane.cc @@ -16,12 +16,18 @@ namespace ui ScrollPane::ScrollPane(Widget *parent, ui::Text &text) : Widget(parent), scrollpane_text(text) { set_label("scrollpane"); + set_alignment(AlignBottom); } ScrollPane::~ScrollPane() { } +void ScrollPane::set_alignment(const unsigned int alignment) +{ + scrollpane_alignment = alignment; +} + void ScrollPane::set_scroll(int scroll) { scrollpane_scroll = scroll; @@ -157,13 +163,24 @@ void ScrollPane::draw() render::gl::color(palette()->text()); const math ::Vector2f gl(global_location()); - float y = height() - font()->height(); + float y = 0; - for (ui::Text::reverse_iterator rit = lines.rbegin(); (y >= 0) && (rit != lines.rend()); ++rit) { - render::Text::draw(gl.x, gl.y + y, (*rit)); - y -= font()->height(); + if ((alignment() & AlignTop) == AlignTop) { + int i = (int) lines.size(); + for (ui::Text::iterator it = lines.begin(); it != lines.end(); it++) { + if (i <= text_height) { + render::Text::draw(gl.x, gl.y + y, (*it)); + y += font()->height(); + } + i--; + } + } else { + y = height() - font()->height(); + for (ui::Text::reverse_iterator rit = lines.rbegin(); (y >= 0) && (rit != lines.rend()); ++rit) { + render::Text::draw(gl.x, gl.y + y, (*rit)); + y -= font()->height(); + } } - render::gl::disable(GL_TEXTURE_2D); } -- cgit v1.2.3