mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
reading alignments
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@123 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+16
-6
@@ -34,13 +34,23 @@ RealPoint align_in_rect(Alignment align, const RealSize& to_align, const RealRec
|
|||||||
// ----------------------------------------------------------------------------- : Reflection stuff
|
// ----------------------------------------------------------------------------- : Reflection stuff
|
||||||
|
|
||||||
/// Convert a String to an Alignment
|
/// Convert a String to an Alignment
|
||||||
Alignment fromString(const String& str) {
|
Alignment from_string(const String& s) {
|
||||||
int al = 0;
|
int al = ALIGN_TOP_LEFT;
|
||||||
|
if (s.find(_("left")) !=String::npos) al = ALIGN_LEFT | (al & ALIGN_VERTICAL);
|
||||||
|
if (s.find(_("center")) !=String::npos) al = ALIGN_CENTER | (al & ALIGN_VERTICAL);
|
||||||
|
if (s.find(_("right")) !=String::npos) al = ALIGN_RIGHT | (al & ALIGN_VERTICAL);
|
||||||
|
if (s.find(_("justify")) !=String::npos) al = ALIGN_JUSTIFY | (al & ALIGN_VERTICAL);
|
||||||
|
if (s.find(_("justify-words")) !=String::npos) al = ALIGN_JUSTIFY_WORDS | (al & ALIGN_VERTICAL);
|
||||||
|
if (s.find(_("shrink-overflow"))!=String::npos) al = ALIGN_JUSTIFY_OVERFLOW | (al & ~ALIGN_JUSTIFY_OVERFLOW);
|
||||||
|
if (s.find(_("top")) !=String::npos) al = ALIGN_TOP | (al & ALIGN_HORIZONTAL);
|
||||||
|
if (s.find(_("middle")) !=String::npos) al = ALIGN_MIDDLE | (al & ALIGN_HORIZONTAL);
|
||||||
|
if (s.find(_("bottom")) !=String::npos) al = ALIGN_BOTTOM | (al & ALIGN_HORIZONTAL);
|
||||||
|
if (s.find(_("stretch")) !=String::npos) al = ALIGN_STRETCH;
|
||||||
return static_cast<Alignment>(al);
|
return static_cast<Alignment>(al);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert an Alignment to a String
|
/// Convert an Alignment to a String
|
||||||
String toString(Alignment align) {
|
String to_string(Alignment align) {
|
||||||
String ret;
|
String ret;
|
||||||
// vertical
|
// vertical
|
||||||
if (align & ALIGN_TOP) ret += _(" top");
|
if (align & ALIGN_TOP) ret += _(" top");
|
||||||
@@ -61,11 +71,11 @@ String toString(Alignment align) {
|
|||||||
// we need custom io, because there can be both a horizontal and a vertical component
|
// we need custom io, because there can be both a horizontal and a vertical component
|
||||||
|
|
||||||
template <> void Reader::handle(Alignment& align) {
|
template <> void Reader::handle(Alignment& align) {
|
||||||
align = fromString(value);
|
align = from_string(value);
|
||||||
}
|
}
|
||||||
template <> void Writer::handle(const Alignment& align) {
|
template <> void Writer::handle(const Alignment& align) {
|
||||||
handle(toString(align));
|
handle(to_string(align));
|
||||||
}
|
}
|
||||||
template <> void GetDefaultMember::handle(const Alignment& align) {
|
template <> void GetDefaultMember::handle(const Alignment& align) {
|
||||||
handle(toString(align));
|
handle(to_string(align));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user