boost::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
+ boost::shared_ptr<AutomationControl> automation_control (PBD::ID const & id) const;
boost::shared_ptr<AutomationControl> automation_control (const Evoral::Parameter& id) {
return automation_control (id, false);
}
LIBARDOUR_API extern DebugBits AudioEngine;
LIBARDOUR_API extern DebugBits Soundcloud;
LIBARDOUR_API extern DebugBits Butler;
+ LIBARDOUR_API extern DebugBits Selection;
LIBARDOUR_API extern DebugBits GenericMidi;
LIBARDOUR_API extern DebugBits BackendMIDI;
LIBARDOUR_API extern DebugBits BackendAudio;
* change after construction (not strictly the constructor itself, but
* a more generalized notion of construction, as in "ready to use").
*
- * SELECTION
- *
- * When an object is selected, its _flags member will have the Selected
- * bit set.
- *
* VISIBILITY
*
* When an object is hidden, its _flags member will have the Hidden
/* These are for sharing Stripable states between the GUI and other
* user interfaces/control surfaces
*/
- Selected = 0x100,
- Hidden = 0x200,
+ Hidden = 0x100,
/* single bit indicates that the group order is set */
OrderSet = 0x400,
/* special mask to delect out "state" bits */
- StatusMask = (Selected|Hidden),
+ StatusMask = (Hidden),
/* special mask to delect select type bits */
TypeMask = (AudioBus|AudioTrack|MidiTrack|MidiBus|VCA|MasterOut|MonitorOut|Auditioner)
};
bool color_set() const;
void set_color (color_t);
- void set_selected (bool yn);
void set_hidden (bool yn);
void set_flags (Flag f) { _flags = f; }
int selection_cnt() const { return _selection_cnt; }
bool hidden() const { return _flags & Hidden; }
- bool selected() const { return _flags & Selected; }
bool special() const { return _flags & (MasterOut|MonitorOut|Auditioner); }
bool flag_match (Flag f) const {
*/
static PBD::Signal1<void,PBD::PropertyChange const &> Change;
+ static void send_static_change (const PBD::PropertyChange&);
static void make_property_quarks ();
static PBD::PropertyChange _pending_static_changes;
static Glib::Threads::Mutex static_signal_lock;
static int _change_signal_suspended;
- static void send_static_change (const PBD::PropertyChange&);
static int selection_counter;
};
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
-#include <boost/enable_shared_from_this.hpp>
#include <glibmm/threads.h>
#include "pbd/fastlog.h"
public Soloable,
public Muteable,
public Monitorable,
- public Automatable,
- public RouteGroupMember,
- public boost::enable_shared_from_this<Route>
+ public RouteGroupMember
{
public:
class Butler;
class Click;
class ControllableDescriptor;
+class CoreSelection;
class Diskstream;
class ExportHandler;
class ExportStatus;
return routes.reader ();
}
+ CoreSelection& selection () { return *_selection; }
+
/* because the set of Stripables consists of objects managed
* independently, in multiple containers within the Session (or objects
* owned by the session), we fill out a list in-place rather than
bool io_name_is_legal (const std::string&) const;
boost::shared_ptr<Route> route_by_name (std::string) const;
boost::shared_ptr<Route> route_by_id (PBD::ID) const;
+ boost::shared_ptr<Stripable> stripable_by_id (PBD::ID) const;
boost::shared_ptr<Stripable> get_remote_nth_stripable (PresentationInfo::order_t n, PresentationInfo::Flag) const;
boost::shared_ptr<Route> get_remote_nth_route (PresentationInfo::order_t n) const;
boost::shared_ptr<Route> route_by_selected_count (uint32_t cnt) const;
boost::shared_ptr<Processor> processor_by_id (PBD::ID) const;
boost::shared_ptr<PBD::Controllable> controllable_by_id (const PBD::ID&);
+ boost::shared_ptr<AutomationControl> automation_control_by_id (const PBD::ID&);
boost::shared_ptr<PBD::Controllable> controllable_by_descriptor (const ARDOUR::ControllableDescriptor&);
void add_controllable (boost::shared_ptr<PBD::Controllable>);
void rewire_selected_midi (boost::shared_ptr<MidiTrack>);
void rewire_midi_selection_ports ();
boost::weak_ptr<MidiTrack> current_midi_target;
+
+ CoreSelection* _selection;
};
virtual ~SessionHandlePtr () {}
virtual void set_session (ARDOUR::Session *);
+ virtual ARDOUR::Session* session() const { return _session; }
protected:
ARDOUR::Session* _session;
#include <string>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/enable_shared_from_this.hpp>
#include "pbd/signals.h"
+#include "ardour/automatable.h"
#include "ardour/presentation_info.h"
#include "ardour/session_object.h"
#include "ardour/libardour_visibility.h"
* and behaviour of the object.
*/
-class LIBARDOUR_API Stripable : public SessionObject {
- public:
+class LIBARDOUR_API Stripable : public SessionObject,
+ public Automatable,
+ public boost::enable_shared_from_this<Stripable>
+{
+ public:
Stripable (Session& session, std::string const & name, PresentationInfo const &);
- virtual ~Stripable () {}
+ virtual ~Stripable ();
/* XXX
midi on/off
int set_state (XMLNode const&, int);
bool is_hidden() const { return _presentation_info.flags() & PresentationInfo::Hidden; }
- bool is_selected() const { return _presentation_info.flags() & PresentationInfo::Selected; }
+ bool is_selected() const;
PresentationInfo const & presentation_info () const { return _presentation_info; }
PresentationInfo& presentation_info () { return _presentation_info; }
#include "pbd/controllable.h"
#include "pbd/statefuldestructible.h"
-#include "ardour/automatable.h"
#include "ardour/muteable.h"
#include "ardour/monitorable.h"
#include "ardour/recordable.h"
class LIBARDOUR_API VCA : public Stripable,
public Soloable,
public Muteable,
- public Automatable,
public Recordable,
- public Monitorable,
- public boost::enable_shared_from_this<VCA> {
+ public Monitorable
+{
public:
VCA (Session& session, int32_t num, const std::string& name);
~VCA();
return boost::shared_ptr<Evoral::Control>(control);
}
+boost::shared_ptr<AutomationControl>
+Automatable::automation_control (PBD::ID const & id) const
+{
+ Controls::const_iterator li;
+
+ for (li = _controls.begin(); li != _controls.end(); ++li) {
+ boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (li->second);
+ if (ac && (ac->id() == id)) {
+ return ac;
+ }
+ }
+
+ return boost::shared_ptr<AutomationControl>();
+}
+
boost::shared_ptr<AutomationControl>
Automatable::automation_control (const Evoral::Parameter& id, bool create)
{
#include "ardour/control_group.h"
#include "ardour/event_type_map.h"
#include "ardour/session.h"
+#include "ardour/selection.h"
#include "pbd/i18n.h"
AutomationControl::~AutomationControl ()
{
+ _session.selection().remove_control_by_id (id());
DropReferences (); /* EMIT SIGNAL */
}
PBD::DebugBits PBD::DEBUG::AudioEngine = PBD::new_debug_bit ("AudioEngine");
PBD::DebugBits PBD::DEBUG::Soundcloud = PBD::new_debug_bit ("Soundcloud");
PBD::DebugBits PBD::DEBUG::Butler = PBD::new_debug_bit ("Butler");
+PBD::DebugBits PBD::DEBUG::Selection = PBD::new_debug_bit ("selection");
PBD::DebugBits PBD::DEBUG::GenericMidi = PBD::new_debug_bit ("genericmidi");
PBD::DebugBits PBD::DEBUG::BackendMIDI = PBD::new_debug_bit ("backendmidi");
REGISTER_CLASS_ENUM (PresentationInfo, MasterOut);
REGISTER_CLASS_ENUM (PresentationInfo, MonitorOut);
REGISTER_CLASS_ENUM (PresentationInfo, Auditioner);
- REGISTER_CLASS_ENUM (PresentationInfo, Selected);
REGISTER_CLASS_ENUM (PresentationInfo, Hidden);
REGISTER_CLASS_ENUM (PresentationInfo, OrderSet);
REGISTER_BITS (_PresentationInfo_Flag);
.addConst ("MasterOut", ARDOUR::PresentationInfo::Flag(PresentationInfo::MasterOut))
.addConst ("MonitorOut", ARDOUR::PresentationInfo::Flag(PresentationInfo::MonitorOut))
.addConst ("Auditioner", ARDOUR::PresentationInfo::Flag(PresentationInfo::Auditioner))
- .addConst ("Selected", ARDOUR::PresentationInfo::Flag(PresentationInfo::Selected))
.addConst ("Hidden", ARDOUR::PresentationInfo::Flag(PresentationInfo::Hidden))
.addConst ("GroupOrderSet", ARDOUR::PresentationInfo::Flag(PresentationInfo::OrderSet))
.addConst ("StatusMask", ARDOUR::PresentationInfo::Flag(PresentationInfo::StatusMask))
#include "pbd/xml++.h"
#include "ardour/presentation_info.h"
+#include "ardour/selection.h"
#include "pbd/i18n.h"
Glib::Threads::Mutex PresentationInfo::static_signal_lock;
int PresentationInfo::_change_signal_suspended = 0;
PBD::PropertyChange PresentationInfo::_pending_static_changes;
-int PresentationInfo::selection_counter = 0;
+int PresentationInfo::selection_counter= 0;
namespace ARDOUR {
namespace Properties {
return _color != 0;
}
-void
-PresentationInfo::set_selected (bool yn)
-{
- if (yn != selected()) {
- if (yn) {
- _flags = Flag (_flags | Selected);
- _selection_cnt = g_atomic_int_add (&selection_counter, 1);
- } else {
- _flags = Flag (_flags & ~Selected);
- _selection_cnt = 0;
- }
- send_change (PropertyChange (Properties::selected));
- send_static_change (PropertyChange (Properties::selected));
- }
-}
-
void
PresentationInfo::set_hidden (bool yn)
{
: Stripable (sess, name, PresentationInfo (flag))
, GraphNode (sess._process_graph)
, Muteable (sess, name)
- , Automatable (sess)
, _active (true)
, _signal_latency (0)
, _signal_latency_at_amp_position (0)
boost::weak_ptr<Route>
Route::weakroute () {
- return boost::weak_ptr<Route> (shared_from_this ());
+ return boost::weak_ptr<Route> (boost::dynamic_pointer_cast<Route> (shared_from_this ()));
}
int
flags &= mask;
if (flags != None) {
- boost::optional<int> rv = PluginSetup (shared_from_this (), pi, flags); /* EMIT SIGNAL */
+ boost::optional<int> rv = PluginSetup (boost::dynamic_pointer_cast<Route>(shared_from_this ()), pi, flags); /* EMIT SIGNAL */
int mode = rv.get_value_or (0);
switch (mode & 3) {
case 1:
bool
Route::direct_feeds_according_to_graph (boost::shared_ptr<Route> other, bool* via_send_only)
{
- return _session._current_route_graph.has (shared_from_this (), other, via_send_only);
+ return _session._current_route_graph.has (boost::dynamic_pointer_cast<Route> (shared_from_this ()), other, via_send_only);
}
bool
Route::feeds_according_to_graph (boost::shared_ptr<Route> other)
{
- return _session._current_route_graph.feeds (shared_from_this (), other);
+ return _session._current_route_graph.feeds (boost::dynamic_pointer_cast<Route> (shared_from_this ()), other);
}
/** Called from the (non-realtime) butler thread when the transport is stopped */
continue;
}
bool sends_only;
- bool does_feed = (*i)->direct_feeds_according_to_reality (shared_from_this(), &sends_only);
+ bool does_feed = (*i)->direct_feeds_according_to_reality (boost::dynamic_pointer_cast<Route> (shared_from_this()), &sends_only);
if (does_feed && !sends_only) {
if ((*i)->soloed()) {
++sbou;
_solo_control->mod_solo_by_others_downstream (delta);
// Session::route_solo_changed() does not propagate indirect solo-changes
// propagate upstream to tracks
- boost::shared_ptr<Route> shared_this = shared_from_this();
+ boost::shared_ptr<Route> shared_this = boost::dynamic_pointer_cast<Route> (shared_from_this());
for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
if ((*i).get() == this || !can_solo()) {
continue;
#include "ardour/route_graph.h"
#include "ardour/route_group.h"
#include "ardour/send.h"
+#include "ardour/selection.h"
#include "ardour/session.h"
#include "ardour/session_directory.h"
#include "ardour/session_playlists.h"
, _midi_ports (0)
, _mmc (0)
, _vca_manager (new VCAManager (*this))
+ , _selection (new CoreSelection (*this))
{
uint32_t sr = 0;
return boost::shared_ptr<Route> ((Route*) 0);
}
+
+boost::shared_ptr<Stripable>
+Session::stripable_by_id (PBD::ID id) const
+{
+ StripableList sl;
+ get_stripables (sl);
+
+ for (StripableList::const_iterator s = sl.begin(); s != sl.end(); ++s) {
+ if ((*s)->id() == id) {
+ return *s;
+ }
+ }
+
+ return boost::shared_ptr<Stripable>();
+}
+
boost::shared_ptr<Processor>
Session::processor_by_id (PBD::ID id) const
{
RouteList::iterator i;
for (i = r.begin(); i != r.end(); ++i) {
- if ((*i)->presentation_info().selected()) {
+ if ((*i)->is_selected()) {
if (id == 0) {
return *i;
}
boost::shared_ptr<MidiTrack> new_midi_target (mt.lock ());
- if (new_midi_target->presentation_info().selected()) {
+ if (new_midi_target->is_selected()) {
rewire_selected_midi (new_midi_target);
}
}
#include "ardour/revision.h"
#include "ardour/route_group.h"
#include "ardour/send.h"
+#include "ardour/selection.h"
#include "ardour/session.h"
#include "ardour/session_directory.h"
#include "ardour/session_metadata.h"
if (full_state) {
+ node->add_child_nocopy (_selection->get_state());
+
if (_locations) {
node->add_child_nocopy (_locations->get_state());
}
}
}
+ if ((child = find_named_node (node, X_("Selection")))) {
+ _selection->set_state (*child, version);
+ }
+
update_route_record_state ();
/* here beginneth the second phase ... */
return boost::shared_ptr<Controllable>();
}
+boost::shared_ptr<AutomationControl>
+Session::automation_control_by_id (const PBD::ID& id)
+{
+ return boost::dynamic_pointer_cast<AutomationControl> (controllable_by_id (id));
+}
+
boost::shared_ptr<Controllable>
Session::controllable_by_descriptor (const ControllableDescriptor& desc)
{
#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)
{
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());
+}
return -1;
}
- boost::shared_ptr<Route> rp (shared_from_this());
+ boost::shared_ptr<Route> rp (boost::dynamic_pointer_cast<Route> (shared_from_this()));
boost::shared_ptr<Track> rt = boost::dynamic_pointer_cast<Track> (rp);
_record_enable_control.reset (new RecordEnableControl (_session, EventTypeMap::instance().to_symbol (RecEnableAutomation), *this));
VCA::VCA (Session& s, int32_t num, const string& name)
: Stripable (s, name, PresentationInfo (num, PresentationInfo::VCA))
, Muteable (s, name)
- , Automatable (s)
, _number (num)
, _gain_control (new GainControl (s, Evoral::Parameter (GainAutomation), boost::shared_ptr<AutomationList> ()))
{
'rb_effect.cc',
'scene_change.cc',
'search_paths.cc',
+ 'selection.cc',
'send.cc',
'session.cc',
'session_butler.cc',
}
break;
case Selected: // For example: a group (this is USER)
- if (s->presentation_info().selected() && !s->presentation_info().hidden()) {
+ if (s->is_selected() && !s->presentation_info().hidden()) {
sorted.push_back (s);
}
break;
return;
}
- if (stripables.size() == 1 && ControlProtocol::last_selected().size() == 1 && stripables.front()->presentation_info().selected()) {
+ if (stripables.size() == 1 && ControlProtocol::last_selected().size() == 1 && stripables.front()->is_selected()) {
/* cancel selection for one and only selected stripable */
ToggleStripableSelection (stripables.front());
} else {
if (what_changed.contains (ARDOUR::Properties::selected)) {
if (_stripable) {
- _surface->write (_select->set_state (_stripable->presentation_info().selected()));
- _surface->mcp().update_selected (_stripable, _stripable->presentation_info().selected());
+ _surface->write (_select->set_state (_stripable->is_selected()));
+ _surface->mcp().update_selected (_stripable, _stripable->is_selected());
}
}
}
sorted.push_back (s);
}
}
- } else
- if (types[3] && (s->presentation_info().flags() & PresentationInfo::MidiBus)) {
+ } else if (types[3] && (s->presentation_info().flags() & PresentationInfo::MidiBus)) {
sorted.push_back (s);
- } else
- if (types[4] && (s->presentation_info().flags() & PresentationInfo::VCA)) {
+ } else if (types[4] && (s->presentation_info().flags() & PresentationInfo::VCA)) {
sorted.push_back (s);
- } else
- if (types[8] && (s->presentation_info().flags() & PresentationInfo::Selected)) {
+ } else if (types[8] && (s->is_selected())) {
sorted.push_back (s);
- } else
- if (types[9] && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
+ } else if (types[9] && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
sorted.push_back (s);
}
}
if (what_changed.contains (Properties::color)) {
lower_backgrounds[which]->set_fill_color (stripable[which]->presentation_info().color());
- if (stripable[which]->presentation_info().selected()) {
+ if (stripable[which]->is_selected()) {
lower_text[which]->set_fill_color (contrasting_text_color (stripable[which]->presentation_info().color()));
/* might not be a MIDI track, in which case this will
do nothing
return;
}
- if (stripable[which]->presentation_info().selected()) {
+ if (stripable[which]->is_selected()) {
show_selection (which);
} else {
hide_selection (which);
stripable[n]->solo_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&MixLayout::solo_changed, this, n), &p2);
stripable[n]->mute_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&MixLayout::mute_changed, this, n), &p2);
- if (stripable[n]->presentation_info().selected()) {
+ if (stripable[n]->is_selected()) {
show_selection (n);
} else {
hide_selection (n);
for (int n = 0; n < 8; ++n) {
if (stripable[n]) {
- if (stripable[n]->presentation_info().selected()) {
+ if (stripable[n]->is_selected()) {
selected = n;
break;
}