new solo safe/lock button image from oofus (a tad ugly, dare might i say)
[ardour.git] / gtk2_ardour / editor_routes.cc
index a8fbb58d324dd826d345f0192fe7cf84c2660412..940030bc4d11d4de79828e8e5b459ec85de8401a 100644 (file)
@@ -68,6 +68,8 @@ EditorRoutes::EditorRoutes (Editor* e)
         , selection_countdown (0)
         , name_editable (0)
 {
+       static const int column_width = 22;
+
        _scroller.add (_display);
        _scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
 
@@ -77,10 +79,10 @@ EditorRoutes::EditorRoutes (Editor* e)
        // Record enable toggle
        CellRendererPixbufMulti* rec_col_renderer = manage (new CellRendererPixbufMulti());
 
-       rec_col_renderer->set_pixbuf (0, ::get_icon("act-disabled"));
-       rec_col_renderer->set_pixbuf (1, ::get_icon("rec-in-progress"));
-       rec_col_renderer->set_pixbuf (2, ::get_icon("rec-enabled"));
-       rec_col_renderer->set_pixbuf (3, ::get_icon("step-editing"));
+       rec_col_renderer->set_pixbuf (0, ::get_icon("record-normal-disabled"));
+       rec_col_renderer->set_pixbuf (1, ::get_icon("record-normal-in-progress"));
+       rec_col_renderer->set_pixbuf (2, ::get_icon("record-normal-enabled"));
+       rec_col_renderer->set_pixbuf (3, ::get_icon("record-step"));
        rec_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_enable_changed));
 
        TreeViewColumn* rec_state_column = manage (new TreeViewColumn("R", *rec_col_renderer));
@@ -91,13 +93,13 @@ EditorRoutes::EditorRoutes (Editor* e)
        rec_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
        rec_state_column->set_alignment(ALIGN_CENTER);
        rec_state_column->set_expand(false);
-       rec_state_column->set_fixed_width(15);
+       rec_state_column->set_fixed_width(column_width);
 
        // MIDI Input Active
 
        CellRendererPixbufMulti* input_active_col_renderer = manage (new CellRendererPixbufMulti());
-       input_active_col_renderer->set_pixbuf (0, ::get_icon("midi_socket_small"));
-       input_active_col_renderer->set_pixbuf (1, ::get_icon("midi_socket_small"));
+       input_active_col_renderer->set_pixbuf (0, ::get_icon("midi-input-inactive"));
+       input_active_col_renderer->set_pixbuf (1, ::get_icon("midi-input-active"));
        input_active_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_input_active_changed));
 
        TreeViewColumn* input_active_column = manage (new TreeViewColumn ("I", *input_active_col_renderer));
@@ -108,14 +110,14 @@ EditorRoutes::EditorRoutes (Editor* e)
        input_active_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
        input_active_column->set_alignment(ALIGN_CENTER);
        input_active_column->set_expand(false);
-       input_active_column->set_fixed_width(20);
+       input_active_column->set_fixed_width(column_width);
 
        // Mute enable toggle
        CellRendererPixbufMulti* mute_col_renderer = manage (new CellRendererPixbufMulti());
 
-       mute_col_renderer->set_pixbuf (0, ::get_icon("act-disabled"));
-       mute_col_renderer->set_pixbuf (1, ::get_icon("muted-by-others"));
-       mute_col_renderer->set_pixbuf (2, ::get_icon("mute-enabled"));
+       mute_col_renderer->set_pixbuf (ActiveState(0), ::get_icon("mute-disabled"));
+       mute_col_renderer->set_pixbuf (Mid, ::get_icon("muted-by-others"));
+       mute_col_renderer->set_pixbuf (Active, ::get_icon("mute-enabled"));
        mute_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_mute_enable_toggled));
 
        TreeViewColumn* mute_state_column = manage (new TreeViewColumn("M", *mute_col_renderer));
@@ -129,7 +131,7 @@ EditorRoutes::EditorRoutes (Editor* e)
        // Solo enable toggle
        CellRendererPixbufMulti* solo_col_renderer = manage (new CellRendererPixbufMulti());
 
-       solo_col_renderer->set_pixbuf (0, ::get_icon("act-disabled"));
+       solo_col_renderer->set_pixbuf (0, ::get_icon("solo-disabled"));
        solo_col_renderer->set_pixbuf (1, ::get_icon("solo-enabled"));
        solo_col_renderer->set_pixbuf (3, ::get_icon("soloed-by-others"));
        solo_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_enable_toggled));
@@ -140,13 +142,13 @@ EditorRoutes::EditorRoutes (Editor* e)
        solo_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
        solo_state_column->set_alignment(ALIGN_CENTER);
        solo_state_column->set_expand(false);
-       solo_state_column->set_fixed_width(15);
+       solo_state_column->set_fixed_width(column_width);
 
        // Solo isolate toggle
        CellRendererPixbufMulti* solo_iso_renderer = manage (new CellRendererPixbufMulti());
 
-       solo_iso_renderer->set_pixbuf (0, ::get_icon("act-disabled"));
-       solo_iso_renderer->set_pixbuf (1, ::get_icon("solo-isolated"));
+       solo_iso_renderer->set_pixbuf (0, ::get_icon("solo-isolate-disabled"));
+       solo_iso_renderer->set_pixbuf (1, ::get_icon("solo-isolate-enabled"));
        solo_iso_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_isolate_toggled));
 
        TreeViewColumn* solo_isolate_state_column = manage (new TreeViewColumn("SI", *solo_iso_renderer));
@@ -155,13 +157,13 @@ EditorRoutes::EditorRoutes (Editor* e)
        solo_isolate_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
        solo_isolate_state_column->set_alignment(ALIGN_CENTER);
        solo_isolate_state_column->set_expand(false);
-       solo_isolate_state_column->set_fixed_width(22);
+       solo_isolate_state_column->set_fixed_width(column_width);
 
        // Solo safe toggle
        CellRendererPixbufMulti* solo_safe_renderer = manage (new CellRendererPixbufMulti ());
 
-       solo_safe_renderer->set_pixbuf (0, ::get_icon("act-disabled"));
-       solo_safe_renderer->set_pixbuf (1, ::get_icon("solo-enabled"));
+       solo_safe_renderer->set_pixbuf (0, ::get_icon("solo-safe-disabled"));
+       solo_safe_renderer->set_pixbuf (1, ::get_icon("solo-safe-enabled"));
        solo_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_safe_toggled));
 
        TreeViewColumn* solo_safe_state_column = manage (new TreeViewColumn(_("SS"), *solo_safe_renderer));
@@ -169,7 +171,7 @@ EditorRoutes::EditorRoutes (Editor* e)
        solo_safe_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
        solo_safe_state_column->set_alignment(ALIGN_CENTER);
        solo_safe_state_column->set_expand(false);
-       solo_safe_state_column->set_fixed_width(22);
+       solo_safe_state_column->set_fixed_width(column_width);
 
        _display.append_column (*input_active_column);
        _display.append_column (*rec_state_column);
@@ -180,6 +182,7 @@ EditorRoutes::EditorRoutes (Editor* e)
 
         _name_column = _display.append_column (_("Name"), _columns.text) - 1;
        _visible_column = _display.append_column (_("V"), _columns.visible) - 1;
+       _active_column = _display.append_column (_("A"), _columns.active) - 1;
 
        _display.set_headers_visible (true);
        _display.set_name ("TrackListDisplay");
@@ -220,6 +223,18 @@ EditorRoutes::EditorRoutes (Editor* e)
        visible_col->set_fixed_width(30);
        visible_col->set_alignment(ALIGN_CENTER);
 
+       CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_active_column));
+
+       active_cell->property_activatable() = true;
+       active_cell->property_radio() = false;
+       active_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::active_changed));
+
+       TreeViewColumn* active_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_active_column));
+       active_col->set_expand (false);
+       active_col->set_sizing (TREE_VIEW_COLUMN_FIXED);
+       active_col->set_fixed_width (30);
+       active_col->set_alignment (ALIGN_CENTER);
+       
        _model->signal_row_deleted().connect (sigc::mem_fun (*this, &EditorRoutes::route_deleted));
        _model->signal_rows_reordered().connect (sigc::mem_fun (*this, &EditorRoutes::reordered));
 
@@ -466,21 +481,19 @@ EditorRoutes::redisplay ()
                        route->set_order_key (N_ ("editor"), n);
                }
 
-               bool visible = (*i)[_columns.visible];
+               bool visible = tv->marked_for_display ();
 
                /* show or hide the TimeAxisView */
                if (visible) {
-                       tv->set_marked_for_display (true);
                        position += tv->show_at (position, n, &_editor->edit_controls_vbox);
                        tv->clip_to_viewport ();
                } else {
-                       tv->set_visibility (false);
+                       tv->hide ();
                }
 
                n++;
        }
 
-
        /* whenever we go idle, update the track view list to reflect the new order.
           we can't do this here, because we could mess up something that is traversing
           the track order and has caused a redisplay of the list.
@@ -532,14 +545,29 @@ EditorRoutes::visible_changed (std::string const & path)
                TimeAxisView* tv = (*iter)[_columns.tv];
                if (tv) {
                        bool visible = (*iter)[_columns.visible];
-                       (*iter)[_columns.visible] = !visible;
+
+                       if (tv->set_marked_for_display (!visible)) {
+                               _redisplay_does_not_reset_order_keys = true;
+                               _session->set_remote_control_ids();
+                               update_visibility ();
+                               redisplay ();
+                               _redisplay_does_not_reset_order_keys = false;
+                       }
                }
        }
+}
 
-       _redisplay_does_not_reset_order_keys = true;
-       _session->set_remote_control_ids();
-       redisplay ();
-       _redisplay_does_not_reset_order_keys = false;
+void
+EditorRoutes::active_changed (std::string const & path)
+{
+       if (_session && _session->deletion_in_progress ()) {
+               return;
+       }
+
+       Gtk::TreeModel::Row row = *_model->get_iter (path);
+       boost::shared_ptr<Route> route = row[_columns.route];
+       bool const active = row[_columns.active];
+       route->set_active (!active, this);
 }
 
 void
@@ -558,6 +586,7 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
 
                row[_columns.text] = (*x)->route()->name();
                row[_columns.visible] = (*x)->marked_for_display();
+               row[_columns.active] = (*x)->route()->active ();
                row[_columns.tv] = *x;
                row[_columns.route] = (*x)->route ();
                row[_columns.is_track] = (boost::dynamic_pointer_cast<Track> ((*x)->route()) != 0);
@@ -570,7 +599,7 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
                        row[_columns.is_midi] = false;
                }
 
-               row[_columns.mute_state] = (*x)->route()->muted();
+               row[_columns.mute_state] = (*x)->route()->muted() ? Active : ActiveState (0);
                row[_columns.solo_state] = RouteUI::solo_visual_state ((*x)->route());
                row[_columns.solo_isolate_state] = (*x)->route()->solo_isolated();
                row[_columns.solo_safe_state] = (*x)->route()->solo_safe();
@@ -606,6 +635,7 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
                (*x)->route()->listen_changed.connect (*this, MISSING_INVALIDATOR, ui_bind (&EditorRoutes::update_solo_display, this, _1), gui_context());
                (*x)->route()->solo_isolated_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_isolate_display, this), gui_context());
                (*x)->route()->solo_safe_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_safe_display, this), gui_context());
+               (*x)->route()->active_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_active_display, this), gui_context ());
        }
 
        update_rec_display ();
@@ -614,6 +644,7 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
        update_solo_isolate_display ();
        update_solo_safe_display ();
        update_input_active_display ();
+       update_active_display ();
        resume_redisplay ();
        _redisplay_does_not_sync_order_keys = false;
 }
@@ -687,6 +718,18 @@ EditorRoutes::route_property_changed (const PropertyChange& what_changed, boost:
        }
 }
 
+void
+EditorRoutes::update_active_display ()
+{
+       TreeModel::Children rows = _model->children();
+       TreeModel::Children::iterator i;
+
+       for (i = rows.begin(); i != rows.end(); ++i) {
+               boost::shared_ptr<Route> route = (*i)[_columns.route];
+               (*i)[_columns.active] = route->active ();
+       }
+}
+
 void
 EditorRoutes::update_visibility ()
 {
@@ -698,7 +741,6 @@ EditorRoutes::update_visibility ()
        for (i = rows.begin(); i != rows.end(); ++i) {
                TimeAxisView *tv = (*i)[_columns.tv];
                (*i)[_columns.visible] = tv->marked_for_display ();
-               cerr << "marked " << tv->name() << " for display = " << tv->marked_for_display() << endl;
        }
 
        resume_redisplay ();
@@ -712,12 +754,12 @@ EditorRoutes::hide_track_in_display (TimeAxisView& tv)
 
        for (i = rows.begin(); i != rows.end(); ++i) {
                if ((*i)[_columns.tv] == &tv) {
+                       tv.set_marked_for_display (false);
                        (*i)[_columns.visible] = false;
+                       redisplay ();
                        break;
                }
        }
-
-       redisplay ();
 }
 
 void
@@ -726,14 +768,15 @@ EditorRoutes::show_track_in_display (TimeAxisView& tv)
        TreeModel::Children rows = _model->children();
        TreeModel::Children::iterator i;
 
+
        for (i = rows.begin(); i != rows.end(); ++i) {
                if ((*i)[_columns.tv] == &tv) {
+                       tv.set_marked_for_display (true);
                        (*i)[_columns.visible] = true;
+                       redisplay ();
                        break;
                }
        }
-
-       redisplay ();
 }
 
 void
@@ -781,6 +824,8 @@ EditorRoutes::sync_order_keys (string const & src)
                        co.push_back (i->second);
                }
 
+               assert (co.size() == _model->children().size ());
+
                _model->reorder (co);
                _redisplay_does_not_reset_order_keys = false;
        }
@@ -1339,7 +1384,7 @@ EditorRoutes::update_mute_display ()
 
        for (i = rows.begin(); i != rows.end(); ++i) {
                boost::shared_ptr<Route> route = (*i)[_columns.route];
-               (*i)[_columns.mute_state] = RouteUI::mute_visual_state (_session, route);
+               (*i)[_columns.mute_state] = RouteUI::mute_active_state (_session, route);
        }
 }