void SeqSongIndexMatrixView::MouseDown(BPoint where)
{
	mMouseDown = DOWN_ON_NOTHING;
	mMouseDownIndex = -1;
	mMouseDownOnMode = 0;
	/* There should never NOT be a props -- that's my window
	 * object, so it would be quite odd.
	 */
	SeqSongWinPropertiesI*		props = SongWinProperties();
	if (!props) return;

	_SeqIndexMetric*	metric = MetricAt(where, &mMouseDownIndex);
	if (!metric) {
		props->SetSelections(NULL);
		return;
	}
	mMouseDownOnMode = metric->ModeForPoint(where);
	if (mMouseDownOnMode != 0) {
		mMouseDown = DOWN_ON_MODE;
		return;
	}
	/* If there is a current selections object and it isn't
	 * empty, then I maintain it's time range, regardless of
	 * whether I'm adding to it or replacing it.
	 */
	SeqSongSelections*		selections = props->Selections();
	AmRange					curRange;
	bool					selectionsEmpty = true;
	if (selections && !selections->IsEmpty() ) {
		curRange = selections->TimeRange();
		selectionsEmpty = false;
	}
	
	selections = NULL;
	if (modifiers() & B_SHIFT_KEY) selections = props->Selections();
	if (selections) selections = selections->Copy();
	if (!selections) selections = SeqSongSelections::New();
	if (!selections) return;
	selections->SetTimeRange(curRange);

	if (selections->IncludesTrack(metric->mTrackId) ) {
		mMouseDown = DOWN_ON_SELECTED_TRACK;
		selections->RemoveTrack(metric->mTrackId);
	} else {
		mMouseDown = DOWN_ON_DESELECTED_TRACK;
		selections->AddTrack(metric->mTrackId);
	}
	
	props->SetSelections(selections);
}
void SeqSongIndexMatrixView::MouseMoved(BPoint where,
										uint32 code,
										const BMessage* dragMessage)
{
	int32		buttons = 0;
	Window()->CurrentMessage()->FindInt32("buttons", &buttons);
	if (buttons == 0) {
		if (mMouseDown != DOWN_ON_MODE) mMouseDown = DOWN_ON_NOTHING;
		return;
	}

	if (mMouseDown != DOWN_ON_SELECTED_TRACK && mMouseDown != DOWN_ON_DESELECTED_TRACK)
		return;
	if (mMouseDownIndex < 0) return;
	int32						metricIndex;
	_SeqIndexMetric*			metric = MetricAt(where, &metricIndex);
	if (!metric) return;
	/* There should never NOT be a props -- that's my window
	 * object, so it would be quite odd.
	 */
	SeqSongWinPropertiesI*		props = SongWinProperties();
	if (!props) return;

	/* The mouse down that initiated this drag should have guaranteed
	 * there's a selection object.  If there isn't, there's probably
	 * a memory problem, so I just fail.  I copy so that I'm not modifying
	 * the original selections object, which could cause confusion for
	 * the view updating routines.
	 */
	SeqSongSelections*			selections = props->Selections();
	if (!selections) return;
	selections = selections->Copy();
	if (!selections) return;
	/* If I'm selecting tracks, make sure every track between myself
	 * and the origin is selected.  If I'm deselecting, make sure they're
	 * deselected.
	 */
	bool						changes;
	if (mMouseDown == DOWN_ON_DESELECTED_TRACK)
		changes = SelectBetween(selections, mMouseDownIndex, metricIndex);
	else changes = DeselectBetween(selections, mMouseDownIndex, metricIndex);
	if (changes) props->SetSelections(selections);
	else delete selections;

}