diff options
-rw-r--r-- | gtk2_ardour/location_ui.cc | 47 | ||||
-rw-r--r-- | libs/ardour/ardour/location.h | 2 |
2 files changed, 41 insertions, 8 deletions
diff --git a/gtk2_ardour/location_ui.cc b/gtk2_ardour/location_ui.cc index 9613aaccb5..fda29be193 100644 --- a/gtk2_ardour/location_ui.cc +++ b/gtk2_ardour/location_ui.cc @@ -703,6 +703,12 @@ LocationUI::location_redraw_ranges () range_rows.show(); } +struct LocationSortByStart { + bool operator() (Location *a, Location *b) { + return a->start() < b->start(); + } +}; + void LocationUI::location_added (Location* location) { @@ -712,8 +718,39 @@ LocationUI::location_added (Location* location) punch_edit_row.set_location(location); } else if (location->is_auto_loop()) { loop_edit_row.set_location(location); - } else { - refresh_location_list (); + } else if (location->is_range_marker() || location->is_mark()) { + Locations::LocationList loc = _session->locations()->list (); + loc.sort (LocationSortByStart ()); + + LocationEditRow* erow = manage (new LocationEditRow (_session, location)); + erow->remove_requested.connect (sigc::mem_fun (*this, &LocationUI::location_remove_requested)); + Box_Helpers::BoxList & children = location->is_range_marker() ? range_rows.children () : location_rows.children (); + + /* Step through the location list and the GUI list to find the place to insert */ + Locations::LocationList::iterator i = loc.begin (); + Box_Helpers::BoxList::iterator j = children.begin (); + while (i != loc.end()) { + + if (location->flags() != (*i)->flags()) { + /* Skip locations in the session list that aren't of the right type */ + ++i; + continue; + } + + if (*i == location) { + children.insert (j, Box_Helpers::Element (*erow, PACK_SHRINK, 1, PACK_START)); + break; + } + + ++i; + + if (j != children.end()) { + ++j; + } + } + + range_rows.show_all (); + location_rows.show_all (); } } @@ -738,12 +775,6 @@ LocationUI::location_removed (Location* location) } } -struct LocationSortByStart { - bool operator() (Location *a, Location *b) { - return a->start() < b->start(); - } -}; - void LocationUI::map_locations (Locations::LocationList& locations) { diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index 7d3b0ac1a9..3f3eaf4fc8 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -104,6 +104,8 @@ class Location : public PBD::StatefulDestructible bool is_range_marker() const { return _flags & IsRangeMarker; } bool matches (Flags f) const { return _flags & f; } + Flags flags () const { return _flags; } + PBD::Signal1<void,Location*> name_changed; PBD::Signal1<void,Location*> end_changed; PBD::Signal1<void,Location*> start_changed; |