[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2882 - branches/pingus_sdl/src
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r2882 - branches/pingus_sdl/src |
Date: |
Mon, 13 Aug 2007 05:05:39 +0200 |
Author: grumbel
Date: 2007-08-13 05:05:38 +0200 (Mon, 13 Aug 2007)
New Revision: 2882
Modified:
branches/pingus_sdl/src/font.cpp
Log:
- implemented proper right and center align for multiline text
Modified: branches/pingus_sdl/src/font.cpp
===================================================================
--- branches/pingus_sdl/src/font.cpp 2007-08-13 02:45:55 UTC (rev 2881)
+++ branches/pingus_sdl/src/font.cpp 2007-08-13 03:05:38 UTC (rev 2882)
@@ -28,6 +28,7 @@
#include "SDL.h"
#include "SDL_image.h"
#include "font.hpp"
+#include "line_iterator.hpp"
#include "font_description.hpp"
#include "gui/display.hpp"
@@ -167,6 +168,16 @@
void draw(Origin origin, int x, int y, const std::string& text, SDL_Surface*
target)
{
+ // FIXME: only origins top_left, top_right and top_center to work right now
+ LineIterator it(text);
+ while(it.next()) {
+ draw_line(origin, x, y, it.get(), target);
+ y += surface->h;
+ }
+ }
+
+ void draw_line(Origin origin, int x, int y, const std::string& text,
SDL_Surface* target)
+ {
Vector2i offset = calc_origin(origin, get_size(text));
int dstx = x - offset.x;
@@ -180,11 +191,6 @@
{
dstx += space_length;
}
- else if (text[i] == '\n')
- {
- dstx = x - offset.x;
- dsty += surface->h;
- }
else
{
SDL_Rect& srcrect = chrs[static_cast<unsigned char>(text[i])];
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2882 - branches/pingus_sdl/src,
grumbel at BerliOS <=