more fixes to SVAModifier constructor(s)

This commit is contained in:
Paul Davis 2014-12-15 09:03:52 -05:00
parent 4908685d5e
commit aa57e9e032

View file

@ -548,12 +548,24 @@ SVAModifier::from_string (string const & str)
switch (op) { switch (op) {
case '*': case '*':
type = Multiply; type = Multiply;
/* no-op values for multiply */
s = 1.0;
v = 1.0;
a = 1.0;
break; break;
case '+': case '+':
type = Add; type = Add;
/* no-op values for add */
s = 0.0;
v = 0.0;
a = 1.0;
break; break;
case '=': case '=':
type = Assign; type = Assign;
/* this will avoid assignment in operator() (see below) */
s = -1.0;
v = -1.0;
a = -1.0;
break; break;
default: default:
throw failed_constructor (); throw failed_constructor ();
@ -564,11 +576,11 @@ SVAModifier::from_string (string const & str)
while (ss) { while (ss) {
ss >> mod; ss >> mod;
if ((pos = mod.find ("alpha:")) != string::npos) { if ((pos = mod.find ("alpha:")) != string::npos) {
a = PBD::atoi (mod.substr (pos+6)); a = PBD::atof (mod.substr (pos+6));
} else if ((pos = mod.find ("saturate:")) != string::npos) { } else if ((pos = mod.find ("saturate:")) != string::npos) {
s = PBD::atoi (mod.substr (pos+9)); s = PBD::atof (mod.substr (pos+9));
} else if ((pos = mod.find ("darkness:")) != string::npos) { } else if ((pos = mod.find ("darkness:")) != string::npos) {
v = PBD::atoi (mod.substr (pos+9)); v = PBD::atof (mod.substr (pos+9));
} else { } else {
throw failed_constructor (); throw failed_constructor ();
} }
@ -625,9 +637,15 @@ SVAModifier::operator () (HSV& hsv) const
r.a *= a; r.a *= a;
break; break;
case Assign: case Assign:
if (s > -1.0) {
r.s = s; r.s = s;
}
if (v > -1.0) {
r.v = v; r.v = v;
}
if (a > -1.0) {
r.a = a; r.a = a;
}
break; break;
} }