From f1fe10462c53e1ee86c8e40b0d19ad816abeb745 Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 21 Sep 2007 17:53:53 +0000 Subject: [PATCH] stretch-overflow biw works with rotation and alignment. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@733 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/field/text.cpp | 2 +- src/data/field/text.hpp | 7 ++++++- src/render/text/viewer.cpp | 3 +++ src/util/alignment.cpp | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/data/field/text.cpp b/src/data/field/text.cpp index abc90c8e..7b0388a8 100644 --- a/src/data/field/text.cpp +++ b/src/data/field/text.cpp @@ -61,7 +61,7 @@ TextStyle::TextStyle(const TextFieldP& field) double TextStyle::getStretch() const { if (content_width > 0 && ((alignment() & ALIGN_STRETCH) || (alignment() & ALIGN_STRETCH_OVERFLOW))) { - double factor = (width - padding_left - padding_right) / content_width; + double factor = (sideways(angle) ? height : width - padding_left - padding_right) / content_width; if (alignment() == ALIGN_STRETCH || factor < 1.0) { return factor; } diff --git a/src/data/field/text.hpp b/src/data/field/text.hpp index c7ed4559..0c4d3f98 100644 --- a/src/data/field/text.hpp +++ b/src/data/field/text.hpp @@ -82,7 +82,12 @@ class TextStyle : public Style { /// The rotation to use when drawing inline Rotation getRotation() const { - return Rotation(angle, getRect(), 1.0, getStretch()); + double stretch = getStretch(); + if (sideways(angle)) { + return Rotation(angle, getRect(), stretch, 1/stretch); + } else { + return Rotation(angle, getRect(), 1.0, stretch); + } } /// The rotation to use when determining content layout, does not include the stretch factor inline Rotation getRotationNoStretch() const { diff --git a/src/render/text/viewer.cpp b/src/render/text/viewer.cpp index e1ba122a..536984cd 100644 --- a/src/render/text/viewer.cpp +++ b/src/render/text/viewer.cpp @@ -753,6 +753,9 @@ void TextViewer::alignParagraph(size_t start_line, size_t end_line, const vector c += s.x + hdelta * i / count; if (j < l.end_or_soft && chars[j++].break_after == BREAK_SPACE) i++; } + } else if (style.alignment & ALIGN_STRETCH_OVERFLOW && width >= s.width) { + // stretching, don't center or align right + justifying = false; } else { // simple alignment justifying = false; diff --git a/src/util/alignment.cpp b/src/util/alignment.cpp index ce148037..e2f4ac2f 100644 --- a/src/util/alignment.cpp +++ b/src/util/alignment.cpp @@ -44,10 +44,10 @@ Alignment from_string(const String& s) { if (s.find(_("justify-overflow")) !=String::npos) al = ALIGN_JUSTIFY_OVERFLOW | (al & ~ALIGN_JUSTIFY_OVERFLOW); if (s.find(_("shrink-overflow")) !=String::npos) al = ALIGN_STRETCH_OVERFLOW | (al & ~ALIGN_STRETCH_OVERFLOW); // compatability if (s.find(_("stretch-overflow")) !=String::npos) al = ALIGN_STRETCH_OVERFLOW | (al & ~ALIGN_STRETCH_OVERFLOW); + else if (s.find(_("stretch")) !=String::npos) al = ALIGN_STRETCH; if (s.find(_("top")) !=String::npos) al = ALIGN_TOP | (al & ~ALIGN_VERTICAL); if (s.find(_("middle")) !=String::npos) al = ALIGN_MIDDLE | (al & ~ALIGN_VERTICAL); if (s.find(_("bottom")) !=String::npos) al = ALIGN_BOTTOM | (al & ~ALIGN_VERTICAL); - if (s.find(_("stretch")) !=String::npos) al = ALIGN_STRETCH; return static_cast(al); }