Example #1
0
void MoveCursorAndSel(COMMAND_T* ct)
{
	double dStart, dEnd, dPos = GetCursorPosition();
	int iEdge; // -1 for left, 1 for right
	GetSet_LoopTimeRange(false, false, &dStart, &dEnd, false);
	if (dStart == dEnd)
	{
		iEdge = (int)ct->user;
		dStart = dEnd = dPos;
	}
	else if (dPos <= dStart)
		iEdge = -1;
	else if (dPos >= dEnd)
		iEdge = 1;
	else if (dPos - dStart < dEnd - dPos)
		iEdge = -1;
	else
		iEdge = 1;

	// Set edit cursor
	dPos = ((int)ct->user == -1) ? GetPrevGridDiv(dPos) : GetNextGridDiv(dPos);
	SetEditCurPos(dPos, true, false);

	// Extend the time sel
	if (iEdge == -1)
		dStart = dPos;
	else
		dEnd = dPos;
	GetSet_LoopTimeRange(true, false, &dStart, &dEnd, false);

}
Example #2
0
void UndoEditCursor(COMMAND_T*)
{
	int iPrev = *g_editCursorStackPos.Get() - 1;
	if (iPrev < 0)
		iPrev = SWS_EDITCURSOR_STACK_SIZE - 1;
	if (g_editCursorStack.Get()->Get()[iPrev] != -DBL_MAX)
	{
		*g_editCursorStackPos.Get() = iPrev;
		SetEditCurPos(g_editCursorStack.Get()->Get()[iPrev], true, true);
	}
}
Example #3
0
void RedoEditCursor(COMMAND_T*)
{
	int iNext = *g_editCursorStackPos.Get() + 1;
	if (iNext >= SWS_EDITCURSOR_STACK_SIZE)
		iNext = 0;
	if (g_editCursorStack.Get()->Get()[iNext] != -DBL_MAX)
	{
		*g_editCursorStackPos.Get() = iNext;
		SetEditCurPos(g_editCursorStack.Get()->Get()[iNext], true, true);
	}
}
Example #4
0
// ct->user: -1 left, 1 right
void MoveCursorSample(COMMAND_T* ct)
{
	double dPos = GetCursorPosition();
	int* pSrate = (int*)GetConfigVar("projsrate");
	if (!pSrate)
		return;
	double dSrate = (double)*pSrate;
	INT64 iCurSample = (INT64)(dPos * dSrate + 0.5);
	if (ct->user == -1 && (dPos == (double)(iCurSample / dSrate)))
		iCurSample--;
	else if (ct->user == 1)
		iCurSample++;

	double dNewPos = (double)(iCurSample / dSrate);

	SetEditCurPos(dNewPos, true, false);
}
Example #5
0
// Goto the end of the project, *including* perhaps marker ends
void GotoEndInclMarkers(COMMAND_T*)
{
	Main_OnCommand(40043, 0);
	int x = 0;
	double dRegStart, dRegEnd;
	bool bReg;
	double dMarkerEnd = -DBL_MAX;
	while ((x = EnumProjectMarkers(x, &bReg, &dRegStart, &dRegEnd, NULL, NULL)))
	{
		if (bReg && dRegEnd > dMarkerEnd)
			dMarkerEnd = dRegEnd;
		else if (!bReg && dRegStart > dMarkerEnd)
			dMarkerEnd = dRegStart;
	}
	if (dMarkerEnd > GetCursorPosition())
		SetEditCurPos(dMarkerEnd, true, true);
}
Example #6
0
void FindItemPeak(COMMAND_T*)
{
	// Just use the first item
	MediaItem* mi = GetSelectedMediaItem(NULL, 0);
	if (mi)
	{
		ANALYZE_PCM a;
		memset(&a, 0, sizeof(a));
		if (AnalyzeItem(mi, &a))
		{
			double dSrate = ((PCM_source*)mi)->GetSampleRate();
			double dPos = *(double*)GetSetMediaItemInfo(mi, "D_POSITION", NULL);
			dPos += a.peakSample / dSrate;
			SetEditCurPos(dPos, true, false);
		}
	}
	else
		MessageBox(NULL, __LOCALIZE("No items selected to analyze.","sws_analysis"), __LOCALIZE("SWS - Error","sws_analysis"), MB_OK);
}
Example #7
0
void SelNextMarkerOrRegion(COMMAND_T*)
{
	double dCurPos = GetCursorPosition();
	double dCurStart, dCurEnd, dRegStart, dRegEnd;
	GetSet_LoopTimeRange(false, false, &dCurStart, &dCurEnd, false);
	int x = 0;
	bool bReg;
	while ((x = EnumProjectMarkers(x, &bReg, &dRegStart, &dRegEnd, NULL, NULL)))
	{
		bool bSelMatches = dCurStart == dRegStart && dCurEnd == dRegEnd;
		if (dRegStart > dCurPos || (bReg && dRegStart >= dCurPos && !bSelMatches))
		{
			GetSet_LoopTimeRange(true, false, &dRegStart, bReg ? &dRegEnd : &dRegStart, false);
			SetEditCurPos(dRegStart, true, true);
			return;
		}
	}
	// Currently no wraparound, if needed add "go to first" here.
}
Example #8
0
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;
		}
	}
}
Example #9
0
void MoveCursorAndSel(COMMAND_T* ct)
{
	double dStart, dEnd, dPos = GetCursorPosition();
	int iEdge; // -1 for left, 1 for right
	GetSet_LoopTimeRange(false, false, &dStart, &dEnd, false);
	if (dStart == dEnd)
	{
		iEdge = (int)ct->user;
		dStart = dEnd = dPos;
	}
	else if (dPos <= dStart)
		iEdge = -1;
	else if (dPos >= dEnd)
		iEdge = 1;
	else if (dPos - dStart < dEnd - dPos)
		iEdge = -1;
	else
		iEdge = 1;

	// Move the edit cursor position
	double dQN = TimeMap2_timeToQN(NULL, dPos);
	// Special case for left move and on grid already
	int iQN = (int)(dQN + SWS_ADJACENT_ITEM_THRESHOLD);
	if (ct->user == -1 && fabs(dQN - iQN) < SWS_ADJACENT_ITEM_THRESHOLD)
		--iQN;
	else if (ct->user == 1)
		++iQN;
	dPos = TimeMap2_QNToTime(NULL, (double)iQN);

	// Extend the time sel
	if (iEdge == -1)
		dStart = dPos;
	else
		dEnd = dPos;
	GetSet_LoopTimeRange(true, false, &dStart, &dEnd, false);

	// Set the play cursor
	SetEditCurPos(dPos, true, false);
}
Example #10
0
void MarkerNudge(bool bRight)
{
	// Find the marker underneath the edit cursor
	int x = 0;
	int iIndex, iColor;
	double dPos, dEnd;
	bool bReg;
	double dCurPos = GetCursorPosition();
	while (x = EnumProjectMarkers3(NULL, x, &bReg, &dPos, &dEnd, NULL, &iIndex, &iColor))
	{
		if (dPos == dCurPos)
		{
			dCurPos += (bRight ? 1.0 : -1.0) / GetHZoomLevel();
			if (dCurPos >= 0)
			{
				SetProjectMarkerByIndex(NULL, x-1, bReg, dCurPos, dEnd, iIndex, NULL, iColor);
				SetEditCurPos(dCurPos, true, false);
				return;
			}
		}
	}
}
Example #11
0
void MoveCursorFade(COMMAND_T* ct)
{
	double dPos = GetCursorPosition();
	dPos += fabs(*(double*)GetConfigVar("deffadelen")) * (double)ct->user; // Abs because neg value means "not auto"
	SetEditCurPos(dPos, true, false);
}