static void shade_frame(int x, int y, int w, int h, const char *c, Fl_Color bc) { uchar *g = fl_gray_ramp(); int b = strlen(c) / 4 + 1; for (x += b, y += b, w -= 2 * b + 1, h -= 2 * b + 1; b > 1; b --) { // Draw lines around the perimeter of the button, 4 colors per // circuit. fl_color(shade_color(*c++, bc)); fl_line(x, y + h + b, x + w - 1, y + h + b, x + w + b - 1, y + h); fl_color(shade_color(*c++, bc)); fl_line(x + w + b - 1, y + h, x + w + b - 1, y, x + w - 1, y - b); fl_color(shade_color(*c++, bc)); fl_line(x + w - 1, y - b, x, y - b, x - b, y); fl_color(shade_color(*c++, bc)); fl_line(x - b, y, x - b, y + h, x, y + h + b); } }
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); }
static inline void draw_content_border( BView* view, BRect b, rgb_color clr, ArpLineArrayCache& lines, bool drawMuted, bool fillTop) { rgb_color c = tint_color(clr, B_LIGHTEN_2_TINT); if (drawMuted) c = shade_color(c, MUTE_SHADE); if (fillTop) { lines.AddLine(BPoint(b.left, b.top - 1), BPoint(b.right, b.top - 1), c); lines.AddLine(BPoint(b.left - 1, b.top - 1), BPoint(b.left - 1, b.top - 1), clr); lines.AddLine(BPoint(b.right + 1, b.top - 1), BPoint(b.right + 1, b.top - 1), clr); lines.AddLine(BPoint(b.left - 1, b.top), BPoint(b.left - 1, b.bottom), c); } else { lines.AddLine(BPoint(b.left - 1, b.top), BPoint(b.left - 1, b.bottom), c); } c = tint_color(clr, B_DARKEN_2_TINT); if (drawMuted) c = shade_color(c, MUTE_SHADE); lines.AddLine(BPoint(b.right + 1, b.top), BPoint(b.right + 1, b.bottom), c); lines.AddLine(BPoint(b.left, b.bottom + 1), BPoint(b.right + 1, b.bottom + 1), c); lines.AddLine(BPoint(b.left - 1, b.bottom + 1), BPoint(b.left - 1, b.bottom + 1), clr); }
void SeqPhraseMatrixView::DrawTopLevelPhrase( BRect clip, BView* view, const AmTrack* track, const AmPhraseEvent* event, AmTime end, AmPhraseEvent* topPhrase, AmPhraseRendererI* renderer) { ArpASSERT(event && topPhrase); if (!event || !event->Phrase() ) return; const AmPhrase* phrase = event->Phrase(); BRect entireF(0, clip.top + 3, 0, clip.bottom - 3); AmTime phraseEnd = event->EndTime(); BString n = event->Phrase()->Name(); float labelH = mCurLabelH + 3; bool drawLabel = mCurLabelH > 0 && labelH < entireF.Height() && n.Length() > 0; entireF.left = mMtc.TickToPixel(event->StartTime()) - 2; entireF.right = mMtc.TickToPixel(phraseEnd) + 2; BRect labelF = arp_invalid_rect(); BRect contentF = arp_invalid_rect(); if (drawLabel) { if (entireF.Height() - 4 > labelH + 4) { labelF.Set(entireF.left + 2, entireF.top + 2, entireF.right - 2, entireF.bottom - 2); contentF = labelF; labelF.bottom = labelF.top + labelH - 1; contentF.top = labelF.bottom + 1; } else labelF.Set(entireF.left + 2, entireF.top + 2, entireF.right - 2, entireF.bottom - 2); } else contentF.Set(entireF.left + 2, entireF.top + 2, entireF.right - 2, entireF.bottom - 2); rgb_color bgC = phrase->Color(phrase->BACKGROUND_C); rgb_color fgC = phrase->Color(phrase->FOREGROUND_C); if (mDrawMuted) { bgC = shade_color(bgC, MUTE_SHADE); fgC = shade_color(fgC, MUTE_SHADE); } if (arp_is_valid_rect(contentF) ) { /* Fill the background. */ if (!mDrawMuted) { view->SetHighColor(bgC); view->FillRect(contentF); } /* Draw the measure markers. */ AmTrackMeasureBackground bg(mSongRef, AmTrackRef(track), mMtc); if (mDrawMuted) bg.SetFlag(bg.DRAW_BEATS_FLAG, false); else { rgb_color c = weighted_shade(bgC, Prefs().Color(AM_MEASURE_FG_C), 5); bg.SetBeatColor(c); } bg.LockedDraw(view, contentF, track->Signatures() ); } mLines.BeginLineArray(); if (arp_is_valid_rect(labelF) ) { rgb_color c = weighted_shade(bgC, fgC, 3); view->SetHighColor(c); view->SetLowColor(c); view->FillRect(labelF); draw_label_border(view, labelF, c, mLines, mDrawMuted, !arp_is_valid_rect(contentF)); view->SetHighColor(Prefs().Color(AM_MEASURE_FG_C) ); BPoint pt(labelF.left + 2, labelF.bottom - 2); if (arp_is_valid_rect(contentF) ) pt.y -= 2; view->TruncateString(&n, B_TRUNCATE_END, labelF.Width() ); view->DrawString(n.String(), pt); } /* Shade the background. */ rgb_color c; c.red = c.green = c.blue = 0; if (mDrawMuted) c = shade_color(c, MUTE_SHADE); mLines.AddLine(BPoint(entireF.left + 1, entireF.top), BPoint(entireF.right - 1, entireF.top), c); mLines.AddLine(BPoint(entireF.left + 1, entireF.bottom), BPoint(entireF.right - 1, entireF.bottom), c); mLines.AddLine(BPoint(entireF.left, entireF.top + 1), BPoint(entireF.left, entireF.bottom - 1), c); mLines.AddLine(BPoint(entireF.right, entireF.top + 1), BPoint(entireF.right, entireF.bottom - 1), c); if (arp_is_valid_rect(contentF) ) { draw_content_border(view, contentF, bgC, mLines, mDrawMuted, !arp_is_valid_rect(labelF)); } c = tint_color(Prefs().Color(AM_DATA_BACKDROP_C), B_DARKEN_1_TINT); if (mDrawMuted) c = shade_color(c, MUTE_SHADE); if (!gPhraseBg) { mLines.AddLine(BPoint(entireF.right + 1, entireF.top + 2), BPoint(entireF.right + 1, entireF.bottom + 0), c); mLines.AddLine(BPoint(entireF.left + 2, entireF.bottom + 1), BPoint(entireF.right + 0, entireF.bottom + 1), c); mLines.AddLine(BPoint(entireF.right + 0, entireF.bottom + 0), BPoint(entireF.right + 0, entireF.bottom + 0), c); } /* Indicate if this phrase is linked. */ if (phrase->CountLinks() > 0) { view->SetHighColor(bgC); view->SetLowColor(0, 0, 0); view->StrokeRect(entireF, LINK_PATTERN); } if (arp_is_valid_rect(contentF) ) { /* Draw the events. */ if (renderer) { BRect trackR(clip.left, contentF.top, clip.right, contentF.bottom); view->SetHighColor(fgC); renderer->BeginTrack(trackR, view, track, mLines); renderer->DrawPhrase(contentF, view, track, event, end < phraseEnd ? end : phraseEnd, topPhrase, mLines); renderer->EndTrack(trackR, view, track, mLines); } } /* Finish. */ mLines.EndLineArray(); }
void Fl_Plastic_Box::draw(int x, int y, int w, int h, Fl_Color bc, Fl_Flags f) const { const char* c = (f & FL_VALUE) ? down->data() : data(); char buf[26]; if (f&FL_INACTIVE && Fl_Style::draw_boxes_inactive) { fl_to_inactive(c, buf); c = buf; } int i, j; int clen = strlen(c) - 1; int chalf = clen / 2; int cstep = 1; if (h < (w * 2)) { // Horizontal shading... if (clen >= h) cstep = 2; for (i = 0, j = 0; j < chalf; i ++, j += cstep) { // Draw the top line and points... fl_color(shade_color(c[i], bc)); fl_line(x + 1, y + i, x + w - 1, y + i); fl_color(shade_color(c[i] - 2, bc)); fl_point(x, y + i + 1); fl_point(x + w - 1, y + i + 1); // Draw the bottom line and points... fl_color(shade_color(c[clen - i], bc)); fl_line(x + 1, y + h - 1 - i, x + w - 1, y + h - 1 - i); fl_color(shade_color(c[clen - i] - 2, bc)); fl_point(x, y + h - i); fl_point(x + w - 1, y + h - i); } // Draw the interior and sides... i = chalf / cstep; fl_color(shade_color(c[chalf], bc)); fl_rectf(x + 1, y + i, w - 2, h - 2 * i); fl_color(shade_color(c[chalf] - 2, bc)); fl_line(x, y + i, x, y + h - i); fl_line(x + w - 1, y + i, x + w - 1, y + h - i); } else { // Vertical shading... if (clen >= w) cstep = 2; for (i = 0, j = 0; j < chalf; i ++, j += cstep) { // Draw the left line and points... fl_color(shade_color(c[i], bc)); fl_line(x + i, y + 1, x + i, y + h - 1); fl_color(shade_color(c[i] - 2, bc)); fl_point(x + i + 1, y); fl_point(x + i + 1, y + h - 1); // Draw the right line and points... fl_color(shade_color(c[clen - i], bc)); fl_line(x + w - 1 - i, y + 1, x + w - 1 - i, y + h - 1); fl_color(shade_color(c[clen - i] - 2, bc)); fl_point(x + w - 1 - i, y); fl_point(x + w - 1 - i, y + h - 1); } // Draw the interior, top, and bottom... i = chalf / cstep; fl_color(shade_color(c[chalf], bc)); fl_rectf(x + i, y + 1, w - 2 * i, h - 2); fl_color(shade_color(c[chalf - 2], bc)); fl_line(x + i, y, x + w - i, y); fl_line(x + i, y + h - 1, x + w - i, y + h); } }