various work to make loop/punch display work better (including fixes for bugs present in master also)

This commit is contained in:
Paul Davis 2014-01-27 21:27:13 -05:00
parent d23c2499bf
commit d00dc6a706
4 changed files with 31 additions and 44 deletions

View file

@ -1214,32 +1214,12 @@ Editor::set_session (Session *t)
/* Make sure we have auto loop and auto punch ranges */ /* Make sure we have auto loop and auto punch ranges */
Location* loc = _session->locations()->auto_loop_location(); Location* loc = _session->locations()->auto_loop_location();
if (loc == 0) { 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
loc->set_name (_("Loop")); loc->set_name (_("Loop"));
} }
loc = _session->locations()->auto_punch_location(); loc = _session->locations()->auto_punch_location();
if (loc != 0) {
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 {
// force name // force name
loc->set_name (_("Punch")); loc->set_name (_("Punch"));
} }
@ -3201,7 +3181,7 @@ Editor::map_transport_state ()
have_pending_keyboard_selection = false; have_pending_keyboard_selection = false;
} }
update_loop_range_view (true); update_loop_range_view ();
} }
/* UNDO/REDO */ /* 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); Location* loc = new Location (*_session, start, end, _("Punch"), Location::IsAutoPunch);
XMLNode &before = _session->locations()->get_state(); XMLNode &before = _session->locations()->get_state();
_session->locations()->add (loc, true); _session->locations()->add (loc, true);
_session->set_auto_loop_location (loc); _session->set_auto_punch_location (loc);
XMLNode &after = _session->locations()->get_state(); XMLNode &after = _session->locations()->get_state();
_session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after)); _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
} }

View file

@ -1507,8 +1507,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void marker_menu_zoom_to_range (); void marker_menu_zoom_to_range ();
void new_transport_marker_menu_set_loop (); void new_transport_marker_menu_set_loop ();
void new_transport_marker_menu_set_punch (); void new_transport_marker_menu_set_punch ();
void update_loop_range_view (bool visibility=false); void update_loop_range_view ();
void update_punch_range_view (bool visibility=false); void update_punch_range_view ();
void new_transport_marker_menu_popdown (); void new_transport_marker_menu_popdown ();
void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*); void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
void tempo_or_meter_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*); void tempo_or_meter_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);

View file

@ -1600,11 +1600,11 @@ Editor::parameter_changed (std::string p)
ENSURE_GUI_THREAD (*this, &Editor::parameter_changed, p) ENSURE_GUI_THREAD (*this, &Editor::parameter_changed, p)
if (p == "auto-loop") { if (p == "auto-loop") {
update_loop_range_view (true); update_loop_range_view ();
} else if (p == "punch-in") { } else if (p == "punch-in") {
update_punch_range_view (true); update_punch_range_view ();
} else if (p == "punch-out") { } else if (p == "punch-out") {
update_punch_range_view (true); update_punch_range_view ();
} else if (p == "timecode-format") { } else if (p == "timecode-format") {
update_just_timecode (); update_just_timecode ();
} else if (p == "show-region-fades") { } else if (p == "show-region-fades") {

View file

@ -68,6 +68,14 @@ Editor::add_new_location (Location *location)
/* Do a full update of the markers in this group */ /* Do a full update of the markers in this group */
update_marker_labels (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; /** 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; i = tmp;
} }
update_punch_range_view (false); update_punch_range_view ();
update_loop_range_view (false); update_loop_range_view ();
} }
void void
@ -729,11 +737,11 @@ Editor::location_gone (Location *location)
LocationMarkerMap::iterator i; LocationMarkerMap::iterator i;
if (location == transport_loop_location()) { if (location == transport_loop_location()) {
update_loop_range_view (true); update_loop_range_view ();
} }
if (location == transport_punch_location()) { if (location == transport_punch_location()) {
update_punch_range_view (true); update_punch_range_view ();
} }
for (i = location_markers.begin(); i != location_markers.end(); ++i) { for (i = location_markers.begin(); i != location_markers.end(); ++i) {
@ -1420,7 +1428,7 @@ Editor::new_transport_marker_menu_set_punch ()
} }
void void
Editor::update_loop_range_view (bool visibility) Editor::update_loop_range_view ()
{ {
if (_session == 0) { if (_session == 0) {
return; return;
@ -1436,17 +1444,15 @@ Editor::update_loop_range_view (bool visibility)
transport_loop_range_rect->set_x0 (x1); transport_loop_range_rect->set_x0 (x1);
transport_loop_range_rect->set_x1 (x2); transport_loop_range_rect->set_x1 (x2);
if (visibility) { transport_loop_range_rect->show();
transport_loop_range_rect->show();
}
} else if (visibility) { } else {
transport_loop_range_rect->hide(); transport_loop_range_rect->hide();
} }
} }
void void
Editor::update_punch_range_view (bool visibility) Editor::update_punch_range_view ()
{ {
if (_session == 0) { if (_session == 0) {
return; 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)) { if ((_session->config.get_punch_in() || _session->config.get_punch_out()) && ((tpl = transport_punch_location()) != 0)) {
ArdourCanvas::Rect const v = _track_canvas->visible_area (); ArdourCanvas::Rect const v = _track_canvas->visible_area ();
if (_session->config.get_punch_in()) { if (_session->config.get_punch_in()) {
transport_punch_range_rect->set_x0 (sample_to_pixel (tpl->start())); 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)); transport_punch_range_rect->set_x1 (_session->config.get_punch_out() ? sample_to_pixel (tpl->end()) : sample_to_pixel (JACK_MAX_FRAMES));
@ -1464,10 +1471,10 @@ Editor::update_punch_range_view (bool visibility)
transport_punch_range_rect->set_x1 (_session->config.get_punch_out() ? sample_to_pixel (tpl->end()) : v.width ()); transport_punch_range_rect->set_x1 (_session->config.get_punch_out() ? sample_to_pixel (tpl->end()) : v.width ());
} }
if (visibility) { transport_punch_range_rect->show();
transport_punch_range_rect->show();
} } else {
} else if (visibility) {
transport_punch_range_rect->hide(); transport_punch_range_rect->hide();
} }
} }