示例#1
0
void
CPitchBendEventRenderer::Draw(
	const CEvent &ev,
	bool shadowed) const
{
	CDestination *dest = Editor()->TrackWindow()->Document()->FindDestination(ev.GetVChannel());
	BRect r;

	if (shadowed)
		Editor()->SetDrawingMode( B_OP_BLEND );
	
	Editor()->SetHighColor(dest->Color());
		
	if ((ev.Duration() > 0) && (ev.pitchBend.updatePeriod > 0))
	{
		Editor()->BeginLineArray(ev.Duration() / ev.pitchBend.updatePeriod);
		for (int i = ev.pitchBend.updatePeriod; i < ev.Duration(); i += ev.pitchBend.updatePeriod)
		{
			long v = ev.pitchBend.startBend - 0x2000
					 + ((ev.pitchBend.targetBend - ev.pitchBend.startBend)
					    * i / ev.Duration());
			BPoint point(Editor()->TimeToViewCoords(ev.Start() + i),
						 Editor()->ValueToViewCoords(v));
			Editor()->AddLine(point, point, Editor()->HighColor());
		}
		Editor()->EndLineArray();

		r.left = Editor()->TimeToViewCoords(ev.Stop() ) - 2.0;
		r.top = Editor()->ValueToViewCoords(ev.pitchBend.targetBend - 0x2000) - 2.0;
		r.right = r.left + 4.0;
		r.bottom = r.top + 4.0;
	
		Editor()->FillEllipse(r);

		r.InsetBy(-1.0, -1.0);
		if (ev.IsSelected() && !shadowed && Editor()->IsSelectionVisible())
			Editor()->SetHighColor(0, 0, 255);
		else
			Editor()->SetHighColor(0, 0, 0);
		Editor()->StrokeEllipse(r);
	}

	r.left = Editor()->TimeToViewCoords(ev.Start()) - 2.0;
	r.top = Editor()->ValueToViewCoords(ev.pitchBend.startBend - 0x2000) - 2.0;
	r.right = r.left + 4.0;
	r.bottom = r.top + 4.0;
	
	Editor()->SetHighColor(dest->Color());
	Editor()->FillEllipse(r);
	
	if (ev.IsSelected() && !shadowed && Editor()->IsSelectionVisible())
		Editor()->SetHighColor(0, 0, 255);
	else
		Editor()->SetHighColor(0, 0, 0);
	
	r.InsetBy(-1.0, -1.0);
	Editor()->StrokeEllipse(r);
}
示例#2
0
long
CPitchBendEventRenderer::Pick(
	const CEvent &ev,
	BPoint pickPt,
	short &partCode) const
{
	if (ev.Duration() > 0)
	{
		BPoint start(Editor()->TimeToViewCoords(ev.Start()),
					 Editor()->ValueToViewCoords(ev.pitchBend.startBend - 0x2000));
		BPoint stop(Editor()->TimeToViewCoords(ev.Stop()),
					Editor()->ValueToViewCoords(ev.pitchBend.targetBend - 0x2000));
	
		float best = MAX(fabs(pickPt.x - stop.x), fabs(pickPt.y - stop.y));
		float dist = MAX(fabs(pickPt.x - start.x), fabs(pickPt.y - start.y));

		partCode = Part_End;
		if (dist < best)
		{
			best = dist;
			partCode = Part_Start;
		}
		
		if (best > 3.0)
		{
			dist = MathUtils::DistanceFromPointToLine(pickPt, start, stop);
			if (dist < best)
			{
				best = dist + 2.0;
				partCode = Part_Whole;
			}
		}
		
		if (best > 8.0)
			return LONG_MAX;
		return static_cast<long>(best);
	}
	else
	{
		BPoint diff(pickPt.x - Editor()->TimeToViewCoords(ev.Start()),
					pickPt.y - Editor()->ValueToViewCoords(ev.pitchBend.startBend - 0x2000));

		if ((diff.y > 8) || (diff.y < -8) || (diff.x > 10) || (diff.x < -8))
			return LONG_MAX;
		
		if (diff.x >= 3.0)
			partCode = Part_End;
		else
			partCode = Part_Whole;

		return static_cast<long>(MAX(fabs(diff.x), fabs(diff.y)));
	}
}
示例#3
0
BRect
CPitchBendEventRenderer::Extent(
	const CEvent &ev) const
{
	float yStart = Editor()->ValueToViewCoords(ev.pitchBend.startBend - 0x2000);
	float yStop = Editor()->ValueToViewCoords(ev.pitchBend.targetBend - 0x2000);

	BRect r;
	r.left = Editor()->TimeToViewCoords(ev.Start()) - 5.0;
	r.right	= Editor()->TimeToViewCoords(ev.Stop()) + 5.0;
	r.bottom = MAX(yStart, yStop) + 5.0;
	r.top = MIN(yStart, yStop) - 5.0;

	return r;
}