Exemplo n.º 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);
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
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;

}
Exemplo n.º 4
0
void _SeqIndexMetric::DrawOn(	BView* view, BRect clip,
								SeqSongWinPropertiesI& props,
								float fontHeight)
{
	BRect		b(0, mFrame.top, clip.right, mFrame.bottom);
	float		borderL = 1, borderR = 0;	
	float		bottomIndent = 5;
	float		stringIndent = 4;
	float		bot = mFrame.top + fontHeight + 2 + bottomIndent + stringIndent;
	if (bot < mFrame.bottom) b.bottom = bot;
	rgb_color	bgc = background_color();
	/* Drawn this way just to get pixel-perfect:  The very right edge of
	 * the view should always be drawn with the background color, regardless
	 * of whether or not the track is selected, because a couple pixels
	 * show through behind the mode buttons.
	 */
	if (props.Selections() && props.Selections()->IncludesTrack(mTrackId) ) {
		if (props.IsRecording() ) bgc = recording_highlight_color();
		else bgc = highlight_color();
		draw_background(view, b, bgc, borderL, borderR, bottomIndent);
		draw_background(view, BRect(b.right - 4, b.top, b.right, b.bottom), background_color(), borderL, borderR, bottomIndent);
	} else draw_background(view, b, bgc, borderL, borderR, bottomIndent);
	/* Clean up the cap
	 */
	float		absBottom = b.bottom - bottomIndent + 2;
	view->SetHighColor(0, 0, 0);
	view->StrokeLine( BPoint(0, b.top + 3), BPoint(0, absBottom) );
	/* Cap off if I'm larger then normal.
	 */
	float		fullBottom = mFrame.bottom - bottomIndent + 2;
	if (fullBottom > absBottom && clip.right >= mFrame.right) {
		view->StrokeLine(BPoint(mFrame.right, absBottom), BPoint(mFrame.right, fullBottom));
	}

	/* Draw the label
	 */
	view->SetLowColor(bgc);
	view->SetHighColor( Prefs().Color(AM_ARRANGE_FG_C) );
	if (mLabel.Length() > 0)
		view->DrawString(mLabel.String(), BPoint( b.left + borderL + 2, b.bottom - bottomIndent - stringIndent) );
	/* Draw the group indicator.
	 */
	if (mGroups > 0) {
		const char*	gname = group_name_from(mGroups);
		if (gname) {
			BPoint		mutePt = MuteRect().LeftTop();
			float		w = view->StringWidth("G9");
			view->DrawString(gname, BPoint(mutePt.x - w - 1, b.bottom - bottomIndent - stringIndent));
//			view->FillRect(BRect(b.left + borderL + 2, mFrame.top, b.left + borderL + 8, mFrame.bottom));
		}
	}
	/* Draw the mode buttons.
	 */
	if (mModeW > 0 && clip.right >= mFrame.right - mModeW) {
		BPoint		mutePt = MuteRect().LeftTop(),
					soloPt = SoloRect().LeftTop();

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

		if (mModeFlags&AmTrack::MUTE_MODE && gMuteOn) view->DrawBitmapAsync(gMuteOn, mutePt);
		else if (gMuteOff) view->DrawBitmapAsync(gMuteOff, mutePt);
		if (mModeFlags&AmTrack::SOLO_MODE && gSoloOn) view->DrawBitmapAsync(gSoloOn, soloPt);
		else if (gSoloOff) view->DrawBitmapAsync(gSoloOff, soloPt);

		view->SetDrawingMode(mode);
	}
}