コード例 #1
0
ファイル: MarkerListActions.cpp プロジェクト: AusRedNeck/sws
void MarkersToRegions(COMMAND_T* ct)
{
	MarkerList ml(NULL, true);

	WDL_PtrList<MarkerItem> &markers = ml.m_items;

	if(markers.GetSize() == 0) return; // Bail if there are no markers/regions

	double projEnd = SNM_GetProjectLength();

	Undo_BeginBlock2(NULL);

	// Insert dummy marker at project start if necessary
	if(markers.Get(0)->GetPos() > 0)
	{
		markers.Insert(0, new MarkerItem(false, 0, 0, "", 0, 0));
	}

	// Convert markers to regions
	for(int i = 0, c = markers.GetSize(); i < c; i++)
	{
		MarkerItem *pm = markers.Get(i);
		if(!pm->IsRegion())
		{
			// Find next marker
			MarkerItem *pNext = NULL;
			int n = i + 1;
			do
			{
				pNext = markers.Get(n++);
			}
			while(pNext && pNext->IsRegion());

			double pos = pm->GetPos();
			double end = pNext ? pNext->GetPos() : projEnd;

			if(pos != end)
			{
				pm->SetReg(true);
				pm->SetRegEnd(end);
			}
		}
	}

	ml.UpdateReaper();

	Undo_EndBlock2(NULL, __LOCALIZE("Convert markers to regions","sws_undo"), UNDO_STATE_MISCCFG);
}
コード例 #2
0
ファイル: MarkerListActions.cpp プロジェクト: AusRedNeck/sws
void RegionsToMarkers(COMMAND_T*)
{
	MarkerList ml(NULL, true);

	WDL_PtrList<MarkerItem> &markers = ml.m_items;

	if(markers.GetSize() == 0) return; // Bail if there are no markers/regions

	Undo_BeginBlock2(NULL);

	for(int i = 0, c = markers.GetSize(); i < c; i++)
	{
		MarkerItem *pm = markers.Get(i);

		if(pm->IsRegion())
		{
			pm->SetReg(false);
		}
	}

	ml.UpdateReaper();

	Undo_EndBlock2(NULL, __LOCALIZE("Convert regions to markers","sws_undo"), UNDO_STATE_MISCCFG);
}