carl's wondrous DnD VBox patch - processor boxes are now vboxes and not listviews...
[ardour.git] / libs / ardour / send.cc
index bd9eccaf542ddabe1aa56cdfd69b03e8cd0cbd6e..91e6827e6166435a2e0e040b46b9813fe9adb27b 100644 (file)
@@ -17,6 +17,7 @@
 
 */
 
+#include <iostream>
 #include <algorithm>
 
 #include "pbd/xml++.h"
@@ -35,6 +36,7 @@
 
 using namespace ARDOUR;
 using namespace PBD;
+using namespace std;
 
 Send::Send (Session& s, boost::shared_ptr<MuteMaster> mm, Role r)
        : Delivery (s, mm, string_compose (_("send %1"), (_bitslot = s.next_send_id()) + 1), r)
@@ -79,7 +81,8 @@ Send::deactivate ()
 {
        _amp->deactivate ();
        _meter->deactivate ();
-
+       _meter->reset ();
+       
        Processor::deactivate ();
 }
 
@@ -160,6 +163,7 @@ Send::set_state (const XMLNode& node, int version)
                _bitslot = _session.next_send_id();
        } else {
                sscanf (prop->value().c_str(), "%" PRIu32, &_bitslot);
+               cerr << this << " scanned " << prop->value() << " to get " << _bitslot << endl;
                _session.mark_send_id (_bitslot);
        }
 
@@ -167,7 +171,7 @@ Send::set_state (const XMLNode& node, int version)
 
        /* XXX need to load automation state & data for amp */
 
-       Delivery::set_state (*insert_node);
+       Delivery::set_state (*insert_node, version);
 
        return 0;
 }
@@ -212,7 +216,7 @@ Send::make_unique (XMLNode &state, Session &session)
        snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
        state.property("bitslot")->set_value (buf);
 
-       std::string const name = string_compose (_("send %1"), bitslot);
+       string const name = string_compose (_("send %1"), bitslot);
 
        state.property("name")->set_value (name);
 
@@ -224,15 +228,27 @@ Send::make_unique (XMLNode &state, Session &session)
 }
 
 bool
-Send::set_name (const std::string& new_name)
+Send::set_name (const string& new_name)
 {
-       std::string unique_name;
+       string unique_name;
 
        if (_role == Delivery::Send) {
                char buf[32];
-               snprintf (buf, sizeof (buf), "%u", _bitslot);
-               unique_name = new_name;
+
+               /* rip any existing numeric part of the name, and append the bitslot
+                */
+
+               string::size_type last_letter = new_name.find_last_not_of ("0123456789");
+
+               if (last_letter != string::npos) {
+                       unique_name = new_name.substr (0, last_letter + 1);
+               } else {
+                       unique_name = new_name;
+               }
+
+               snprintf (buf, sizeof (buf), "%u", (_bitslot + 1));
                unique_name += buf;
+
        } else {
                unique_name = new_name;
        }
@@ -241,8 +257,10 @@ Send::set_name (const std::string& new_name)
 }
 
 bool
-Send::visible () const
+Send::display_to_user () const
 {
+       /* we ignore Deliver::_display_to_user */
+
        if (_role == Listen) {
                return false;
        }