libardour now has CoreSelection object to manage selection status of Stripables and...
[ardour.git] / libs / ardour / stripable.cc
index c2f5b7239ad30c15712d64af434da6d43a2be670..c4f128b4e82096b865eb9d32a45da4f66aa66128 100644 (file)
 
 #include "pbd/compose.h"
 #include "pbd/convert.h"
+#include "pbd/i18n.h"
+
 
 #include "ardour/debug.h"
 #include "ardour/rc_configuration.h"
+#include "ardour/session.h"
+#include "ardour/selection.h"
 #include "ardour/stripable.h"
 
-#include "pbd/i18n.h"
-
 using namespace ARDOUR;
 using namespace PBD;
 using std::string;
 
 Stripable::Stripable (Session& s, string const & name, PresentationInfo const & pi)
        : SessionObject (s, name)
+       , Automatable (s)
        , _presentation_info (pi)
        , _active_color_picker (0)
 {
 }
 
+Stripable::~Stripable ()
+{
+       _session.selection().remove_stripable_by_id (id());
+}
+
 void
 Stripable::set_presentation_order (PresentationInfo::order_t order)
 {
@@ -103,3 +111,15 @@ Stripable::set_state (XMLNode const& node, int version)
 
        return 0;
 }
+
+bool
+Stripable::is_selected() const
+{
+       try {
+               boost::shared_ptr<const Stripable> s (shared_from_this());
+       } catch (...) {
+               std::cerr << "cannot shared-from-this for " << this << std::endl;
+               abort ();
+       }
+       return _session.selection().selected (shared_from_this());
+}