mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
add getters for SVAModifier
This commit is contained in:
parent
94b6dd7f87
commit
9831006c8e
2 changed files with 43 additions and 40 deletions
|
|
@ -43,17 +43,20 @@ struct LIBCANVAS_API HSV;
|
||||||
|
|
||||||
class LIBCANVAS_API SVAModifier
|
class LIBCANVAS_API SVAModifier
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
Add,
|
Add,
|
||||||
Multiply,
|
Multiply,
|
||||||
Assign
|
Assign
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
SVAModifier (std::string const &);
|
SVAModifier (std::string const &);
|
||||||
SVAModifier (Type t, double ss, double vv, double aa) : type (t), s (ss) , v (vv) , a (aa) {}
|
SVAModifier (Type t, double ss, double vv, double aa) : type (t), _s (ss) , _v (vv) , _a (aa) {}
|
||||||
SVAModifier () : type (Add), s (0), v (0), a (0) {} /* no-op modifier */
|
SVAModifier () : type (Add), _s (0), _v (0), _a (0) {} /* no-op modifier */
|
||||||
|
|
||||||
|
double s() const { return _s; }
|
||||||
|
double v() const { return _v; }
|
||||||
|
double a() const { return _a; }
|
||||||
|
|
||||||
HSV operator () (HSV& hsv) const;
|
HSV operator () (HSV& hsv) const;
|
||||||
std::string to_string () const;
|
std::string to_string () const;
|
||||||
|
|
@ -61,9 +64,9 @@ class LIBCANVAS_API SVAModifier
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type type;
|
Type type;
|
||||||
double s;
|
double _s;
|
||||||
double v;
|
double _v;
|
||||||
double a;
|
double _a;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LIBCANVAS_API HSV
|
struct LIBCANVAS_API HSV
|
||||||
|
|
|
||||||
|
|
@ -529,9 +529,9 @@ HSV::mod (SVAModifier const & svam)
|
||||||
|
|
||||||
SVAModifier::SVAModifier (string const &str)
|
SVAModifier::SVAModifier (string const &str)
|
||||||
: type (Add)
|
: type (Add)
|
||||||
, s (0)
|
, _s (0)
|
||||||
, v (0)
|
, _v (0)
|
||||||
, a (0)
|
, _a (0)
|
||||||
{
|
{
|
||||||
from_string (str);
|
from_string (str);
|
||||||
}
|
}
|
||||||
|
|
@ -549,23 +549,23 @@ SVAModifier::from_string (string const & str)
|
||||||
case '*':
|
case '*':
|
||||||
type = Multiply;
|
type = Multiply;
|
||||||
/* no-op values for multiply */
|
/* no-op values for multiply */
|
||||||
s = 1.0;
|
_s = 1.0;
|
||||||
v = 1.0;
|
_v = 1.0;
|
||||||
a = 1.0;
|
_a = 1.0;
|
||||||
break;
|
break;
|
||||||
case '+':
|
case '+':
|
||||||
type = Add;
|
type = Add;
|
||||||
/* no-op values for add */
|
/* no-op values for add */
|
||||||
s = 0.0;
|
_s = 0.0;
|
||||||
v = 0.0;
|
_v = 0.0;
|
||||||
a = 0.0;
|
_a = 0.0;
|
||||||
break;
|
break;
|
||||||
case '=':
|
case '=':
|
||||||
type = Assign;
|
type = Assign;
|
||||||
/* this will avoid assignment in operator() (see below) */
|
/* this will avoid assignment in operator() (see below) */
|
||||||
s = -1.0;
|
_s = -1.0;
|
||||||
v = -1.0;
|
_v = -1.0;
|
||||||
a = -1.0;
|
_a = -1.0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw failed_constructor ();
|
throw failed_constructor ();
|
||||||
|
|
@ -576,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::atof (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::atof (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::atof (mod.substr (pos+9));
|
_v = PBD::atof (mod.substr (pos+9));
|
||||||
} else {
|
} else {
|
||||||
throw failed_constructor ();
|
throw failed_constructor ();
|
||||||
}
|
}
|
||||||
|
|
@ -605,16 +605,16 @@ SVAModifier::to_string () const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s > -1.0) {
|
if (_s >= 0.0) {
|
||||||
ss << " saturate:" << s;
|
ss << " saturate:" << _s;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v > -1.0) {
|
if (_v >= 0.0) {
|
||||||
ss << " darker:" << v;
|
ss << " darker:" << _v;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a > -1.0) {
|
if (_a >= 0.0) {
|
||||||
ss << " alpha:" << a;
|
ss << " alpha:" << _a;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
|
|
@ -627,24 +627,24 @@ SVAModifier::operator () (HSV& hsv) const
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Add:
|
case Add:
|
||||||
r.s += s;
|
r.s += _s;
|
||||||
r.v += v;
|
r.v += _v;
|
||||||
r.a += a;
|
r.a += _a;
|
||||||
break;
|
break;
|
||||||
case Multiply:
|
case Multiply:
|
||||||
r.s *= s;
|
r.s *= _s;
|
||||||
r.v *= v;
|
r.v *= _v;
|
||||||
r.a *= a;
|
r.a *= _a;
|
||||||
break;
|
break;
|
||||||
case Assign:
|
case Assign:
|
||||||
if (s > -1.0) {
|
if (_s >= 0.0) {
|
||||||
r.s = s;
|
r.s = _s;
|
||||||
}
|
}
|
||||||
if (v > -1.0) {
|
if (_v >= 0.) {
|
||||||
r.v = v;
|
r.v = _v;
|
||||||
}
|
}
|
||||||
if (a > -1.0) {
|
if (_a >= 0.0) {
|
||||||
r.a = a;
|
r.a = _a;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue