make solo-in-front controllable. a few tweaks left to do.
[ardour.git] / gtk2_ardour / mixer_group_tabs.cc
index 7ab162d3c862677a600e67d9938cc5872550d906..a261fc8ec992193956d372ffc342d4bc732cf68d 100644 (file)
 #include "mixer_strip.h"
 #include "mixer_ui.h"
 #include "utils.h"
+#include "i18n.h"
+#include "route_group_dialog.h"
 
 using namespace std;
+using namespace Gtk;
 using namespace ARDOUR;
 
 MixerGroupTabs::MixerGroupTabs (Mixer_UI* m)
-       : _mixer (m)
+       : _mixer (m),
+         _menu (0)
 {
        
 }
@@ -44,28 +48,31 @@ MixerGroupTabs::compute_tabs () const
        tab.group = 0;
 
        int32_t x = 0;
-       for (list<MixerStrip*>::iterator i = _mixer->strips.begin(); i != _mixer->strips.end(); ++i) {
+       TreeModel::Children rows = _mixer->track_model->children ();
+       for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
 
-               if ((*i)->route()->is_master() || (*i)->route()->is_control() || !(*i)->marked_for_display()) {
+               MixerStrip* s = (*i)[_mixer->track_columns.strip];
+
+               if (s->route()->is_master() || s->route()->is_control() || !s->marked_for_display()) {
                        continue;
                }
 
-               RouteGroup* g = (*i)->route_group ();
+               RouteGroup* g = s->route_group ();
 
                if (g != tab.group) {
                        if (tab.group) {
                                tab.to = x;
-                               tab.last_ui_size = (*i)->get_width ();
+                               tab.last_ui_size = s->get_width ();
                                tabs.push_back (tab);
                        }
 
                        tab.from = x;
                        tab.group = g;
-                       tab.colour = (*i)->color ();
-                       tab.first_ui_size = (*i)->get_width ();
+                       tab.colour = s->color ();
+                       tab.first_ui_size = s->get_width ();
                }
 
-               x += (*i)->get_width ();
+               x += s->get_width ();
        }
 
        if (tab.group) {
@@ -117,16 +124,19 @@ MixerGroupTabs::reflect_tabs (list<Tab> const & tabs)
        list<Tab>::const_iterator j = tabs.begin ();
        
        int32_t x = 0;
-       for (list<MixerStrip*>::iterator i = _mixer->strips.begin(); i != _mixer->strips.end(); ++i) {
+       TreeModel::Children rows = _mixer->track_model->children ();
+       for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
 
-               if ((*i)->route()->is_master() || (*i)->route()->is_control() || !(*i)->marked_for_display()) {
+               MixerStrip* s = (*i)[_mixer->track_columns.strip];
+               
+               if (s->route()->is_master() || s->route()->is_control() || !s->marked_for_display()) {
                        continue;
                }
                
                if (j == tabs.end()) {
                        
                        /* already run out of tabs, so no edit group */
-                       (*i)->route()->set_route_group (0, this);
+                       s->route()->set_route_group (0, this);
                        
                } else {
                        
@@ -135,17 +145,48 @@ MixerGroupTabs::reflect_tabs (list<Tab> const & tabs)
                                ++j;
                        }
                        
-                       double const h = x + (*i)->get_width() / 2;
+                       double const h = x + s->get_width() / 2;
                        
                        if (j->from < h && j->to > h) {
-                               (*i)->route()->set_route_group (j->group, this);
+                               s->route()->set_route_group (j->group, this);
                        } else {
-                               (*i)->route()->set_route_group (0, this);
+                               s->route()->set_route_group (0, this);
                        }
                        
                }
 
-               x += (*i)->get_width ();
+               x += s->get_width ();
        }
 }
 
+Gtk::Menu*
+MixerGroupTabs::get_menu (RouteGroup* g)
+{
+       if (g == 0) {
+               return 0;
+       }
+       
+       using namespace Menu_Helpers;
+       
+       delete _menu;
+       _menu = new Menu;
+       
+       MenuList& items = _menu->items ();
+       items.push_back (MenuElem (_("Edit..."), bind (mem_fun (*this, &MixerGroupTabs::edit_group), g)));
+       items.push_back (MenuElem (_("Remove"), bind (mem_fun (*this, &MixerGroupTabs::remove_group), g)));
+
+       return _menu;
+}
+
+void
+MixerGroupTabs::edit_group (RouteGroup* g)
+{
+       RouteGroupDialog d (g, Gtk::Stock::APPLY);
+       d.do_run ();
+}
+
+void
+MixerGroupTabs::remove_group (RouteGroup *g)
+{
+       _session->remove_route_group (*g);
+}