fix merge conflict from master
[ardour.git] / gtk2_ardour / time_axis_view.cc
index 1cf2391d5e8558171f03c0736abf6f95e58e80cb..2cc2adf7617611c47f208fdac6405d3c0e2c19d6 100644 (file)
@@ -83,7 +83,6 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        , _canvas_display (0)
        , _y_position (0)
        , _editor (ed)
-       , name_editor (0)
        , name_entry (0)
        , control_parent (0)
        , _order (0)
@@ -113,7 +112,13 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        name_label.set_name ("TrackLabel");
        name_label.set_alignment (0.0, 0.5);
        ARDOUR_UI::instance()->set_tip (name_label, _("Track/Bus name (double click to edit)"));
-                                                     
+
+       Gtk::Entry* an_entry = new Gtk::Entry;
+       Gtk::Requisition req;
+       an_entry->size_request (req);
+       name_label.set_size_request (-1, req.height);
+       delete an_entry;
+
        name_hbox.pack_start (name_label, true, true);
        name_hbox.show ();
        name_label.show ();
@@ -129,12 +134,18 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        controls_table.set_no_show_all ();
 
        HSeparator* separator = manage (new HSeparator());
+       separator->set_name("TrackSeparator");
+       separator->set_size_request(-1, 1);
+       separator->show();
 
        controls_vbox.pack_start (controls_table, false, false);
        controls_vbox.show ();
 
+       controls_hbox.pack_start (controls_vbox, true, true);
+       controls_hbox.show ();
+
        //controls_ebox.set_name ("TimeAxisViewControlsBaseUnselected");
-       controls_ebox.add (controls_vbox);
+       controls_ebox.add (controls_hbox);
        controls_ebox.add_events (Gdk::BUTTON_PRESS_MASK|
                                  Gdk::BUTTON_RELEASE_MASK|
                                  Gdk::POINTER_MOTION_MASK|
@@ -151,10 +162,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        controls_ebox.signal_leave_notify_event().connect (sigc::mem_fun (*this, &TimeAxisView::controls_ebox_leave));
        controls_ebox.show ();
 
-       controls_hbox.pack_start (controls_ebox, true, true);
-       controls_hbox.show ();
-
-       time_axis_vbox.pack_start (controls_hbox, true, true);
+       time_axis_vbox.pack_start (controls_ebox, true, true, 0);
        time_axis_vbox.pack_end (*separator, false, false);
        time_axis_vbox.show();
 
@@ -305,7 +313,7 @@ TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
 {
        switch (ev->direction) {
        case GDK_SCROLL_UP:
-               if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
+               if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomVerticalModifier)) {
                        /* See Editor::_stepping_axis_view for notes on this hack */
                        Editor& e = dynamic_cast<Editor&> (_editor);
                        if (!e.stepping_axis_view ()) {
@@ -320,7 +328,7 @@ TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
                break;
 
        case GDK_SCROLL_DOWN:
-               if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
+               if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomVerticalModifier)) {
                        /* See Editor::_stepping_axis_view for notes on this hack */
                        Editor& e = dynamic_cast<Editor&> (_editor);
                        if (!e.stepping_axis_view ()) {
@@ -402,6 +410,7 @@ TimeAxisView::controls_ebox_motion (GdkEventMotion* ev)
                maybe_set_cursor (ev->y);
        }
 
+       gdk_event_request_motions(ev);
        return true;
 }
 
@@ -565,7 +574,7 @@ TimeAxisView::name_entry_key_release (GdkEventKey* ev)
 
        switch (ev->keyval) {
        case GDK_Escape:
-               name_editor->response (RESPONSE_CANCEL);
+               end_name_edit (RESPONSE_CANCEL);
                return true;
 
        /* Shift+Tab Keys Pressed. Note that for Shift+Tab, GDK actually
@@ -573,8 +582,11 @@ TimeAxisView::name_entry_key_release (GdkEventKey* ev)
         * ev->state.
         */
        case GDK_ISO_Left_Tab:
+               end_name_edit (RESPONSE_APPLY);
+               return true;
+
        case GDK_Tab:
-               name_editor->response (RESPONSE_ACCEPT);
+               end_name_edit (RESPONSE_ACCEPT);
                return true;
        default:
                break;
@@ -583,78 +595,54 @@ TimeAxisView::name_entry_key_release (GdkEventKey* ev)
        return false;
 }
 
+bool
+TimeAxisView::name_entry_focus_out (GdkEventFocus*)
+{
+       end_name_edit (RESPONSE_OK);
+       return false;
+}
+
 void
 TimeAxisView::begin_name_edit ()
 {
-       if (name_editor) {
+       if (name_entry) {
                return;
        }
 
        if (can_edit_name()) {
 
-               Gtk::Widget* w = name_label.get_toplevel();
-               Gtk::Window* win = dynamic_cast<Gtk::Window*>(w);
-               
-               if (!win) {
-                       return;
-               }
-
-               name_editor = new ArdourDialog (*win, string_compose (_("Edit name for %1"), name()), true);
-               name_editor->add_button (_("Cancel"), RESPONSE_CANCEL);
-               name_editor->add_button (_("Save"), RESPONSE_OK);
-               name_editor->add_button (_("Save & Edit Next"), RESPONSE_ACCEPT);
-
                name_entry = manage (new Gtkmm2ext::FocusEntry);
                
                name_entry->set_name ("EditorTrackNameDisplay");
                name_entry->signal_key_press_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_key_press), false);
                name_entry->signal_key_release_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_key_release), false);
+               name_entry->signal_focus_out_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_focus_out));
                name_entry->set_text (name_label.get_text());
-               name_entry->signal_activate().connect (sigc::bind (sigc::mem_fun (*name_editor, &ArdourDialog::response), RESPONSE_OK));
-
-               Gtk::HBox* hbox = manage (new HBox);
-               Gtk::Label* label = manage (new Label (_("New name")));
+               name_entry->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &TimeAxisView::end_name_edit), RESPONSE_OK));
 
-               hbox->pack_start (*label, false, false);
-               hbox->pack_start (*name_entry, true, true);
-               name_editor->get_vbox()->pack_start (*hbox, false, false);
-
-               label->show();
+               if (name_label.is_ancestor (name_hbox)) {
+                       name_hbox.remove (name_label);
+               }
+               
+               name_hbox.pack_start (*name_entry);
                name_entry->show ();
-               hbox->show ();
 
                name_entry->select_region (0, -1);
                name_entry->set_state (STATE_SELECTED);
                name_entry->grab_focus ();
                name_entry->start_editing (0);
-
-               name_editor->signal_response().connect (sigc::mem_fun (*this, &TimeAxisView::end_name_edit));
-
-               name_editor->set_position (WIN_POS_MOUSE);
-               name_editor->present ();
-
-               /* move it to line up with the name label, and some distance to
-                * the right of it
-                */
-
-               int x, y;
-               int wx, wy;
-
-               name_label.translate_coordinates (_editor, 0, 0, x, y);
-               _editor.get_position (wx, wy);
-
-               name_editor->move (wx + x + 250, wy + y);
        }
 }
 
 void
 TimeAxisView::end_name_edit (int response)
 {
-       if (!name_editor) {
+       if (!name_entry) {
                return;
        }
        
        bool edit_next = false;
+       bool edit_prev = false;
 
        switch (response) {
        case RESPONSE_CANCEL:
@@ -665,12 +653,24 @@ TimeAxisView::end_name_edit (int response)
        case RESPONSE_ACCEPT:
                name_entry_changed ();
                edit_next = true;
+       case RESPONSE_APPLY:
+               name_entry_changed ();
+               edit_prev = true;
        }
 
-       delete_when_idle (name_editor);
+       /* this will delete the name_entry. but it will also drop focus, which
+        * will cause another callback to this function, so set name_entry = 0
+        * first to ensure we don't double-remove etc. etc.
+        */
 
-       name_editor = 0;
+       Gtk::Entry* tmp = name_entry;
        name_entry = 0;
+       name_hbox.remove (*tmp);
+
+       /* put the name label back */
+
+       name_hbox.pack_start (name_label);
+       name_label.show ();
 
        if (edit_next) {
 
@@ -697,6 +697,37 @@ TimeAxisView::end_name_edit (int response)
                        } while (true);
                }
 
+               if ((i != allviews.end()) && (*i != this) && !(*i)->hidden()) {
+                       _editor.ensure_time_axis_view_is_visible (**i);
+                       (*i)->begin_name_edit ();
+               } 
+
+       } else if (edit_prev) {
+
+               TrackViewList const & allviews = _editor.get_track_views ();
+               TrackViewList::const_iterator i = find (allviews.begin(), allviews.end(), this);
+               
+               if (i != allviews.begin()) {
+                       do {
+                               if (i == allviews.begin()) {
+                                       return;
+                               }
+                               
+                               --i;
+                               
+                               RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*>(*i);
+                               
+                               if (rtav && rtav->route()->record_enabled()) {
+                                       continue;
+                               }
+                               
+                               if (!(*i)->hidden()) {
+                                       break;
+                               }
+                               
+                       } while (true);
+               }
+               
                if ((i != allviews.end()) && (*i != this) && !(*i)->hidden()) {
                        _editor.ensure_time_axis_view_is_visible (**i);
                        (*i)->begin_name_edit ();