Beispiel #1
0
void SeqToolBarView::CacheDrawingInfo()
{
	mPrefW = 0;
	mPrefH = 0;

	FreeCachedInfo();	
	toolref_vec			toolRefs;
	FillVec(toolRefs);

	for (uint32 k = 0; k < toolRefs.size(); k++) {
		// READ TOOL BLOCK
		const AmTool*	tool = toolRefs[k].ReadLock();
		if (tool) {
			BRect		b = tool->IconBounds();
			mPrefW += b.Width() + 1 + mSpace;
			if (b.Height() > mPrefH) mPrefH = b.Height();
			mCachedData.push_back( _SeqCachedTool(tool) );
		}
		toolRefs[k].ReadUnlock(tool);
		// END READ TOOL BLOCK
	}
	/* Oops, I'm empty, prepare myself to just draw a string.
	 */
	if (mCachedData.size() < 1) {
		mPrefW = 4 + StringWidth(EMPTY_STR) + 4;
		mPrefH = 4 + arp_get_font_height(this) + 4;
		return;
	}
	/* Extra space at the end to make it easier to drop in tools.
	 */
	mPrefW += LAST_BUTTON_PAD;
}
Beispiel #2
0
float arp_get_font_height(const BView* view)
{
	if (!view) return 0;
	BFont	font;
	view->GetFont(&font);
	return arp_get_font_height(&font);
}
void SeqPhrasePropertyWindow::AddViews(BRect frame)
{
	mBg = new BView(frame, "bg", B_FOLLOW_ALL, B_WILL_DRAW);
	if (!mBg) return;
	mBg->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
	AddChild(mBg);
	
	float		fh = arp_get_font_height(mBg);
	float		borderX = Prefs().Size(BORDER_X), borderY = Prefs().Size(BORDER_Y);
	float		spaceX = Prefs().Size(SPACE_X), spaceY = Prefs().Size(SPACE_Y);
	float		divider = mBg->StringWidth("Color:") + 10;
	/* The Name field.
	 */
	BRect		f(borderX, borderY, frame.Width() - borderX, borderY + fh);
	mNameCtrl = new BTextControl(f, "name_ctrl", "Name:", NULL, new BMessage(NAME_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mNameCtrl) {
		f.top = mNameCtrl->Frame().bottom;
		mNameCtrl->SetDivider(divider);
		mNameCtrl->MakeFocus(true);
		mNameCtrl->SetModificationMessage(new BMessage(NAME_MSG) );
		mBg->AddChild(mNameCtrl);
	}
	/* The Time field.
	 */
	f.top += spaceY;
	const char*		timeStr = "Time:";
	f.right = divider;
	f.bottom = f.top + fh;
	mTimeLabel = new BStringView(f, "time_label", timeStr, B_FOLLOW_LEFT | B_FOLLOW_TOP);
	if (mTimeLabel) mBg->AddChild(mTimeLabel);
	mTimeCtrl = new AmTimeView(mSongRef);
	if (mTimeCtrl) {
		mTimeCtrl->MoveTo(f.right + 5, f.top);
		mTimeCtrl->SetEnabled(false);
		mBg->AddChild(mTimeCtrl);
		mTimeCtrl->StartWatching(this, ARPMSG_TIME_VIEW_CHANGED);
		f.top = mTimeCtrl->Frame().bottom;
	}
	/* The color controls.
	 */
	f.top += spaceY;
	f.bottom = f.top + fh;
	f.right = frame.Width() - spaceX;
	mColorField = new_color_field(f);
	if (mColorField) {
		mColorField->SetDivider(divider);
		mBg->AddChild(mColorField);
		f.top = f.bottom;
	}

	mColorCtrl = new BColorControl(	BPoint(spaceX, f.top + spaceY + spaceY),
									B_CELLS_32x8, 2, "color_control",
									new BMessage(COLOR_CHANGED_MSG) );

	if (mColorCtrl) {
		mBg->AddChild(mColorCtrl);
	}

}
Beispiel #4
0
void SeqToolBarView::DrawOn(BView* view, BRect clip)
{
	view->SetHighColor(mViewC);
	view->FillRect(clip);
	if (gControlBg) arp_tile_bitmap_on(view, clip, gControlBg, Frame().LeftTop() );

	if (mCachedData.size() < 1) {
		view->SetHighColor( Prefs().Color(AM_CONTROL_FG_C) );
		view->DrawString(EMPTY_STR, BPoint(4, 4 + arp_get_font_height(this)) );
	}

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

#if 0
	if (mCachedData.size() >= 1 && mToolBarName.Length() > 0) {
		view->SetHighColor(0, 0, 0, 100);
		view->DrawString(mToolBarName.String(), BPoint(4, 4 + arp_get_font_height(this)) );
	}
#endif

	BPoint			pt(-1, -1);
	uint32			button;
	if (!is_valid(mDraggingRect)) GetMouse(&pt, &button, false);

	float			x  = 0;
	for (uint32 k = 0; k < mCachedData.size(); k++) {
		x = mCachedData[k].DrawOn(view, clip, x, pt);
		x += 1 + mSpace;
		if (x > clip.right) break;
	}
	if (is_valid(mDraggingRect)) {
		view->SetHighColor(0, 0, 0, 127);
		view->FillRect(mDraggingRect);
	}

	view->SetDrawingMode(mode);
}
BView* SeqEditMultiFilterWindow::NewGeneralView(BRect frame)
{
	BView*		v = new BView(frame, GENERAL_STR, B_FOLLOW_ALL, 0);
	if (!v) return NULL;
	v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
	float		fh = arp_get_font_height(v);
	float		spaceX = 5, spaceY = 5;
	float		divider = v->StringWidth("Author:") + 10;
	BRect		f(spaceX, 0, frame.Width() - spaceX, fh);
	/* The Name field.
	 */
	mNameCtrl = new BTextControl(f, "name_ctrl", "Name:", NULL, new BMessage(NAME_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mNameCtrl) {
		f.top = mNameCtrl->Frame().bottom;
		mNameCtrl->SetDivider(divider);
		mNameCtrl->MakeFocus(true);
		v->AddChild(mNameCtrl);
	}
	/* The Key field.
	 */
	f.top += spaceY;
	f.bottom = f.top + fh;
	mKeyCtrl = new BTextControl(f, "key_ctrl", "Key:", NULL, new BMessage(KEY_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mKeyCtrl) {
		f.top = mKeyCtrl->Frame().bottom;
		mKeyCtrl->SetDivider(divider);
		v->AddChild(mKeyCtrl);
	}
	/* The Author field.
	 */
	f.top += spaceY;
	f.bottom = f.top + fh;
	mAuthorCtrl = new BTextControl(f, "author_ctrl", "Author:", NULL, new BMessage(AUTHOR_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mAuthorCtrl) {
		f.top = mAuthorCtrl->Frame().bottom;
		mAuthorCtrl->SetDivider(divider);
		v->AddChild(mAuthorCtrl);
	}
	/* The Email field.
	 */
	f.top += spaceY;
	f.bottom = f.top + fh;
	mEmailCtrl = new BTextControl(f, "email_ctrl", "Email:", NULL, new BMessage(EMAIL_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mEmailCtrl) {
		f.top = mEmailCtrl->Frame().bottom;
		mEmailCtrl->SetDivider(divider);
		v->AddChild(mEmailCtrl);
	}

	return v;
}
void SeqSongIndexMatrixView::DrawOn(BView* view, BRect clip)
{
	view->SetHighColor(Prefs().Color(AM_DATA_BACKDROP_C) );
	view->FillRect(clip);

	SeqSongWinPropertiesI*		props = SongWinProperties();
	if (!props) return;

	float		fh = arp_get_font_height(view);
	
	for (uint32 k = 0; k < mMetrics.size(); k++) {
		if (mMetrics[k].mFrame.top <= clip.bottom && mMetrics[k].mFrame.bottom >= clip.top)
			mMetrics[k].DrawOn(view, clip, *props, fh);
	}
}
Beispiel #7
0
void ArpIntControl::GetPreferredSize(float *width, float *height)
{
	float		fh = arp_get_font_height(this);
	/* Hmm...  I use the INT_CTRL_Y size to determine the height of
	 * all  my int controls, but for some reason, the layout engine,
	 * which is the only thing that makes use of this method, ends up
	 * with controls that are one pixel smaller than all the other instaces.
	 */
	float		ih = float(Prefs().GetInt32(ARP_INTCTRL_Y) + 1);
	*height = (fh > ih) ? fh : ih;
	
	float		minW, maxW;
	get_control_spacing(this, &minW, &maxW);
	if (minW > maxW) maxW = minW;
	*width = maxW + mDivider;
}
BView* SeqEditMultiFilterWindow::NewDescriptionView(BRect frame)
{
	BView*			v = new BView(frame, DESCRIPTION_STR, B_FOLLOW_ALL, 0);
	if (!v) return NULL;
	v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );

	float			fh = arp_get_font_height(v);
	float			spaceX = 5, spaceY = 5;
	BRect			shortLabelR(spaceX, 0, frame.Width(), fh);
	BRect			shortR(spaceX, shortLabelR.bottom + spaceY, shortLabelR.right - Prefs().Size(V_SCROLLBAR_X) - 4, shortLabelR.bottom + spaceY + (fh * 3) + spaceY);
	BRect			longLabelR(spaceX, shortR.bottom + spaceY, shortLabelR.right, shortR.bottom + spaceY + fh);
	BRect			longR(spaceX, longLabelR.bottom + spaceY, shortR.right, frame.Height() - 2);

	BStringView*	sv = new BStringView(shortLabelR, "short_label", "Short description:");
	if (sv) v->AddChild(sv);
	sv = new BStringView(longLabelR, "long_label", "Long description:");
	if (sv) v->AddChild(sv);

	mShortDescriptionCtrl = new SeqDumbTextView(shortR, "short_descr", BRect(5, 5, shortR.Width() - 10, 0), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mShortDescriptionCtrl) {
		mShortDescriptionCtrl->SetModificationMessage(new BMessage(DESCRIPTION_MOD_MSG) );
		BScrollView*		sv = new BScrollView("short_scroll", mShortDescriptionCtrl,
												 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, 0, false, true);
		if (sv) v->AddChild(sv);
		else v->AddChild(mShortDescriptionCtrl);
	}
	mLongDescriptionCtrl = new SeqDumbTextView(longR, "long_descr", BRect(5, 5, shortR.Width() - 10, 0), B_FOLLOW_ALL);
	if (mLongDescriptionCtrl) {
		mLongDescriptionCtrl->SetModificationMessage(new BMessage(DESCRIPTION_MOD_MSG) );
		BScrollView*		sv = new BScrollView("long_scroll", mLongDescriptionCtrl,
												 B_FOLLOW_ALL, 0, false, true);
		if (sv) v->AddChild(sv);
		else v->AddChild(mLongDescriptionCtrl);
	}
	return v;
}
void ArpKnobPanel::LayoutVertical(	const char* name, const char* label, BMessage* message,
									int32 minValue, int32 maxValue,
									bool showIntControl, uint32 knobFlags, float labelWidth,
									float intControlWidth)
{
	const BFont*	font = be_plain_font;
	float			fh = arp_get_font_height(font);
	float			spaceY = 3;
	float			top = 0;
	float			widest = 0;		// Cache the widest view just to save ourselves an
									// extra iteration over the views
	/* Add label
	 */
	BStringView*	sv = 0;
	if( label ) {
		float		w = (labelWidth >= 0) ? labelWidth : font->StringWidth( label );
		sv = new BStringView(	BRect( 0, top, 0 + w, top + fh ),
								"label", label );
		if( sv ) {
			AddChild( sv );
			if( w > widest ) widest = w;
		}
		top += fh + spaceY;
	}
	/* Add knob
	 */
	float			knobW, knobH;
	if( knobFlags&ARP_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_X);
		knobH = Prefs().Size(KNOB_RING_Y);
	} else if( knobFlags&ARP_TIGHT_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_TIGHT_X);
		knobH = Prefs().Size(KNOB_RING_TIGHT_Y);
	} else {
		knobW = Prefs().Size(KNOB_X);
		knobH = Prefs().Size(KNOB_Y);
	}
	ArpKnobControl* knob = new ArpKnobControl(	BRect(0, top, knobW, top + knobH ),
												name, message, minValue, maxValue, knobFlags);
	if( knob ) {
		AddChild( knob );
		if( knobW > widest ) widest = knobW;
		top += knobH + spaceY;
	}
	/* Add int control
	 */
	ArpIntControl*	intCtrl = 0;
	if( showIntControl ) {
		float		w = (intControlWidth >= 0) ? intControlWidth : knobW;
		intCtrl = new ArpIntControl( BRect(0, top, w, top + Prefs().Size(INT_CTRL_Y) ),
									"int_control", 0, 0);
		if( intCtrl ) {
			intCtrl->SetLimits( minValue, maxValue );
			if( knob ) knob->SetIntControl( intCtrl );
			AddChild( intCtrl );
			if( w > widest ) widest = w;
		}
	}
	/* Now center everything based on the widest view.
	 */
	if( !sv && !intCtrl ) return;
	if( widest <= 0 ) return;

	BView*	view;
	for( view = ChildAt(0); view; view = view->NextSibling() ) {
		BRect	f = view->Frame();
		if( f.Width() < widest )
			view->MoveTo( (widest - f.Width()) / 2, f.top );
	}		
}
void ArpKnobPanel::LayoutHorizontal(const char* name, const char* label, BMessage* message,
									int32 minValue, int32 maxValue,
									bool showIntControl, uint32 knobFlags, float labelWidth,
									float intControlWidth)
{
	const BFont*	font = be_plain_font;
	float			fh = arp_get_font_height(font);
	float			spaceX = 8;
	float			left = 0;
	/* Add label
	 */
	BStringView*	sv = 0;
	if( label ) {
		float		w = (labelWidth >= 0) ? labelWidth : font->StringWidth( label );
		sv = new BStringView(	BRect( left, 0, left + w, 0 + fh ),
								"label", label );
		if( sv ) AddChild( sv );
		left += w + spaceX;
	}
	/* Add knob
	 */
	float			knobW, knobH;
	if( knobFlags&ARP_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_X);
		knobH = Prefs().Size(KNOB_RING_Y);
	} else if( knobFlags&ARP_TIGHT_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_TIGHT_X);
		knobH = Prefs().Size(KNOB_RING_TIGHT_Y);
	} else {
		knobW = Prefs().Size(KNOB_X);
		knobH = Prefs().Size(KNOB_Y);
	}
	ArpKnobControl* knob = new ArpKnobControl(	BRect(left, 0, left + knobW, 0 + knobH ),
												name, message, minValue, maxValue, knobFlags);
	if( knob ) {
		AddChild( knob );
		left += knobW + spaceX;
	}
	/* Add int control
	 */
	ArpIntControl*	intCtrl = 0;
	if( showIntControl ) {
		float		w = (intControlWidth >= 0) ? intControlWidth : knobW;
		intCtrl = new ArpIntControl( BRect(left, 0, left + w, 0 + Prefs().Size(INT_CTRL_Y) ),
									"int_control", 0, 0);
		if( intCtrl ) {
			intCtrl->SetLimits( minValue, maxValue );
			if( knob ) knob->SetIntControl( intCtrl );
			AddChild( intCtrl );
		}
	}
	/* Now center everything based on the tallest view.
	 */
	if( !sv && !intCtrl ) return;
	float	tallest = (knobH > fh) ? knobH : fh;

	BView*	view;
	for( view = ChildAt(0); view; view = view->NextSibling() ) {
		BRect	f = view->Frame();
		if( f.Height() < tallest )
			view->MoveTo( f.left, (tallest - f.Height()) / 2 );
	}		
}
Beispiel #11
0
void SeqPhraseMatrixView::DrawOn(BRect clip, BView* view)
{
    int32		labelH;
    if (seq_get_int32_preference(PHRASE_LABEL_HEIGHT_PREF, &labelH) != B_OK) labelH = 8;
    if (labelH < 6 || labelH > 50) labelH = 8;
    view->SetFontSize(float(labelH) );
    mCurLabelH = arp_get_font_height(view);

    if (gPhraseBg) arp_tile_bitmap_on(view, clip, gPhraseBg, BPoint(0,0) );
    else {
        view->SetHighColor( Prefs().Color(AM_DATA_BACKDROP_C) );
        view->FillRect(clip);
    }
    float				top = 0;
    const BRect			b( Bounds() );
    AmPhraseRendererI*	renderer = NULL;
    // READ SONG BLOCK
#ifdef AM_TRACE_LOCKS
    printf("SeqPhraseMatrixView::DrawOn() read lock\n");
    fflush(stdout);
#endif
    const AmSong*	song = mSongRef.ReadLock();
    if (song) {
        const AmTrack*	track;
        for (uint32 k = 0; (track = song->Track(k)) != NULL; k++) {
            float	bottom = top + track->PhraseHeight();
            if (top > clip.bottom) break;
            BRect	r(clip.left, top, clip.right, bottom);
            r.left -= 3;
            if (r.left < b.left) r.left = b.left;
            r.right += 3;
            if (r.right > b.right) r.right = b.right;
            if (r.Intersects(clip)) {
                renderer = get_phrase_renderer(track, mMtc);
                DrawOn(r, view, track, renderer);
                delete renderer;
            }
            top = bottom + 1;
        }
    }
    mSongRef.ReadUnlock(song);
    // END READ SONG BLOCK

    /* If the user is currently dragging a phrase over my area, draw that.
     */
    if (mDragMetric.IsValid() ) {
        float		left = mMtc.TickToPixel(mDragMetric.mRange.start);
        float		right = mMtc.TickToPixel(mDragMetric.mRange.end);
        drawing_mode	mode = view->DrawingMode();
        view->SetDrawingMode(B_OP_ALPHA);
        view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
        view->SetHighColor(0, 0, 0, 125);
        for (uint32 k = 0; k < mDragMetric.mSrcIndexes.size(); k++) {
            int32	dest = (int32)mDragMetric.mSrcIndexes[k] + ((int32)mDragMetric.mDestIndex - (int32)mDragMetric.mSrcIndex);
            if (dest >= 0 && dest < (int32)mTrackMetrics.size() ) {
                view->FillRect( BRect(left, mTrackMetrics[dest].mTop,
                                      right, mTrackMetrics[dest].mBottom) );
            }
        }
        view->SetDrawingMode(mode);
    }

    if (!gPhraseBg && top <= clip.bottom) {
        view->SetHighColor( Prefs().Color(AM_DATA_BACKDROP_C) );
        view->FillRect( BRect(clip.left, top, clip.right, clip.bottom) );
    }
    /* Draw the song position.
     */
    if (mSongPosition >= 0) {
        view->SetHighColor(0, 0, 0);
        view->StrokeLine( BPoint(mSongPosition, clip.top), BPoint(mSongPosition, clip.bottom) );
    }
}