Revert "use a gloabl size group for track-header ctrl buttons"
[ardour.git] / gtk2_ardour / time_axis_view.cc
index 2ac021f4cb63b2b75a1cc5ad48a73128a6080728..43c68cf5deb41efa5de0ad9bc8eb8c9eb6927a77 100644 (file)
@@ -66,12 +66,16 @@ using namespace Editing;
 using namespace ArdourCanvas;
 using Gtkmm2ext::Keyboard;
 
+#define TOP_LEVEL_WIDGET controls_ebox
+
 const double trim_handle_size = 6.0; /* pixels */
 uint32_t TimeAxisView::button_height = 0;
 uint32_t TimeAxisView::extra_height = 0;
 int const TimeAxisView::_max_order = 512;
+unsigned int TimeAxisView::name_width_px = 100; // TODO adjust with font-scaling on style-change
 PBD::Signal1<void,TimeAxisView*> TimeAxisView::CatchDeletion;
 Glib::RefPtr<Gtk::SizeGroup> TimeAxisView::controls_meters_size_group = Glib::RefPtr<Gtk::SizeGroup>();
+Glib::RefPtr<Gtk::SizeGroup> TimeAxisView::track_number_v_size_group = Glib::RefPtr<Gtk::SizeGroup>();
 
 TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisView* rent, Canvas& /*canvas*/)
        : AxisView (sess)
@@ -101,14 +105,23 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        if (!controls_meters_size_group) {
                controls_meters_size_group = SizeGroup::create (SIZE_GROUP_HORIZONTAL);
        }
+       if (!track_number_v_size_group) {
+               track_number_v_size_group = SizeGroup::create (SIZE_GROUP_VERTICAL);
+       }
        if (extra_height == 0) {
                compute_heights ();
        }
 
-       _canvas_display = new ArdourCanvas::Container (ed.get_trackview_group (), ArdourCanvas::Duple (0.0, 0.0));
+       _canvas_display = new ArdourCanvas::Container (ed.get_trackview_group (), ArdourCanvas::Duple (1.0, 0.0));
        CANVAS_DEBUG_NAME (_canvas_display, "main for TAV");
        _canvas_display->hide(); // reveal as needed
 
+       _canvas_separator = new ArdourCanvas::Line(ed.get_trackview_group ());
+       CANVAS_DEBUG_NAME (_canvas_separator, "separator for TAV");
+       _canvas_separator->set_outline_color(RGBA_TO_UINT (0, 0, 0, 255));
+       _canvas_separator->set_outline_width(1.0);
+       _canvas_separator->hide();
+
        selection_group = new ArdourCanvas::Container (_canvas_display);
        CANVAS_DEBUG_NAME (selection_group, "selection for TAV");
        selection_group->set_data (X_("timeselection"), (void *) 1);
@@ -134,7 +147,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        name_hbox.pack_end (name_label, true, true);
 
        // set min. track-header width if fader is not visible
-       name_hbox.set_size_request(100, 0);
+       name_hbox.set_size_request(name_width_px, -1);
 
        name_hbox.show ();
        name_label.show ();
@@ -144,9 +157,9 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        controls_table.set_border_width (2);
 
        if (ARDOUR::Profile->get_mixbus() ) {
-               controls_table.attach (name_hbox, 4, 5, 0, 2,  Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
+               controls_table.attach (name_hbox, 4, 5, 0, 2,  Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK, 0, 0);
        } else {
-               controls_table.attach (name_hbox, 1, 2, 0, 2,  Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
+               controls_table.attach (name_hbox, 1, 2, 0, 2,  Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK, 0, 0);
        }
        controls_table.show_all ();
        controls_table.set_no_show_all ();
@@ -157,7 +170,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        top_hbox.pack_start (controls_vbox, true, true);
        top_hbox.show ();
 
-       controls_ebox.add (top_hbox);
+       controls_ebox.add (time_axis_hbox);
        controls_ebox.add_events (Gdk::BUTTON_PRESS_MASK|
                                  Gdk::BUTTON_RELEASE_MASK|
                                  Gdk::POINTER_MOTION_MASK|
@@ -175,7 +188,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        controls_ebox.show ();
 
        time_axis_frame.set_shadow_type (Gtk::SHADOW_NONE);
-       time_axis_frame.add(controls_ebox);
+       time_axis_frame.add(top_hbox);
        time_axis_frame.show();
 
        HSeparator* separator = manage (new HSeparator());
@@ -183,9 +196,11 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        separator->set_size_request(-1, 1);
        separator->show();
 
+       time_axis_vbox.pack_start (*separator, false, false);
        time_axis_vbox.pack_start (time_axis_frame, true, true);
-       time_axis_vbox.pack_end (*separator, false, false);
        time_axis_vbox.show();
+       time_axis_hbox.pack_start (time_axis_vbox, true, true);
+       time_axis_hbox.show();
 
        ColorsChanged.connect (sigc::mem_fun (*this, &TimeAxisView::color_handler));
 
@@ -219,6 +234,9 @@ TimeAxisView::~TimeAxisView()
        delete _canvas_display;
        _canvas_display = 0;
 
+       delete _canvas_separator;
+       _canvas_separator = 0;
+
        delete display_menu;
        display_menu = 0;
 
@@ -233,9 +251,10 @@ TimeAxisView::hide ()
        }
 
        _canvas_display->hide ();
+       _canvas_separator->hide ();
 
        if (control_parent) {
-               control_parent->remove (time_axis_vbox);
+               control_parent->remove (TOP_LEVEL_WIDGET);
                control_parent = 0;
        }
 
@@ -267,24 +286,27 @@ guint32
 TimeAxisView::show_at (double y, int& nth, VBox *parent)
 {
        if (control_parent) {
-               control_parent->reorder_child (time_axis_vbox, nth);
+               control_parent->reorder_child (TOP_LEVEL_WIDGET, nth);
        } else {
                control_parent = parent;
-               parent->pack_start (time_axis_vbox, false, false);
-               parent->reorder_child (time_axis_vbox, nth);
+               parent->pack_start (TOP_LEVEL_WIDGET, false, false);
+               parent->reorder_child (TOP_LEVEL_WIDGET, nth);
        }
 
        _order = nth;
 
        if (_y_position != y) {
-               _canvas_display->set_y_position (y);
+               _canvas_separator->set (ArdourCanvas::Duple(0, y), ArdourCanvas::Duple(ArdourCanvas::COORD_MAX, y));
+               _canvas_display->set_y_position (y + 1);
                _y_position = y;
-
        }
 
        _canvas_display->raise_to_top ();
        _canvas_display->show ();
 
+       _canvas_separator->raise_to_top ();
+       _canvas_separator->show ();
+
        _hidden = false;
 
        _effective_height = current_height ();
@@ -529,7 +551,7 @@ TimeAxisView::set_height (uint32_t h)
                h = preset_height (HeightSmall);
        }
 
-       time_axis_vbox.property_height_request () = h;
+       TOP_LEVEL_WIDGET.property_height_request () = h;
        height = h;
 
        char buf[32];
@@ -765,6 +787,10 @@ TimeAxisView::popup_display_menu (guint32 when)
 void
 TimeAxisView::set_selected (bool yn)
 {
+       if (can_edit_name() && name_entry && name_entry->get_visible()) {
+               end_name_edit (RESPONSE_CANCEL);
+       }
+
        if (yn == _selected) {
                return;
        }
@@ -883,7 +909,7 @@ TimeAxisView::show_selection (TimeSelection& ts)
                // trim boxes are at the top for selections
 
                if (x2 > x1) {
-                       rect->start_trim->set (ArdourCanvas::Rect (x1, 1, x1 + trim_handle_size, y2));
+                       rect->start_trim->set (ArdourCanvas::Rect (x1, 0, x1 + trim_handle_size, y2));
                        rect->end_trim->set (ArdourCanvas::Rect (x2 - trim_handle_size, 1, x2, y2));
 
                        rect->start_trim->show();