Normalize XML property name style, preserving old session loading (on load _ will...
[ardour.git] / gtk2_ardour / midi_time_axis.cc
index 8d1f46d55a303dc10d9f2ebeebe087927316ee4b..9453a05611c45ec4e7efdce44efbfc55190163fa 100644 (file)
@@ -80,7 +80,10 @@ using namespace PBD;
 using namespace Gtk;
 using namespace sigc;
 using namespace Editing;
-
+       
+// Minimum height at which a control is displayed
+static const uint32_t CHANNEL_MIN_HEIGHT = 80;
+static const uint32_t KEYBOARD_MIN_HEIGHT = 140;
 
 MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
        : AxisView(sess) // virtually inherited
@@ -91,7 +94,7 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
        , _note_mode(Sustained)
        , _note_mode_item(NULL)
        , _percussion_mode_item(NULL)
-       , _midi_expander("MIDI")
+       , _midi_expander("Channel")
 {
        subplugin_menu.set_name ("ArdourContextMenu");
 
@@ -139,11 +142,11 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
                
        // add channel selector expander
        HBox *channel_selector_box = manage(new HBox());
-       channel_selector_box->pack_start(_channel_selector, SHRINK, 0);
+       channel_selector_box->pack_start(_channel_selector, false, false);
        _midi_expander.add(*channel_selector_box);
        _midi_expander.property_expanded().signal_changed().connect(
                        mem_fun(this, &MidiTimeAxisView::channel_selector_toggled));
-       controls_vbox.pack_end(_midi_expander, SHRINK, 0);
+       controls_vbox.pack_start(_midi_expander, false, false);
        boost::shared_ptr<MidiDiskstream> diskstream = midi_track()->midi_diskstream();
 
        // restore channel selector settings
@@ -172,11 +175,9 @@ guint32
 MidiTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
 {
        ensure_xml_node ();
-       xml_node->add_property ("shown_editor", "yes");
+       xml_node->add_property ("shown-editor", "yes");
                
        guint32 ret = TimeAxisView::show_at (y, nth, parent);
-       _piano_roll_header->show();
-       _range_scroomer->show();
        return ret;
 }
 
@@ -184,7 +185,7 @@ void
 MidiTimeAxisView::hide ()
 {
        ensure_xml_node ();
-       xml_node->add_property ("shown_editor", "no");
+       xml_node->add_property ("shown-editor", "no");
 
        TimeAxisView::hide ();
 }
@@ -194,31 +195,18 @@ MidiTimeAxisView::set_height (uint32_t h)
 {
        RouteTimeAxisView::set_height (h);
 
-       if (height >= hLarger) {
-               _midi_expander.show();
-               if (is_track() && _range_scroomer)
-                       _range_scroomer->show();
-               if (is_track() && _piano_roll_header)
-                       _piano_roll_header->show();
-
-       } else if (height >= hLarge) {
+       if (height >= CHANNEL_MIN_HEIGHT) {
                _midi_expander.show();
-               _midi_expander.set_expanded(FALSE);
+       } else {
+               _midi_expander.hide();
+       }
+       
+       if (height >= KEYBOARD_MIN_HEIGHT) {
                if (is_track() && _range_scroomer)
                        _range_scroomer->show();
                if (is_track() && _piano_roll_header)
                        _piano_roll_header->show();
-
-       } else if (height >= hNormal) {
-               _midi_expander.show();
-               _midi_expander.set_expanded(FALSE);
-               if (is_track() && _range_scroomer)
-                       _range_scroomer->hide();
-               if (is_track() && _piano_roll_header)
-                       _piano_roll_header->hide();
        } else {
-               _midi_expander.hide();
-               _midi_expander.set_expanded(FALSE);
                if (is_track() && _range_scroomer)
                        _range_scroomer->hide();
                if (is_track() && _piano_roll_header)
@@ -263,10 +251,10 @@ MidiTimeAxisView::build_automation_action_menu ()
                        mem_fun(*this, &MidiTimeAxisView::add_cc_track)));
        automation_items.push_back (MenuElem (_("Bender"), 
                        sigc::bind(mem_fun(*this, &MidiTimeAxisView::add_parameter_track),
-                               Parameter(MidiPitchBenderAutomation))));
+                               Evoral::Parameter(MidiPitchBenderAutomation))));
        automation_items.push_back (MenuElem (_("Pressure"), 
                        sigc::bind(mem_fun(*this, &MidiTimeAxisView::add_parameter_track),
-                               Parameter(MidiChannelPressureAutomation))));
+                               Evoral::Parameter(MidiChannelPressureAutomation))));
 
 }
 
@@ -328,10 +316,10 @@ void
 MidiTimeAxisView::show_all_automation ()
 {
        if (midi_track()) {
-               const set<Parameter> params = midi_track()->midi_diskstream()->
+               const set<Evoral::Parameter> params = midi_track()->midi_diskstream()->
                                midi_playlist()->contained_automation();
 
-               for (set<Parameter>::const_iterator i = params.begin(); i != params.end(); ++i) {
+               for (set<Evoral::Parameter>::const_iterator i = params.begin(); i != params.end(); ++i) {
                        create_automation_child(*i, true);
                }
        }
@@ -343,10 +331,10 @@ void
 MidiTimeAxisView::show_existing_automation ()
 {
        if (midi_track()) {
-               const set<Parameter> params = midi_track()->midi_diskstream()->
+               const set<Evoral::Parameter> params = midi_track()->midi_diskstream()->
                                midi_playlist()->contained_automation();
 
-               for (set<Parameter>::const_iterator i = params.begin(); i != params.end(); ++i) {
+               for (set<Evoral::Parameter>::const_iterator i = params.begin(); i != params.end(); ++i) {
                        create_automation_child(*i, true);
                }
        }
@@ -360,7 +348,7 @@ void
 MidiTimeAxisView::add_cc_track()
 {
        int response;
-       Parameter param;
+       Evoral::Parameter param(0, 0, 0);
 
        {
                AddMidiCCTrackDialog dialog;
@@ -371,7 +359,7 @@ MidiTimeAxisView::add_cc_track()
                        param = dialog.parameter();
        }
 
-       if (response == Gtk::RESPONSE_ACCEPT)
+       if (param.type() != 0 && response == Gtk::RESPONSE_ACCEPT)
                create_automation_child(param, true);
 }
 
@@ -379,13 +367,13 @@ MidiTimeAxisView::add_cc_track()
 /** Add an automation track for the given parameter (pitch bend, channel pressure).
  */
 void
-MidiTimeAxisView::add_parameter_track(const Parameter& param)
+MidiTimeAxisView::add_parameter_track(const Evoral::Parameter& param)
 {
        create_automation_child(param, true);
 }
 
 void
-MidiTimeAxisView::create_automation_child (const Parameter& param, bool show)
+MidiTimeAxisView::create_automation_child (const Evoral::Parameter& param, bool show)
 {
        if (    param.type() == MidiCCAutomation ||
                        param.type() == MidiPgmChangeAutomation ||
@@ -419,7 +407,8 @@ MidiTimeAxisView::create_automation_child (const Parameter& param, bool show)
                add_automation_child(param, track, show);
 
        } else {
-               error << "MidiTimeAxisView: unknown automation child " << param.symbol() << endmsg;
+               error << "MidiTimeAxisView: unknown automation child "
+                       << ARDOUR::EventTypeMap::instance().to_symbol(param) << endmsg;
        }
 }
 
@@ -459,16 +448,12 @@ MidiTimeAxisView::channel_selector_toggled()
 {
        static uint32_t previous_height;
        
-       if(_midi_expander.property_expanded()) {
-
+       if (_midi_expander.property_expanded()) {
                previous_height = current_height();
-
                if (previous_height < TimeAxisView::hLargest) {
                        set_height (TimeAxisView::hLarge);
                }
-
        } else {
-
                set_height (previous_height);
        }
 }