13
0

implement track numbering

This commit is contained in:
Robin Gareus 2014-06-25 21:16:09 +02:00
parent 7cb6e9065a
commit b067a185f0
4 changed files with 68 additions and 0 deletions

View File

@ -287,6 +287,21 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
PBD::Signal1<void,void*> mute_changed;
PBD::Signal0<void> mute_points_changed;
/** track numbers - assigned by session
* nubers > 0 indicate tracks (audio+midi)
* nubers < 0 indicate busses
* zero is reserved for unnumbered special busses.
* */
PBD::Signal0<void> track_number_changed;
int64_t track_number() const { return _track_number; }
void set_track_number(int64_t tn) {
if (tn == _track_number) { return; }
_track_number = tn;
track_number_changed();
PropertyChanged (ARDOUR::Properties::name);
}
/** the processors have changed; the parameter indicates what changed */
PBD::Signal1<void,RouteProcessorChange> processors_changed;
PBD::Signal1<void,void*> record_enable_changed;
@ -562,6 +577,8 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
bool _has_order_key;
uint32_t _remote_control_id;
int64_t _track_number;
void input_change_handler (IOChange, void *src);
void output_change_handler (IOChange, void *src);

View File

@ -260,6 +260,10 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
bool route_name_unique (std::string) const;
bool route_name_internal (std::string) const;
uint32_t track_number_decimals () const {
return _track_number_decimals;
}
bool get_record_enabled() const {
return (record_status () >= Enabled);
}
@ -1342,6 +1346,11 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
ChanCount input_start = ChanCount (), ChanCount output_start = ChanCount ());
void midi_output_change_handler (IOChange change, void* /*src*/, boost::weak_ptr<Route> midi_track);
/* track numbering */
void reassign_track_numbers ();
uint32_t _track_number_decimals;
/* mixer stuff */
bool solo_update_disabled;

View File

@ -102,6 +102,7 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type)
, _order_key (0)
, _has_order_key (false)
, _remote_control_id (0)
, _track_number (0)
, _in_configure_processors (false)
, _initial_io_setup (false)
, _custom_meter_position_noted (false)

View File

@ -81,6 +81,7 @@
#include "ardour/region_factory.h"
#include "ardour/route_graph.h"
#include "ardour/route_group.h"
#include "ardour/route_sorters.h"
#include "ardour/send.h"
#include "ardour/session.h"
#include "ardour/session_directory.h"
@ -234,6 +235,7 @@ Session::Session (AudioEngine &eng,
, routes (new RouteList)
, _adding_routes_in_progress (false)
, destructive_index (0)
, _track_number_decimals(1)
, solo_update_disabled (false)
, default_fade_steepness (0)
, default_fade_msecs (0)
@ -2349,6 +2351,8 @@ Session::add_routes (RouteList& new_routes, bool input_auto_connect, bool output
save_state (_current_snapshot_name);
}
reassign_track_numbers();
RouteAdded (new_routes); /* EMIT SIGNAL */
}
@ -2626,6 +2630,7 @@ Session::remove_route (boost::shared_ptr<Route> route)
if (save_state (_current_snapshot_name)) {
save_history (_current_snapshot_name);
}
reassign_track_numbers();
}
void
@ -3042,6 +3047,40 @@ Session::route_by_remote_id (uint32_t id)
return boost::shared_ptr<Route> ((Route*) 0);
}
void
Session::reassign_track_numbers ()
{
int64_t tn = 0;
int64_t bn = 0;
RouteList r (*(routes.reader ()));
SignalOrderRouteSorter sorter;
r.sort (sorter);
for (RouteList::iterator i = r.begin(); i != r.end(); ++i) {
if (boost::dynamic_pointer_cast<Track> (*i)) {
(*i)->set_track_number(++tn);
}
else if (!(*i)->is_master() && !(*i)->is_monitor() && !(*i)->is_auditioner()) {
(*i)->set_track_number(--bn);
}
}
const uint32_t decimals = ceilf (log10f (tn + 1));
const bool decimals_changed = _track_number_decimals != decimals;
_track_number_decimals = decimals;
if (decimals_changed && config.get_track_name_number ()) {
for (RouteList::iterator i = r.begin(); i != r.end(); ++i) {
boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*i);
if (t) {
t->resync_track_name();
}
}
// trigger GUI re-layout
config.ParameterChanged("track-name-number");
}
}
void
Session::playlist_region_added (boost::weak_ptr<Region> w)
{
@ -5004,6 +5043,8 @@ Session::sync_order_keys ()
DEBUG_TRACE (DEBUG::OrderKeys, "Sync Order Keys.\n");
reassign_track_numbers();
Route::SyncOrderKeys (); /* EMIT SIGNAL */
DEBUG_TRACE (DEBUG::OrderKeys, "\tsync done\n");