fixes for 2 of 3 "fit-tracks" problems; new feature: 12 "view-states" and bindings...
[ardour.git] / gtk2_ardour / audio_time_axis.cc
index 8484bbceca93100e52f7801624adec550e66b136..18a0d12199bd7fc9893fc58febff652a3112b408 100644 (file)
@@ -43,6 +43,7 @@
 #include <ardour/location.h>
 #include <ardour/panner.h>
 #include <ardour/playlist.h>
+#include <ardour/profile.h>
 #include <ardour/session.h>
 #include <ardour/session_playlist.h>
 #include <ardour/utils.h>
@@ -74,7 +75,6 @@ using namespace PBD;
 using namespace Gtk;
 using namespace Editing;
 
-
 AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
        : AxisView(sess)
        , RouteTimeAxisView(ed, sess, rt, canvas)
@@ -113,16 +113,29 @@ AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
 
                /* ask for notifications of any new RegionViews */
                _view->RegionViewAdded.connect (mem_fun(*this, &AudioTimeAxisView::region_view_added));
-               _view->attach ();
-       }
 
-       post_construct ();
+               if (!editor.have_idled()) {
+                       /* first idle will do what we need */
+               } else {
+                       first_idle ();
+               } 
+
+       } else {
+               post_construct ();
+       }
 }
 
 AudioTimeAxisView::~AudioTimeAxisView ()
 {
 }
 
+void
+AudioTimeAxisView::first_idle ()
+{
+       _view->attach ();
+       post_construct ();
+}
+
 AudioStreamView*
 AudioTimeAxisView::audio_view()
 {
@@ -147,21 +160,30 @@ AudioTimeAxisView::hide ()
        TimeAxisView::hide ();
 }
 
-void
+int
 AudioTimeAxisView::set_state (const XMLNode& node)
 {
        const XMLProperty *prop;
-       
-       TimeAxisView::set_state (node);
-       
-       if ((prop = node.property ("shown_editor")) != 0) {
-               if (prop->value() == "no") {
-                       _marked_for_display = false;
+       int ret;
+
+       if ((ret = TimeAxisView::set_state (node)) != 0) {
+               return ret;
+       }
+
+       /* if the TimeAxisView had marked this not for display,
+          then do not allow this to override it.
+       */
+
+       if ((prop = node.property ("marked_for_display")) == 0) {
+               if ((prop = node.property ("shown_editor")) != 0) {
+                       if (prop->value() == "no") {
+                               _marked_for_display = false;
+                       } else {
+                               _marked_for_display = true;
+                       }
                } else {
                        _marked_for_display = true;
                }
-       } else {
-               _marked_for_display = true;
        }
        
        XMLNodeList nlist = node.children();
@@ -197,6 +219,8 @@ AudioTimeAxisView::set_state (const XMLNode& node)
                        continue;
                }
        }
+
+       return 0;
 }
 
 void
@@ -230,8 +254,10 @@ AudioTimeAxisView::append_extra_display_menu_items ()
        MenuList& items = display_menu->items();
 
        // crossfade stuff
-       items.push_back (MenuElem (_("Hide all crossfades"), mem_fun(*this, &AudioTimeAxisView::hide_all_xfades)));
-       items.push_back (MenuElem (_("Show all crossfades"), mem_fun(*this, &AudioTimeAxisView::show_all_xfades)));
+       if (!Profile->get_sae()) {
+               items.push_back (MenuElem (_("Hide all crossfades"), mem_fun(*this, &AudioTimeAxisView::hide_all_xfades)));
+               items.push_back (MenuElem (_("Show all crossfades"), mem_fun(*this, &AudioTimeAxisView::show_all_xfades)));
+       }
 
        // waveform menu
        Menu *waveform_menu = manage(new Menu);
@@ -251,8 +277,12 @@ AudioTimeAxisView::append_extra_display_menu_items ()
        waveform_items.push_back (RadioMenuElem (group, _("Traditional"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Traditional)));
        traditional_item = static_cast<RadioMenuItem *> (&waveform_items.back());
 
-       waveform_items.push_back (RadioMenuElem (group, _("Rectified"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Rectified)));
-       rectified_item = static_cast<RadioMenuItem *> (&waveform_items.back());
+       if (!Profile->get_sae()) {
+               waveform_items.push_back (RadioMenuElem (group, _("Rectified"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Rectified)));
+               rectified_item = static_cast<RadioMenuItem *> (&waveform_items.back());
+       } else {
+               rectified_item = 0;
+       }
 
        waveform_items.push_back (SeparatorElem());
        
@@ -268,9 +298,11 @@ AudioTimeAxisView::append_extra_display_menu_items ()
        AudioStreamView* asv = audio_view();
        if (asv) {
                ignore_toggle = true;
-               if (asv->get_waveform_shape() == Rectified
+               if (asv->get_waveform_shape() == Rectified && rectified_item) {
                        rectified_item->set_active(true);
-               else traditional_item->set_active(true);
+               } else {
+                       traditional_item->set_active(true);
+               }
 
                if (asv->get_waveform_scale() == LogWaveform) 
                        logscale_item->set_active(true);
@@ -359,7 +391,7 @@ AudioTimeAxisView::add_gain_automation_child ()
                                       *gain_track->canvas_display,
                                       _route->gain_automation_curve());
 
-       line->set_line_color (color_map[cAutomationLine]);
+       line->set_line_color (ARDOUR_UI::config()->canvasvar_AutomationLine.get());
        
 
        gain_track->add_line (*line);
@@ -439,11 +471,9 @@ AudioTimeAxisView::update_pans ()
                                              (*p)->automation());
 
                if (p == _route->panner().begin()) {
-                       /* first line is a nice orange */
-                       line->set_line_color (color_map[cLeftPanAutomationLine]);
+                       line->set_line_color (ARDOUR_UI::config()->canvasvar_AutomationLine.get());
                } else {
-                       /* second line is a nice blue */
-                       line->set_line_color (color_map[cRightPanAutomationLine]);
+                       line->set_line_color (ARDOUR_UI::config()->canvasvar_AutomationLine.get());
                }
 
                pan_track->add_line (*line);
@@ -453,7 +483,6 @@ AudioTimeAxisView::update_pans ()
 void
 AudioTimeAxisView::toggle_gain_track ()
 {
-
        bool showit = gain_automation_item->get_active();
 
        if (showit != gain_track->marked_for_display()) {
@@ -470,7 +499,7 @@ AudioTimeAxisView::toggle_gain_track ()
                /* now trigger a redisplay */
                
                if (!no_redraw) {
-                        _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
+                        _route->gui_changed (X_("visible_tracks"), (void *) 0); /* EMIT_SIGNAL */
                }
        }
 }
@@ -484,7 +513,7 @@ AudioTimeAxisView::gain_hidden ()
                gain_automation_item->set_active (false);
        }
 
-        _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+        _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
 }
 
 void
@@ -506,7 +535,7 @@ AudioTimeAxisView::toggle_pan_track ()
                /* now trigger a redisplay */
                
                if (!no_redraw) {
-                        _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+                        _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
                }
        }
 }
@@ -520,7 +549,7 @@ AudioTimeAxisView::pan_hidden ()
                pan_automation_item->set_active (false);
        }
 
-        _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+        _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
 }
 
 void
@@ -535,7 +564,7 @@ AudioTimeAxisView::show_all_automation ()
 
        no_redraw = false;
 
-        _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+        _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
 }
 
 void
@@ -550,7 +579,7 @@ AudioTimeAxisView::show_existing_automation ()
 
        no_redraw = false;
 
-        _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+        _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
 }
 
 void
@@ -564,7 +593,7 @@ AudioTimeAxisView::hide_all_automation ()
        RouteTimeAxisView::hide_all_automation();
 
        no_redraw = false;
-        _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
+        _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
 }
 
 void
@@ -628,25 +657,27 @@ AudioTimeAxisView::update_control_names ()
 {
        if (is_audio_track()) {
                if (_route->active()) {
-                       controls_ebox.set_name ("AudioTrackControlsBaseUnselected");
                        controls_base_selected_name = "AudioTrackControlsBaseSelected";
                        controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
                } else {
-                       controls_ebox.set_name ("AudioTrackControlsBaseInactiveUnselected");
                        controls_base_selected_name = "AudioTrackControlsBaseInactiveSelected";
                        controls_base_unselected_name = "AudioTrackControlsBaseInactiveUnselected";
                }
        } else {
                if (_route->active()) {
-                       controls_ebox.set_name ("BusControlsBaseUnselected");
                        controls_base_selected_name = "BusControlsBaseSelected";
                        controls_base_unselected_name = "BusControlsBaseUnselected";
                } else {
-                       controls_ebox.set_name ("BusControlsBaseInactiveUnselected");
                        controls_base_selected_name = "BusControlsBaseInactiveSelected";
                        controls_base_unselected_name = "BusControlsBaseInactiveUnselected";
                }
        }
+
+       if (get_selected()) {
+               controls_ebox.set_name (controls_base_selected_name);
+       } else {
+               controls_ebox.set_name (controls_base_unselected_name);
+       }
 }
 
 XMLNode*