Fix crash when adding automation tracks caused by route ordering.
[ardour.git] / gtk2_ardour / time_axis_view.cc
index be3c0655b83646f9704d5799614f9ecb6a033470..56f23a0ac2daacc2f94660c51516c5a8411ba2a8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000 Paul Davis 
+    Copyright (C) 2000 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 #include <libgnomecanvasmm/canvas.h>
 #include <libgnomecanvasmm/item.h>
 
-#include <pbd/error.h>
+#include "pbd/error.h"
 
 #include <gtkmm2ext/utils.h>
 #include <gtkmm2ext/selector.h>
 #include <gtkmm2ext/stop_signal.h>
 
-#include <ardour/session.h>
-#include <ardour/utils.h>
-#include <ardour/ladspa_plugin.h>
-#include <ardour/processor.h>
-#include <ardour/location.h>
+#include "ardour/session.h"
+#include "ardour/utils.h"
+#include "ardour/ladspa_plugin.h"
+#include "ardour/processor.h"
+#include "ardour/location.h"
 
 #include "ardour_ui.h"
 #include "public_editor.h"
 
 #include "i18n.h"
 
+using namespace std;
 using namespace Gtk;
 using namespace Gdk;
-using namespace sigc; 
+using namespace sigc;
 using namespace ARDOUR;
 using namespace PBD;
 using namespace Editing;
@@ -73,8 +74,8 @@ uint32_t TimeAxisView::hSmall = 0;
 bool TimeAxisView::need_size_info = true;
 int const TimeAxisView::_max_order = 512;
 
-TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* rent, Canvas& canvas) 
-       : AxisView (sess), 
+TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* rent, Canvas& /*canvas*/)
+       : AxisView (sess),
          controls_table (2, 8),
          _y_position (0),
          _editor (ed),
@@ -132,6 +133,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie
 
        name_hbox.show ();
 
+       controls_table.set_size_request (200);
        controls_table.set_border_width (2);
        controls_table.set_row_spacings (0);
        controls_table.set_col_spacings (0);
@@ -174,11 +176,6 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie
        controls_hbox.pack_start (controls_ebox,true,true);
        controls_hbox.show ();
 
-       // controls_frame.add (controls_hbox);
-       // controls_frame.set_name ("TimeAxisViewControlsBaseUnselected");
-       // controls_vbox.set_name ("TimeAxisViewControlsBaseUnselected");
-       // controls_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
-
        ColorsChanged.connect (mem_fun (*this, &TimeAxisView::color_handler));
 }
 
@@ -354,7 +351,6 @@ TimeAxisView::hide ()
 
        _canvas_display->hide ();
        _canvas_background->hide ();
-       controls_frame.hide ();
 
        if (control_parent) {
                control_parent->remove (controls_hbox);
@@ -435,7 +431,7 @@ TimeAxisView::name_entry_key_release (GdkEventKey* ev)
                return true;
 
        /* Shift+Tab Keys Pressed. Note that for Shift+Tab, GDK actually
-        * generates a different ev->keyval, rather than setting 
+        * generates a different ev->keyval, rather than setting
         * ev->state.
         */
        case GDK_ISO_Left_Tab:
@@ -478,7 +474,7 @@ TimeAxisView::name_entry_key_release (GdkEventKey* ev)
                break;
        }
 
-#ifdef TIMEOUT_NAME_EDIT       
+#ifdef TIMEOUT_NAME_EDIT
        /* adapt the timeout to reflect the user's typing speed */
 
        guint32 name_entry_timeout;
@@ -503,7 +499,7 @@ TimeAxisView::name_entry_key_release (GdkEventKey* ev)
 }
 
 bool
-TimeAxisView::name_entry_focus_in (GdkEventFocus* ev)
+TimeAxisView::name_entry_focus_in (GdkEventFocus*)
 {
        name_entry.select_region (0, -1);
        name_entry.set_name ("EditorActiveTrackNameDisplay");
@@ -511,7 +507,7 @@ TimeAxisView::name_entry_focus_in (GdkEventFocus* ev)
 }
 
 bool
-TimeAxisView::name_entry_focus_out (GdkEventFocus* ev)
+TimeAxisView::name_entry_focus_out (GdkEventFocus*)
 {
        /* clean up */
 
@@ -582,7 +578,7 @@ TimeAxisView::popup_display_menu (guint32 when)
        }
 
        conditionally_add_to_selection ();
-       display_menu->popup (1, when);  
+       display_menu->popup (1, when);
 }
 
 gint
@@ -875,7 +871,7 @@ TimeAxisView::get_selection_rect (uint32_t id)
                rect->rect->signal_event().connect (bind (mem_fun (_editor, &PublicEditor::canvas_selection_rect_event), rect->rect, rect));
                rect->start_trim->signal_event().connect (bind (mem_fun (_editor, &PublicEditor::canvas_selection_start_trim_event), rect->rect, rect));
                rect->end_trim->signal_event().connect (bind (mem_fun (_editor, &PublicEditor::canvas_selection_end_trim_event), rect->rect, rect));
-       } 
+       }
 
        rect = free_selection_rects.front();
        rect->id = id;
@@ -908,13 +904,13 @@ TimeAxisView::remove_child (boost::shared_ptr<TimeAxisView> child)
 }
 
 void
-TimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& result)
+TimeAxisView::get_selectables (nframes_t /*start*/, nframes_t /*end*/, double /*top*/, double /*bot*/, list<Selectable*>& /*result*/)
 {
        return;
 }
 
 void
-TimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
+TimeAxisView::get_inverted_selectables (Selection& /*sel*/, list<Selectable*>& /*result*/)
 {
        return;
 }
@@ -959,11 +955,11 @@ TimeAxisView::touched (double top, double bot)
        */
 
        double mybot = _y_position + current_height();
-       
-       return ((_y_position <= bot && _y_position >= top) || 
-               ((mybot <= bot) && (top < mybot)) || 
+
+       return ((_y_position <= bot && _y_position >= top) ||
+               ((mybot <= bot) && (top < mybot)) ||
                (mybot >= bot && _y_position < top));
-}              
+}
 
 void
 TimeAxisView::set_parent (TimeAxisView& p)
@@ -986,7 +982,7 @@ TimeAxisView::get_parent_with_state ()
 
        if (parent->has_state()) {
                return parent;
-       } 
+       }
 
        return parent->get_parent_with_state ();
 }
@@ -1005,7 +1001,7 @@ TimeAxisView::get_state ()
 }
 
 int
-TimeAxisView::set_state (const XMLNode& node)
+TimeAxisView::set_state (const XMLNode& node, int /*version*/)
 {
        const XMLProperty *prop;
 
@@ -1035,7 +1031,7 @@ TimeAxisView::set_state (const XMLNode& node)
        } else if ((prop = node.property ("height")) != 0) {
 
                set_height (atoi (prop->value()));
-               
+
        } else {
 
                set_height (hNormal);
@@ -1053,7 +1049,7 @@ TimeAxisView::reset_height()
                (*i)->set_height ((*i)->height);
        }
 }
-       
+
 void
 TimeAxisView::compute_controls_size_info ()
 {
@@ -1084,7 +1080,7 @@ TimeAxisView::compute_controls_size_info ()
        }
 
        one_row_table.attach (*buttons[0], 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
-       
+
        one_row_table.show_all ();
        Gtk::Requisition req(one_row_table.size_request ());
 
@@ -1104,13 +1100,11 @@ TimeAxisView::compute_controls_size_info ()
        two_row_table.show_all ();
        req = two_row_table.size_request ();
 
-       cerr << "Normal height is " << req.height << " + " << extra_height << endl;
-
-       // height required to show all normal buttons 
+       // height required to show all normal buttons
 
        hNormal = /*req.height*/ 48 + extra_height;
 
-       // these heights are all just larger than normal. no more 
+       // these heights are all just larger than normal. no more
        // elements are visible (yet).
 
        hLarger = hNormal + 50;
@@ -1221,7 +1215,7 @@ TimeAxisView::covers_y_position (double y)
                                l = view()->layers() - 1;
                        }
                }
-                       
+
                return std::make_pair (this, l);
        }
 
@@ -1285,16 +1279,13 @@ bool
 TimeAxisView::resizer_button_press (GdkEventButton* event)
 {
        _resize_drag_start = event->y_root;
-       _resize_idle_target = current_height ();
-       _editor.start_resize_line_ops ();
        return true;
 }
 
 bool
-TimeAxisView::resizer_button_release (GdkEventButton* ev)
+TimeAxisView::resizer_button_release (GdkEventButton*)
 {
        _resize_drag_start = -1;
-       _editor.end_resize_line_ops ();
        return true;
 }
 
@@ -1311,11 +1302,8 @@ TimeAxisView::resizer_motion (GdkEventMotion* ev)
                return true;
        }
 
-       int32_t const delta = (int32_t) floor (_resize_drag_start - ev->y_root);
-
-       _resize_idle_target = std::max (_resize_idle_target - delta, (int) hSmall);
-       _editor.add_to_idle_resize (this, _resize_idle_target);
-       
+       int32_t const delta = (int32_t) floor (ev->y_root - _resize_drag_start);
+       _editor.add_to_idle_resize (this, delta);
        _resize_drag_start = ev->y_root;
 
        return true;
@@ -1339,7 +1327,7 @@ TimeAxisView::resizer_expose (GdkEventExpose* event)
        win->get_geometry (x, y, w, h, d);
 
        /* handle/line #1 */
-       
+
        win->draw_line (dark, 0, 0, w - 2, 0);
        win->draw_point (dark, 0, 1);
        win->draw_line (light, 1, 1, w - 1, 1);