+
+void
+RouteGroup::post_set (PBD::PropertyChange const &)
+{
+ push_to_groups ();
+}
+
+void
+RouteGroup::push_to_groups ()
+{
+ if (is_relative()) {
+ _gain_group->set_mode (ControlGroup::Mode (_gain_group->mode()|ControlGroup::Relative));
+ } else {
+ _gain_group->set_mode (ControlGroup::Mode (_gain_group->mode()&~ControlGroup::Relative));
+ }
+
+ if (_active) {
+ _gain_group->set_active (is_gain());
+ _solo_group->set_active (is_solo());
+ _mute_group->set_active (is_mute());
+ _rec_enable_group->set_active (is_recenable());
+ _monitoring_group->set_active (is_monitoring());
+ } else {
+ _gain_group->set_active (false);
+ _solo_group->set_active (false);
+ _mute_group->set_active (false);
+
+ _rec_enable_group->set_active (false);
+ _monitoring_group->set_active (false);
+ }
+}
+
+void
+RouteGroup::assign_master (boost::shared_ptr<VCA> master)
+{
+ if (!routes || routes->empty()) {
+ return;
+ }
+
+ boost::shared_ptr<Route> front = routes->front ();
+
+ if (front->slaved_to (master)) {
+ return;
+ }
+
+ for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) {
+ (*r)->assign (master, false);
+ }
+
+ bool used_to_share_gain = false;
+
+ if (is_gain()) {
+ used_to_share_gain = true;
+ }
+
+ group_master = master;
+ _group_master_number = master->number();
+ _gain_group->set_active (false);
+
+ if (used_to_share_gain) {
+ send_change (PropertyChange (Properties::group_gain));
+ }
+}
+
+void
+RouteGroup::unassign_master (boost::shared_ptr<VCA> master)
+{
+ if (!routes || routes->empty()) {
+ return;
+ }
+
+ boost::shared_ptr<Route> front = routes->front ();
+
+ if (!front->slaved_to (master)) {
+ return;
+ }
+
+ for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) {
+ (*r)->unassign (master);
+ }
+
+ group_master.reset ();
+ _group_master_number = -1;
+
+ /* this is slightly tricky: is_gain() will return whether or not
+ the group is supposed to be sharing gain adjustment, and now that
+ we've reset _group_master_number to -1, it will reflect the user's
+ intentions correctly. Since there was a master before, and now there
+ is not, we are going to reactivate gain sharing ... and then tell
+ the world about it.
+ */
+ if (is_gain()) {
+ _gain_group->set_active (true);
+ send_change (PropertyChange (Properties::group_gain));
+ }
+}
+
+bool
+RouteGroup::slaved () const
+{
+ if (!routes || routes->empty()) {
+ return false;
+ }
+
+ return routes->front()->slaved ();
+}
+
+bool
+RouteGroup::has_control_master() const
+{
+ return group_master.lock() != 0;
+}