mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 23:35:03 +01:00
update GUI to use new APIs
This commit is contained in:
parent
394bd8f428
commit
1db9ce4c90
4 changed files with 54 additions and 152 deletions
|
|
@ -99,7 +99,6 @@ AutomationLine::AutomationLine (const string& name,
|
||||||
|
|
||||||
update_pending = false;
|
update_pending = false;
|
||||||
have_timeout = false;
|
have_timeout = false;
|
||||||
_uses_gain_mapping = false;
|
|
||||||
no_draw = false;
|
no_draw = false;
|
||||||
_is_boolean = false;
|
_is_boolean = false;
|
||||||
terminal_points_can_slide = true;
|
terminal_points_can_slide = true;
|
||||||
|
|
@ -118,12 +117,6 @@ AutomationLine::AutomationLine (const string& name,
|
||||||
|
|
||||||
trackview.session()->register_with_memento_command_factory(alist->id(), this);
|
trackview.session()->register_with_memento_command_factory(alist->id(), this);
|
||||||
|
|
||||||
if (alist->parameter().type() == GainAutomation ||
|
|
||||||
alist->parameter().type() == TrimAutomation ||
|
|
||||||
alist->parameter().type() == EnvelopeAutomation) {
|
|
||||||
set_uses_gain_mapping (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
interpolation_changed (alist->interpolation ());
|
interpolation_changed (alist->interpolation ());
|
||||||
|
|
||||||
connect_to_list ();
|
connect_to_list ();
|
||||||
|
|
@ -194,7 +187,19 @@ AutomationLine::update_visibility ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
AutomationLine::get_uses_gain_mapping () const
|
||||||
|
{
|
||||||
|
switch (_desc.type) {
|
||||||
|
case GainAutomation:
|
||||||
|
case EnvelopeAutomation:
|
||||||
|
case TrimAutomation:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -250,15 +255,6 @@ AutomationLine::set_line_color (uint32_t color)
|
||||||
line->set_fill_color ((color & 0xffffff00) + mod.a()*255);
|
line->set_fill_color ((color & 0xffffff00) + mod.a()*255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AutomationLine::set_uses_gain_mapping (bool yn)
|
|
||||||
{
|
|
||||||
if (yn != _uses_gain_mapping) {
|
|
||||||
_uses_gain_mapping = yn;
|
|
||||||
reset ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ControlPoint*
|
ControlPoint*
|
||||||
AutomationLine::nth (uint32_t n)
|
AutomationLine::nth (uint32_t n)
|
||||||
{
|
{
|
||||||
|
|
@ -342,36 +338,17 @@ AutomationLine::sync_model_with_view_points (list<ControlPoint*> cp)
|
||||||
string
|
string
|
||||||
AutomationLine::get_verbose_cursor_string (double fraction) const
|
AutomationLine::get_verbose_cursor_string (double fraction) const
|
||||||
{
|
{
|
||||||
std::string s = fraction_to_string (fraction);
|
return fraction_to_string (fraction);
|
||||||
if (_uses_gain_mapping) {
|
|
||||||
s += " dB";
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
AutomationLine::get_verbose_cursor_relative_string (double original, double fraction) const
|
AutomationLine::get_verbose_cursor_relative_string (double original, double fraction) const
|
||||||
{
|
{
|
||||||
std::string s = fraction_to_string (fraction);
|
std::string s = fraction_to_string (fraction);
|
||||||
if (_uses_gain_mapping) {
|
|
||||||
s += " dB";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string d = fraction_to_relative_string (original, fraction);
|
std::string d = fraction_to_relative_string (original, fraction);
|
||||||
|
|
||||||
if (!d.empty()) {
|
if (!d.empty()) {
|
||||||
|
s += " (\u0394" + d + ")";
|
||||||
s += " (\u0394";
|
|
||||||
s += d;
|
|
||||||
|
|
||||||
if (_uses_gain_mapping) {
|
|
||||||
s += " dB";
|
|
||||||
}
|
|
||||||
|
|
||||||
s += ')';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -382,26 +359,7 @@ AutomationLine::get_verbose_cursor_relative_string (double original, double frac
|
||||||
string
|
string
|
||||||
AutomationLine::fraction_to_string (double fraction) const
|
AutomationLine::fraction_to_string (double fraction) const
|
||||||
{
|
{
|
||||||
if (_uses_gain_mapping) {
|
return ARDOUR::value_as_string (_desc, _desc.from_interface (fraction));
|
||||||
char buf[32];
|
|
||||||
if (_desc.type == GainAutomation || _desc.type == EnvelopeAutomation || _desc.lower == 0) {
|
|
||||||
if (fraction == 0.0) {
|
|
||||||
snprintf (buf, sizeof (buf), "-inf");
|
|
||||||
} else {
|
|
||||||
snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain_with_max (fraction, _desc.upper)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const double lower_db = accurate_coefficient_to_dB (_desc.lower);
|
|
||||||
const double range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db;
|
|
||||||
snprintf (buf, sizeof (buf), "%.1f", lower_db + fraction * range_db);
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
} else {
|
|
||||||
view_to_model_coord_y (fraction);
|
|
||||||
return ARDOUR::value_as_string (_desc, fraction);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ""; /*NOTREACHED*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -412,32 +370,26 @@ AutomationLine::fraction_to_string (double fraction) const
|
||||||
string
|
string
|
||||||
AutomationLine::fraction_to_relative_string (double original, double fraction) const
|
AutomationLine::fraction_to_relative_string (double original, double fraction) const
|
||||||
{
|
{
|
||||||
char buf[32];
|
|
||||||
|
|
||||||
if (original == fraction) {
|
if (original == fraction) {
|
||||||
return "0";
|
return ARDOUR::value_as_string (_desc, 0);
|
||||||
}
|
}
|
||||||
|
switch (_desc.type) {
|
||||||
if (_uses_gain_mapping) {
|
case GainAutomation:
|
||||||
if (original == 0.0) {
|
case EnvelopeAutomation:
|
||||||
/* there is no sensible representation of a relative
|
case TrimAutomation:
|
||||||
change from -inf dB, so return an empty string.
|
if (original == 0.0) {
|
||||||
*/
|
/* there is no sensible representation of a relative
|
||||||
return "";
|
* change from -inf dB, so return an empty string.
|
||||||
} else if (fraction == 0.0) {
|
*/
|
||||||
snprintf (buf, sizeof (buf), "-inf");
|
return "";
|
||||||
} else {
|
} else if (fraction == 0.0) {
|
||||||
double old_db = accurate_coefficient_to_dB (slider_position_to_gain_with_max (original, Config->get_max_gain()));
|
return "-inf dB";
|
||||||
double new_db = accurate_coefficient_to_dB (slider_position_to_gain_with_max (fraction, Config->get_max_gain()));
|
}
|
||||||
snprintf (buf, sizeof (buf), "%.1f", new_db - old_db);
|
return ARDOUR::value_as_string (_desc, _desc.from_interface (fraction) / _desc.from_interface(original));
|
||||||
}
|
default:
|
||||||
} else {
|
break;
|
||||||
view_to_model_coord_y (original);
|
|
||||||
view_to_model_coord_y (fraction);
|
|
||||||
return ARDOUR::value_as_string (_desc, fraction - original);
|
|
||||||
}
|
}
|
||||||
|
return ARDOUR::value_as_string (_desc, _desc.from_interface (fraction) - _desc.from_interface(original));
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -447,21 +399,23 @@ AutomationLine::fraction_to_relative_string (double original, double fraction) c
|
||||||
double
|
double
|
||||||
AutomationLine::string_to_fraction (string const & s) const
|
AutomationLine::string_to_fraction (string const & s) const
|
||||||
{
|
{
|
||||||
if (s == "-inf") {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
double v;
|
double v;
|
||||||
sscanf (s.c_str(), "%lf", &v);
|
sscanf (s.c_str(), "%lf", &v);
|
||||||
|
|
||||||
if (_uses_gain_mapping) {
|
switch (_desc.type) {
|
||||||
v = gain_to_slider_position_with_max (dB_to_coefficient (v), Config->get_max_gain());
|
case GainAutomation:
|
||||||
} else {
|
case EnvelopeAutomation:
|
||||||
double dummy = 0.0;
|
case TrimAutomation:
|
||||||
model_to_view_coord (dummy, v);
|
if (s == "-inf") { /* translation */
|
||||||
|
v = 0;
|
||||||
|
} else {
|
||||||
|
v = dB_to_coefficient (v);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return _desc.to_interface (v);
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Start dragging a single point, possibly adding others if the supplied point is selected and there
|
/** Start dragging a single point, possibly adding others if the supplied point is selected and there
|
||||||
|
|
@ -1198,65 +1152,19 @@ AutomationLine::view_to_model_coord (double& x, double& y) const
|
||||||
void
|
void
|
||||||
AutomationLine::view_to_model_coord_y (double& y) const
|
AutomationLine::view_to_model_coord_y (double& y) const
|
||||||
{
|
{
|
||||||
/* TODO: This should be more generic (use ParameterDescriptor)
|
if (alist->default_interpolation () != alist->interpolation()) {
|
||||||
* or better yet: Controllable -> set_interface();
|
//TODO use non-standard scaling.
|
||||||
*/
|
|
||||||
|
|
||||||
if ( alist->parameter().type() == GainAutomation
|
|
||||||
|| alist->parameter().type() == EnvelopeAutomation
|
|
||||||
|| (_desc.logarithmic && _desc.lower == 0. && _desc.upper > _desc.lower)) {
|
|
||||||
y = slider_position_to_gain_with_max (y, _desc.upper);
|
|
||||||
y = max ((double)_desc.lower, y);
|
|
||||||
y = min ((double)_desc.upper, y);
|
|
||||||
} else if (alist->parameter().type() == TrimAutomation
|
|
||||||
|| (_desc.logarithmic && _desc.lower * _desc.upper > 0 && _desc.upper > _desc.lower)) {
|
|
||||||
const double lower_db = accurate_coefficient_to_dB (_desc.lower);
|
|
||||||
const double range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db;
|
|
||||||
y = max (0.0, y);
|
|
||||||
y = min (1.0, y);
|
|
||||||
y = dB_to_coefficient (lower_db + y * range_db);
|
|
||||||
} else if (alist->parameter().type() == PanAzimuthAutomation ||
|
|
||||||
alist->parameter().type() == PanElevationAutomation) {
|
|
||||||
y = 1.0 - y;
|
|
||||||
y = max ((double) _desc.lower, y);
|
|
||||||
y = min ((double) _desc.upper, y);
|
|
||||||
} else if (alist->parameter().type() == PanWidthAutomation) {
|
|
||||||
y = 2.0 * y - 1.0;
|
|
||||||
y = max ((double) _desc.lower, y);
|
|
||||||
y = min ((double) _desc.upper, y);
|
|
||||||
} else {
|
|
||||||
y = y * (double)(_desc.upper - _desc.lower) + _desc.lower;
|
|
||||||
if (_desc.integer_step) {
|
|
||||||
y = round(y);
|
|
||||||
} else if (_desc.toggled) {
|
|
||||||
y = (y > 0.5) ? 1.0 : 0.0;
|
|
||||||
}
|
|
||||||
y = max ((double) _desc.lower, y);
|
|
||||||
y = min ((double) _desc.upper, y);
|
|
||||||
}
|
}
|
||||||
|
y = _desc.from_interface (y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AutomationLine::model_to_view_coord_y (double& y) const
|
AutomationLine::model_to_view_coord_y (double& y) const
|
||||||
{
|
{
|
||||||
/* TODO: This should be more generic (use ParameterDescriptor) */
|
if (alist->default_interpolation () != alist->interpolation()) {
|
||||||
if ( alist->parameter().type() == GainAutomation
|
//TODO use non-standard scaling.
|
||||||
|| alist->parameter().type() == EnvelopeAutomation
|
|
||||||
|| (_desc.logarithmic && _desc.lower == 0. && _desc.upper > _desc.lower)) {
|
|
||||||
y = gain_to_slider_position_with_max (y, _desc.upper);
|
|
||||||
} else if (alist->parameter().type() == TrimAutomation
|
|
||||||
|| (_desc.logarithmic && _desc.lower * _desc.upper > 0 && _desc.upper > _desc.lower)) {
|
|
||||||
const double lower_db = accurate_coefficient_to_dB (_desc.lower);
|
|
||||||
const double range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db;
|
|
||||||
y = (accurate_coefficient_to_dB (y) - lower_db) / range_db;
|
|
||||||
} else if (alist->parameter().type() == PanAzimuthAutomation ||
|
|
||||||
alist->parameter().type() == PanElevationAutomation) {
|
|
||||||
y = 1.0 - y;
|
|
||||||
} else if (alist->parameter().type() == PanWidthAutomation) {
|
|
||||||
y = .5 + y * .5;
|
|
||||||
} else {
|
|
||||||
y = (y - _desc.lower) / (double)(_desc.upper - _desc.lower);
|
|
||||||
}
|
}
|
||||||
|
y = _desc.to_interface (y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,8 @@ public:
|
||||||
|
|
||||||
void hide ();
|
void hide ();
|
||||||
void set_height (guint32);
|
void set_height (guint32);
|
||||||
void set_uses_gain_mapping (bool yn);
|
|
||||||
bool get_uses_gain_mapping () const { return _uses_gain_mapping; }
|
bool get_uses_gain_mapping () const;
|
||||||
|
|
||||||
TimeAxisView& trackview;
|
TimeAxisView& trackview;
|
||||||
|
|
||||||
|
|
@ -172,7 +172,6 @@ protected:
|
||||||
|
|
||||||
VisibleAspects _visible;
|
VisibleAspects _visible;
|
||||||
|
|
||||||
bool _uses_gain_mapping;
|
|
||||||
bool terminal_points_can_slide;
|
bool terminal_points_can_slide;
|
||||||
bool update_pending;
|
bool update_pending;
|
||||||
bool have_timeout;
|
bool have_timeout;
|
||||||
|
|
|
||||||
|
|
@ -1089,11 +1089,7 @@ GenericPluginUI::output_update ()
|
||||||
(*i)->display_label->set_text (buf);
|
(*i)->display_label->set_text (buf);
|
||||||
|
|
||||||
if ((*i)->meterinfo && (*i)->meterinfo->packed) {
|
if ((*i)->meterinfo && (*i)->meterinfo->packed) {
|
||||||
const float upper = c->desc().upper;
|
(*i)->meterinfo->meter->set (c->desc().to_interface (val));
|
||||||
const float lower = c->desc().lower;
|
|
||||||
val = std::min (upper, std::max (lower, val));
|
|
||||||
float lval = (val - lower / (upper - lower));
|
|
||||||
(*i)->meterinfo->meter->set (lval);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ AudioRegionGainLine::AudioRegionGainLine (const string & name, AudioRegionView&
|
||||||
|
|
||||||
group->raise_to_top ();
|
group->raise_to_top ();
|
||||||
group->set_y_position (2);
|
group->set_y_position (2);
|
||||||
set_uses_gain_mapping (true);
|
|
||||||
terminal_points_can_slide = false;
|
terminal_points_can_slide = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue