mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Cleaned up the Alignment type, it is now much more orthogonal.
Changed the behavior of justifying: - by default justify words instead of characters - only justify before soft line breaks, unless "alignment: force justify" is used. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1251 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+29
-19
@@ -40,15 +40,19 @@ Alignment from_string(const String& s) {
|
||||
if (s.find(_("left")) !=String::npos) al = ALIGN_LEFT | (al & ~ALIGN_HORIZONTAL);
|
||||
if (s.find(_("center")) !=String::npos) al = ALIGN_CENTER | (al & ~ALIGN_HORIZONTAL);
|
||||
if (s.find(_("right")) !=String::npos) al = ALIGN_RIGHT | (al & ~ALIGN_HORIZONTAL);
|
||||
if (s.find(_("justify")) !=String::npos) al = ALIGN_JUSTIFY | (al & ~ALIGN_HORIZONTAL);
|
||||
if (s.find(_("justify-words")) !=String::npos) al = ALIGN_JUSTIFY_WORDS | (al & ~ALIGN_HORIZONTAL);
|
||||
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(_("justify")) !=String::npos) al = ALIGN_JUSTIFY_WORDS | (al & ~ALIGN_FILL);
|
||||
if (s.find(_("justify-all")) !=String::npos) al = ALIGN_JUSTIFY_ALL | (al & ~ALIGN_FILL);
|
||||
if (s.find(_("shrink")) !=String::npos) al = ALIGN_STRETCH | (al & ~ALIGN_FILL);
|
||||
if (s.find(_("stretch")) !=String::npos) al = ALIGN_STRETCH | (al & ~ALIGN_FILL); // compatability
|
||||
|
||||
if (s.find(_("overflow")) !=String::npos) al |= ALIGN_IF_OVERFLOW;
|
||||
if (s.find(_("force")) ==String::npos) al |= ALIGN_IF_SOFTBREAK; // force = !if_softbreak
|
||||
|
||||
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);
|
||||
|
||||
return static_cast<Alignment>(al);
|
||||
}
|
||||
|
||||
@@ -56,20 +60,26 @@ Alignment from_string(const String& s) {
|
||||
String to_string(Alignment align) {
|
||||
String ret;
|
||||
// vertical
|
||||
if (align & ALIGN_TOP) ret += _(" top");
|
||||
if (align & ALIGN_MIDDLE) ret += _(" middle");
|
||||
if (align & ALIGN_BOTTOM) ret += _(" bottom");
|
||||
if (align & ALIGN_TOP) ret += _("top ");
|
||||
if (align & ALIGN_MIDDLE) ret += _("middle ");
|
||||
if (align & ALIGN_BOTTOM) ret += _("bottom ");
|
||||
// horizontal
|
||||
if (align & ALIGN_LEFT) ret += _(" left");
|
||||
if (align & ALIGN_LEFT) ret += _(" center");
|
||||
if (align & ALIGN_LEFT) ret += _(" right");
|
||||
if (align & ALIGN_LEFT) ret += _(" justify");
|
||||
if (align & ALIGN_LEFT) ret += _(" justify-words");
|
||||
if (align & ALIGN_JUSTIFY_OVERFLOW) ret += _(" justify-overflow");
|
||||
// modifier
|
||||
if (align & ALIGN_STRETCH_OVERFLOW) ret += _(" stretch-overflow");
|
||||
if (align & ALIGN_STRETCH) ret += _(" stretch");
|
||||
return ret.substr(1);
|
||||
if (align & ALIGN_LEFT) ret += _("left ");
|
||||
if (align & ALIGN_CENTER) ret += _("center ");
|
||||
if (align & ALIGN_RIGHT) ret += _("right ");
|
||||
// fill
|
||||
if (align & ALIGN_FILL) {
|
||||
// force = !if_softbreak && some fill type
|
||||
if (!(align & ALIGN_IF_SOFTBREAK)) ret += _("force ");
|
||||
// fill
|
||||
if (align & ALIGN_STRETCH) ret += _("stretch ");
|
||||
if (align & ALIGN_JUSTIFY_WORDS) ret += _("justify ");
|
||||
if (align & ALIGN_JUSTIFY_ALL) ret += _("justify-all ");
|
||||
// modifier
|
||||
if (align & ALIGN_IF_OVERFLOW) ret += _("if-overflow ");
|
||||
}
|
||||
ret.resize(ret.size() - 1); // drop trailing ' '
|
||||
return ret;
|
||||
}
|
||||
|
||||
// we need custom io, because there can be both a horizontal and a vertical component
|
||||
|
||||
Reference in New Issue
Block a user