various work to make loop/punch display work better (including fixes for bugs present...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 28 Jan 2014 02:27:13 +0000 (21:27 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 28 Jan 2014 02:27:13 +0000 (21:27 -0500)
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_markers.cc

index 2b430c8a40e9c4db9db6543f80f34c70a0a0c638..5e0d3cc4740c0b399f127641f5c18276c1e8e3ff 100644 (file)
@@ -1214,32 +1214,12 @@ Editor::set_session (Session *t)
        /* Make sure we have auto loop and auto punch ranges */
 
        Location* loc = _session->locations()->auto_loop_location();
-       if (loc == 0) {
-               loc = new Location (*_session, 0, _session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
-
-               if (loc->start() == loc->end()) {
-                       loc->set_end (loc->start() + 1);
-               }
-
-               _session->locations()->add (loc, false);
-               _session->set_auto_loop_location (loc);
-       } else {
-               // force name
+       if (loc != 0) {
                loc->set_name (_("Loop"));
        }
 
        loc = _session->locations()->auto_punch_location();
-
-       if (loc == 0) {
-               loc = new Location (*_session, 0, _session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
-
-               if (loc->start() == loc->end()) {
-                       loc->set_end (loc->start() + 1);
-               }
-
-               _session->locations()->add (loc, false);
-               _session->set_auto_punch_location (loc);
-       } else {
+       if (loc != 0) {
                // force name
                loc->set_name (_("Punch"));
        }
@@ -3201,7 +3181,7 @@ Editor::map_transport_state ()
                have_pending_keyboard_selection = false;
        }
 
-       update_loop_range_view (true);
+       update_loop_range_view ();
 }
 
 /* UNDO/REDO */
@@ -4467,7 +4447,7 @@ Editor::set_punch_range (framepos_t start, framepos_t end, string cmd)
                Location* loc = new Location (*_session, start, end, _("Punch"),  Location::IsAutoPunch);
                XMLNode &before = _session->locations()->get_state();
                _session->locations()->add (loc, true);
-               _session->set_auto_loop_location (loc);
+               _session->set_auto_punch_location (loc);
                XMLNode &after = _session->locations()->get_state();
                _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
        }
index 47ce7d782800997ed3199b13cb381b3237fbfd27..186014e350e35d8518d67ad76d42a5edf0e9a39a 100644 (file)
@@ -1507,8 +1507,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void marker_menu_zoom_to_range ();
        void new_transport_marker_menu_set_loop ();
        void new_transport_marker_menu_set_punch ();
-       void update_loop_range_view (bool visibility=false);
-       void update_punch_range_view (bool visibility=false);
+       void update_loop_range_view ();
+       void update_punch_range_view ();
        void new_transport_marker_menu_popdown ();
        void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
        void tempo_or_meter_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
index 8b4ec4034a861b590937f096f4ba259afd913452..5f3354b0beaa1b28a9edd89379e78955e5727dd3 100644 (file)
@@ -1600,11 +1600,11 @@ Editor::parameter_changed (std::string p)
        ENSURE_GUI_THREAD (*this, &Editor::parameter_changed, p)
 
        if (p == "auto-loop") {
-               update_loop_range_view (true);
+               update_loop_range_view ();
        } else if (p == "punch-in") {
-               update_punch_range_view (true);
+               update_punch_range_view ();
        } else if (p == "punch-out") {
-               update_punch_range_view (true);
+               update_punch_range_view ();
        } else if (p == "timecode-format") {
                update_just_timecode ();
        } else if (p == "show-region-fades") {
index eb82a94f6b00c862355fa23facd0ee9679dbdfde..1302804cec2d31bce22e2203ec61b5318abcb8de 100644 (file)
@@ -68,6 +68,14 @@ Editor::add_new_location (Location *location)
 
        /* Do a full update of the markers in this group */
        update_marker_labels (group);
+       
+       if (location->is_auto_punch()) {
+               update_punch_range_view ();
+       }
+
+       if (location->is_auto_loop()) {
+               update_loop_range_view ();
+       }
 }
 
 /** Add a new location, without a time-consuming update of all marker labels;
@@ -523,8 +531,8 @@ Editor::refresh_location_display_internal (Locations::LocationList& locations)
                i = tmp;
        }
 
-       update_punch_range_view (false);
-       update_loop_range_view (false);
+       update_punch_range_view ();
+       update_loop_range_view ();
 }
 
 void
@@ -729,11 +737,11 @@ Editor::location_gone (Location *location)
        LocationMarkerMap::iterator i;
 
        if (location == transport_loop_location()) {
-               update_loop_range_view (true);
+               update_loop_range_view ();
        }
 
        if (location == transport_punch_location()) {
-               update_punch_range_view (true);
+               update_punch_range_view ();
        }
 
        for (i = location_markers.begin(); i != location_markers.end(); ++i) {
@@ -1420,7 +1428,7 @@ Editor::new_transport_marker_menu_set_punch ()
 }
 
 void
-Editor::update_loop_range_view (bool visibility)
+Editor::update_loop_range_view ()
 {
        if (_session == 0) {
                return;
@@ -1436,17 +1444,15 @@ Editor::update_loop_range_view (bool visibility)
                transport_loop_range_rect->set_x0 (x1);
                transport_loop_range_rect->set_x1 (x2);
 
-               if (visibility) {
-                       transport_loop_range_rect->show();
-               }
-
-       } else if (visibility) {
+               transport_loop_range_rect->show();
+               
+       } else {
                transport_loop_range_rect->hide();
        }
 }
 
 void
-Editor::update_punch_range_view (bool visibility)
+Editor::update_punch_range_view ()
 {
        if (_session == 0) {
                return;
@@ -1456,6 +1462,7 @@ Editor::update_punch_range_view (bool visibility)
 
        if ((_session->config.get_punch_in() || _session->config.get_punch_out()) && ((tpl = transport_punch_location()) != 0)) {
                ArdourCanvas::Rect const v = _track_canvas->visible_area ();
+
                if (_session->config.get_punch_in()) {
                        transport_punch_range_rect->set_x0 (sample_to_pixel (tpl->start()));
                        transport_punch_range_rect->set_x1 (_session->config.get_punch_out() ? sample_to_pixel (tpl->end()) : sample_to_pixel (JACK_MAX_FRAMES));
@@ -1463,11 +1470,11 @@ Editor::update_punch_range_view (bool visibility)
                        transport_punch_range_rect->set_x0 (0);
                        transport_punch_range_rect->set_x1 (_session->config.get_punch_out() ? sample_to_pixel (tpl->end()) : v.width ());
                }
+               
+               transport_punch_range_rect->show();
+
+       } else {
 
-               if (visibility) {
-                       transport_punch_range_rect->show();
-               }
-       } else if (visibility) {
                transport_punch_range_rect->hide();
        }
 }