NOOP, re-indent, remove trailing whitespace, sort includes
[ardour.git] / gtk2_ardour / time_axis_view.cc
index 62225872d6c754b08a5e0c933221e964e13a588d..2923f630761454ab405a0511dd7fd8817c0d28c1 100644 (file)
@@ -66,16 +66,19 @@ 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 = SizeGroup::create (SIZE_GROUP_HORIZONTAL);
+Glib::RefPtr<Gtk::SizeGroup> TimeAxisView::controls_meters_size_group = Glib::RefPtr<Gtk::SizeGroup>();
 
 TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisView* rent, Canvas& /*canvas*/)
        : AxisView (sess)
-       , controls_table (4, 4)
+       , controls_table (3, 3)
        , controls_button_size_group (Gtk::SizeGroup::create (Gtk::SIZE_GROUP_BOTH))
        , _name_editing (false)
        , height (0)
@@ -98,14 +101,23 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        , _have_preresize_cursor (false)
        , _ebox_release_can_act (true)
 {
+       if (!controls_meters_size_group) {
+               controls_meters_size_group = SizeGroup::create (SIZE_GROUP_HORIZONTAL);
+       }
        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);
@@ -131,11 +143,8 @@ 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
-       if (ARDOUR::Profile->get_mixbus() ) {
-               name_hbox.set_size_request(100, 0);
-       } else {
-               name_hbox.set_size_request(90, 0);
-       }
+       name_hbox.set_size_request(name_width_px, -1);
+
        name_hbox.show ();
        name_label.show ();
 
@@ -144,9 +153,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 +166,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 +184,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 +192,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 +230,9 @@ TimeAxisView::~TimeAxisView()
        delete _canvas_display;
        _canvas_display = 0;
 
+       delete _canvas_separator;
+       _canvas_separator = 0;
+
        delete display_menu;
        display_menu = 0;
 
@@ -233,9 +247,10 @@ TimeAxisView::hide ()
        }
 
        _canvas_display->hide ();
+       _canvas_separator->hide ();
 
        if (control_parent) {
-               control_parent->remove (time_axis_frame);
+               control_parent->remove (TOP_LEVEL_WIDGET);
                control_parent = 0;
        }
 
@@ -267,24 +282,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 +547,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 +783,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 +905,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();
@@ -1116,7 +1138,7 @@ TimeAxisView::compute_heights ()
 {
        // TODO this function should be re-evaluated when font-scaling changes (!)
        Gtk::Window window (Gtk::WINDOW_TOPLEVEL);
-       Gtk::Table one_row_table (1, 8);
+       Gtk::Table one_row_table (1, 1);
        ArdourButton* test_button = manage (new ArdourButton);
        const int border_width = 2;
        const int frame_height = 2;
@@ -1125,6 +1147,7 @@ TimeAxisView::compute_heights ()
        window.add (one_row_table);
        test_button->set_name ("mute button");
        test_button->set_text (_("M"));
+       test_button->set_tweaks (ArdourButton::TrackHeader);
 
        one_row_table.set_border_width (border_width);
        one_row_table.set_row_spacings (2);