示例#1
0
void SeqPhraseMatrixView::DrawOn(	BRect clip, BView* view, const AmTrack* track,
                                    AmPhraseRendererI* renderer)
{
    mDrawMuted = false;
    if ( track->ModeFlags()&track->MUTE_MODE && !(track->ModeFlags()&track->SOLO_MODE) )
        mDrawMuted = true;

    rgb_color	bgC = Prefs().Color(AM_DATA_BACKDROP_C);
    if (mDrawMuted) bgC = shade_color(bgC, BACKDROP_MUTE_SHADE);
    view->SetHighColor(bgC);
    if (!gPhraseBg) view->FillRect(clip);

    float	pipeTop = clip.top + ((clip.bottom - clip.top) / 2) - 3;
    seq_draw_hrz_pipe(view, clip.left, pipeTop, clip.right);

    drawing_mode	mode = view->DrawingMode();
    view->SetDrawingMode(B_OP_ALPHA);
    view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
    mLines.SetTarget(view);

    mSelectionRange.MakeInvalid();
    SeqSongWinPropertiesI*	win = dynamic_cast<SeqSongWinPropertiesI*>( Window() );
    bool		drawSelection = false;
    if (win) {
        SeqSongSelections*	selections = win->Selections();
        if (selections && selections->IncludesTrack( track->Id() ) ) {
            mSelectionRange = selections->TimeRange();
            drawSelection = true;
        }
    }

    if (drawSelection) {
        BRect				selectClip(clip);
        if (mSelectionRange.IsValid() ) {
            selectClip.left = mMtc.TickToPixel(mSelectionRange.start);
            selectClip.right = mMtc.TickToPixel(mSelectionRange.end);
        }
        rgb_color	bgC;
        if (win && win->IsRecording() ) bgC = Prefs().Color(AM_SONG_RECORD_SELECTION_C);
        else bgC = Prefs().Color(AM_SONG_SELECTION_C);
        view->SetHighColor(bgC);
        view->FillRect(selectClip);
    }
    view->SetDrawingMode(mode);
#if 0
    _AmBgMeasureBackground		bg( SongRef(), mTrackRef, *mMtc );
    bg.SetLeftIndent( mLeftIndent );
    bg.LockedDraw( view, clip, track->Signatures() );
#endif

    DrawTrack(clip, view, track, renderer);
}
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);
}