void MarkerList::CropToTimeSel(bool bOffset) { double dStart, dEnd; GetSet_LoopTimeRange(false, false, &dStart, &dEnd, false); // If no time sel just return if (dStart == dEnd) return; // Don't crop the end of regions for (int i = 0; i < m_items.GetSize(); i++) { MarkerItem* item = m_items.Get(i); if (item->GetPos() > dEnd || (!item->IsRegion() && item->GetPos() < dStart) || (item->IsRegion() && item->GetRegEnd() < dStart)) { // delete the item m_items.Delete(i, true); i--; } else { if (item->IsRegion() && item->GetPos() < dStart && item->GetRegEnd() >= dStart) item->SetPos(dStart); if (bOffset) { item->SetPos(item->GetPos() - dStart); if (item->IsRegion()) item->SetRegEnd(item->GetRegEnd() - dStart); } } } }
void SelPrevMarkerOrRegion(COMMAND_T*) { // Save the current marker list so we can traverse the list bacwards MarkerList ml(NULL, true); double dCurPos = GetCursorPosition(); double dCurStart, dCurEnd; GetSet_LoopTimeRange(false, false, &dCurStart, &dCurEnd, false); bool bCurSel = dCurStart != dCurEnd; for (int i = ml.m_items.GetSize()-1; i >= 0; i--) { MarkerItem* mi = ml.m_items.Get(i); if (mi->GetPos() < dCurPos || (!mi->IsRegion() && mi->GetPos() <= dCurPos && bCurSel)) { double dNewStart = mi->GetPos(), dNewEnd = mi->GetRegEnd(); GetSet_LoopTimeRange(true, false, &dNewStart, mi->IsRegion() ? &dNewEnd : &dNewStart, false); SetEditCurPos(mi->GetPos(), true, true); return; } } }