+/** Look for the `marks' (either locations which are marks, or start/end points of range markers) either
+ * side of a frame.
+ * @param frame Frame to look for.
+ * @param before Filled in with the position of the last `mark' before `frame' (or max_frames if none exists)
+ * @param after Filled in with the position of the last `mark' after `frame' (or max_frames if none exists)
+ */
+void
+Locations::marks_either_side (nframes64_t const frame, nframes64_t& before, nframes64_t& after) const
+{
+ before = after = max_frames;
+
+ LocationList locs;
+
+ {
+ Glib::Mutex::Lock lm (lock);
+ locs = locations;
+ }
+
+ std::list<nframes64_t> positions;
+
+ for (LocationList::const_iterator i = locs.begin(); i != locs.end(); ++i) {
+ if (((*i)->is_auto_loop() || (*i)->is_auto_punch())) {
+ continue;
+ }
+
+ if (!(*i)->is_hidden()) {
+ if ((*i)->is_mark ()) {
+ positions.push_back ((*i)->start ());
+ } else {
+ positions.push_back ((*i)->start ());
+ positions.push_back ((*i)->end ());
+ }
+ }
+ }
+
+ if (positions.empty ()) {
+ return;
+ }
+
+ positions.sort ();
+
+ std::list<nframes64_t>::iterator i = positions.begin ();
+ while (i != positions.end () && *i < frame) {
+ ++i;
+ }
+
+ if (i == positions.end ()) {
+ /* run out of marks */
+ before = positions.back ();
+ return;
+ }
+
+ after = *i;
+
+ if (i == positions.begin ()) {
+ /* none before */
+ return;
+ }
+
+ --i;
+ before = *i;
+}
+