Remove no-longer-needed file.
[ardour.git] / gtk2_ardour / midi_time_axis.cc
index d518f285ee38bcbc65b62b9d0c61d32b3d3de4e5..f449dcaef05b6db1d745990e64d196bf531689bf 100644 (file)
 
 #include "midi++/names.h"
 
-#include "add_midi_cc_track_dialog.h"
 #include "ardour_ui.h"
 #include "ardour_button.h"
 #include "automation_line.h"
 #include "automation_time_axis.h"
 #include "canvas-note-event.h"
 #include "canvas_impl.h"
-#include "crossfade_view.h"
 #include "editor.h"
 #include "enums.h"
 #include "ghostregion.h"
@@ -124,11 +122,25 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, Canvas& can
 void
 MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
 {
+       _route = rt;
+       
+       _view = new MidiStreamView (*this);
+       
+       if (is_track ()) {
+               _piano_roll_header = new PianoRollHeader(*midi_view());
+               _range_scroomer = new MidiScroomer(midi_view()->note_range_adjustment);
+       }
+
+       /* This next call will result in our height being set up, so it must come after
+          the creation of the piano roll / range scroomer as their visibility is set up
+          when our height is.
+       */
        RouteTimeAxisView::set_route (rt);
 
+       _view->apply_color (_color, StreamView::RegionColor);
+
        subplugin_menu.set_name ("ArdourContextMenu");
 
-       _view = new MidiStreamView (*this);
        if (!gui_property ("note-range-min").empty ()) {
                midi_view()->apply_note_range (atoi (gui_property ("note-range-min").c_str()), atoi (gui_property ("note-range-max").c_str()), true);
        }
@@ -136,9 +148,6 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
 
        ignore_toggle = false;
 
-       mute_button->unset_active_state ();
-       solo_button->set_active (false);
-
        if (is_midi_track()) {
                controls_ebox.set_name ("MidiTimeAxisViewControlsBaseUnselected");
                _note_mode = midi_track()->note_mode();
@@ -153,14 +162,11 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
        _route->processors_changed.connect (*this, invalidator (*this), ui_bind (&MidiTimeAxisView::processors_changed, this, _1), gui_context());
 
        if (is_track()) {
-               _piano_roll_header = new PianoRollHeader(*midi_view());
-
+               _piano_roll_header->SetNoteSelection.connect (sigc::mem_fun (*this, &MidiTimeAxisView::set_note_selection));
                _piano_roll_header->AddNoteSelection.connect (sigc::mem_fun (*this, &MidiTimeAxisView::add_note_selection));
                _piano_roll_header->ExtendNoteSelection.connect (sigc::mem_fun (*this, &MidiTimeAxisView::extend_note_selection));
                _piano_roll_header->ToggleNoteSelection.connect (sigc::mem_fun (*this, &MidiTimeAxisView::toggle_note_selection));
 
-               _range_scroomer = new MidiScroomer(midi_view()->note_range_adjustment);
-
                /* Suspend updates of the StreamView during scroomer drags to speed things up */
                _range_scroomer->DragStarting.connect (sigc::mem_fun (*midi_view(), &MidiStreamView::suspend_updates));
                _range_scroomer->DragFinishing.connect (sigc::mem_fun (*midi_view(), &MidiStreamView::resume_updates));
@@ -240,16 +246,16 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
        /* Look for any GUI object state nodes that represent automation children that should exist, and create
         * the children.
         */
-       
-       GUIObjectState& gui_state = gui_object_state ();
-       for (GUIObjectState::StringPropertyMap::const_iterator i = gui_state.begin(); i != gui_state.end(); ++i) {
+
+       list<string> gui_ids = gui_object_state().all_ids ();
+       for (list<string>::const_iterator i = gui_ids.begin(); i != gui_ids.end(); ++i) {
                PBD::ID route_id;
                bool has_parameter;
                Evoral::Parameter parameter (0, 0, 0);
 
-               bool const p = AutomationTimeAxisView::parse_state_id (i->first, route_id, has_parameter, parameter);
+               bool const p = AutomationTimeAxisView::parse_state_id (*i, route_id, has_parameter, parameter);
                if (p && route_id == _route->id () && has_parameter) {
-                       create_automation_child (parameter, string_is_affirmative (gui_object_state().get_string (i->first, X_("visible"))));
+                       create_automation_child (parameter, string_is_affirmative (gui_object_state().get_string (*i, X_("visible"))));
                }
        }
 }
@@ -329,15 +335,13 @@ MidiTimeAxisView::midi_view()
 void
 MidiTimeAxisView::set_height (uint32_t h)
 {
-       RouteTimeAxisView::set_height (h);
-
-       if (height >= MIDI_CONTROLS_BOX_MIN_HEIGHT) {
+       if (h >= MIDI_CONTROLS_BOX_MIN_HEIGHT) {
                _midi_controls_box.show_all ();
        } else {
                _midi_controls_box.hide();
        }
        
-       if (height >= KEYBOARD_MIN_HEIGHT) {
+       if (h >= KEYBOARD_MIN_HEIGHT) {
                if (is_track() && _range_scroomer) {
                        _range_scroomer->show();
                }
@@ -352,6 +356,13 @@ MidiTimeAxisView::set_height (uint32_t h)
                        _piano_roll_header->hide();
                }
        }
+
+       /* We need to do this after changing visibility of our stuff, as it will
+          eventually trigger a call to Editor::reset_controls_layout_width(),
+          which needs to know if we have just shown or hidden a scroomer /
+          piano roll.
+       */
+       RouteTimeAxisView::set_height (h);
 }
 
 void
@@ -952,7 +963,21 @@ MidiTimeAxisView::route_active_changed ()
        }
 }
 
+void
+MidiTimeAxisView::set_note_selection (uint8_t note)
+{
+       if (!_editor.internal_editing()) {
+               return;
+       }
+
+       uint16_t chn_mask = _channel_selector.get_selected_channels();
 
+       if (_view->num_selected_regionviews() == 0) {
+               _view->foreach_regionview (sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_note_selection_region_view), note, chn_mask));
+       } else {
+               _view->foreach_selected_regionview (sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_note_selection_region_view), note, chn_mask));
+       }
+}
 
 void
 MidiTimeAxisView::add_note_selection (uint8_t note)
@@ -1003,11 +1028,17 @@ MidiTimeAxisView::toggle_note_selection (uint8_t note)
 }
 
 void
-MidiTimeAxisView::add_note_selection_region_view (RegionView* rv, uint8_t note, uint16_t chn_mask)
+MidiTimeAxisView::set_note_selection_region_view (RegionView* rv, uint8_t note, uint16_t chn_mask)
 {
        dynamic_cast<MidiRegionView*>(rv)->select_matching_notes (note, chn_mask, false, false);
 }
 
+void
+MidiTimeAxisView::add_note_selection_region_view (RegionView* rv, uint8_t note, uint16_t chn_mask)
+{
+       dynamic_cast<MidiRegionView*>(rv)->select_matching_notes (note, chn_mask, true, false);
+}
+
 void
 MidiTimeAxisView::extend_note_selection_region_view (RegionView* rv, uint8_t note, uint16_t chn_mask)
 {