From: <pst...@us...> - 2008-03-17 06:25:49
|
Revision: 327 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=327&view=rev Author: pstieber Date: 2008-03-16 23:25:43 -0700 (Sun, 16 Mar 2008) Log Message: ----------- 1. Added a bitmap to the track window to decrease flicker. This required a rework of the coordinates. Scrolling still isn't totally correct. This is a WIP. 2. Changed the way track storage was handled. 3. Changed some variable names to match my convention. Modified Paths: -------------- trunk/jazz/src/EventWindow.cpp trunk/jazz/src/EventWindow.h trunk/jazz/src/MouseAction.cpp trunk/jazz/src/PianoFrame.cpp trunk/jazz/src/PianoFrame.h trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/Song.cpp trunk/jazz/src/Song.h trunk/jazz/src/SynthesizerSettingsDialog.cpp trunk/jazz/src/TrackFrame.cpp trunk/jazz/src/TrackWindow.cpp trunk/jazz/src/TrackWindow.h Modified: trunk/jazz/src/EventWindow.cpp =================================================================== --- trunk/jazz/src/EventWindow.cpp 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/EventWindow.cpp 2008-03-17 06:25:43 UTC (rev 327) @@ -123,14 +123,10 @@ //void tCanvas::SetScrollRanges() //{ -// int w, h; -// EventWin->GetVirtSize(&w, &h); -// SetScrollbars(ScLine, ScLine, w/ScLine, h/ScLine, ScPage, ScPage); -//#ifdef wx_xt -// EnableScrolling(TRUE, TRUE); -//#else -// EnableScrolling(FALSE, FALSE); -//#endif +// int Width, Height; +// EventWin->GetVirtualEventSize(Width, Height); +// SetScrollbars(ScLine, ScLine, Width / ScLine, Height / ScLine); +// EnableScrolling(false, false); //} //void tCanvas::SetScrollPosition(int x, int y) @@ -161,16 +157,16 @@ mpFixedFont(0), hFixedFont(0), LittleBit(1), - hLine(0), - hTop(40), - wLeft(100), + mTrackHeight(0), + mTopInfoHeight(40), + mLeftInfoWidth(100), FontSize(12), ClocksPerPixel(36), UseColors(true), - xEvents(wLeft), - yEvents(hTop), - wEvents(0), - hEvents(0), + mEventsX(mLeftInfoWidth), + mEventsY(mTopInfoHeight), + mEventsWidth(0), + mEventsHeight(0), CanvasX(0), CanvasY(0), CanvasW(0), @@ -242,7 +238,7 @@ //void JZEventFrame::CreateCanvas() //{ // cout << "createcanvas\n"; -// int w, h; +// int w, h; // GetClientSize(&w, &h); // Canvas = new tCanvas(this, 0, 0, w, h); //} @@ -288,7 +284,7 @@ LittleBit = (int)(x/2); dc->GetTextExtent("HXWjgi", &x, &y); - hLine = (int)y + LittleBit; + mTrackHeight = (int)y + LittleBit; delete dc; */ } @@ -298,12 +294,10 @@ this onsize handler is supposed to take care of handling of the resizing the two subwindows sizes to they dont overlap */ - void JZEventFrame::OnSize(wxSizeEvent& event)//int w, int h) - { - // wxFrame::OnSize(event); +void JZEventFrame::OnSize(wxSizeEvent& Event) +{ + // wxFrame::OnSize(Event); - - //the below code is from the toolbar sample, the layoutchidlren function wxSize size = GetClientSize(); @@ -353,13 +347,13 @@ int JZEventFrame::x2Clock(int x) { - return (x - xEvents) * ClocksPerPixel + FromClock; + return (x - mEventsX) * ClocksPerPixel + FromClock; } int JZEventFrame::Clock2x(int clk) { - return xEvents + (clk - FromClock) / ClocksPerPixel; + return mEventsX + (clk - FromClock) / ClocksPerPixel; } int JZEventFrame::x2BarClock(int x, int next) @@ -378,32 +372,36 @@ int JZEventFrame::y2yLine(int y, int up) { if (up) - y += hLine; - y -= hTop; - y -= y % hLine; - y += hTop; + { + y += mTrackHeight; + } + y -= mTopInfoHeight; + y -= y % mTrackHeight; + y += mTopInfoHeight; return y; } int JZEventFrame::y2Line(int y, int up) { if (up) - y += hLine; - y -= hTop; - return y / hLine; + { + y += mTrackHeight; + } + y -= mTopInfoHeight; + return y / mTrackHeight; } int JZEventFrame::Line2y(int Line) { - return Line * hLine + hTop; + return Line * mTrackHeight + mTopInfoHeight; } void JZEventFrame::LineText(wxDC *dc, int x, int y, int w, const char *str, int h, bool down) { if (h <= 0) { - h = hLine; + h = mTrackHeight; y = y2yLine(y); } if (w && h) @@ -490,14 +488,13 @@ CanvasW = xc; CanvasH = yc; - xEvents = CanvasX + wLeft; - yEvents = CanvasY + hTop; - wEvents = CanvasW - wLeft; - hEvents = CanvasH - hTop; - //printf("EventWin::OnPaint: xe %ld, ye %ld, we %ld, he %ld\n", xEvents, yEvents, wEvents, hEvents); + mEventsX = CanvasX + mLeftInfoWidth; + mEventsY = CanvasY + mTopInfoHeight; + mEventsWidth = CanvasW - mLeftInfoWidth; + mEventsHeight = CanvasH - mTopInfoHeight; - FromLine = CanvasY / hLine; - ToLine = (CanvasY + CanvasH - hTop) / hLine; + FromLine = CanvasY / mTrackHeight; + ToLine = (CanvasY + CanvasH - mTopInfoHeight) / mTrackHeight; FromClock = CanvasX * ClocksPerPixel; ToClock = x2Clock(CanvasX + CanvasW); } @@ -522,7 +519,7 @@ int x; int y; e.GetPosition(&x, &y); - if (xEvents < x && x < xEvents + wEvents && yEvents < y && y < yEvents + hEvents) + if (mEventsX < x && x < mEventsX + mEventsWidth && mEventsY < y && y < mEventsY + mEventsHeight) { if (e.LeftDown()) { @@ -582,14 +579,13 @@ { } -void JZEventFrame::GetVirtSize(int *w, int *h) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZEventFrame::GetVirtualEventSize(int& Width, int& Height) { - int clk = Song->MaxQuarters * Song->TicksPerQuarter; - *w = clk / ClocksPerPixel + wLeft; - *h = 127 * hLine + hTop; - - - *w = 5000L; + int TotalClockTics = Song->MaxQuarters * Song->TicksPerQuarter; + Width = TotalClockTics / ClocksPerPixel + mLeftInfoWidth; + Height = 127 * mTrackHeight + mTopInfoHeight; } //----------------------------------------------------------------------------- @@ -608,7 +604,7 @@ if (Clock > FromClock && ToClock >= Song->MaxQuarters * Song->TicksPerQuarter) return; // int x = Clock2x(Clock); -// Canvas->SetScrollPosition(x - wLeft, CanvasY); +// Canvas->SetScrollPosition(x - mLeftInfoWidth, CanvasY); } if (!SnapSel->Active) // sets clipping @@ -641,22 +637,24 @@ /** draw the "play position", by placing a vertical line where the "play clock" is */ void JZEventFrame::DrawPlayPosition(wxDC* dc) { - if (!SnapSel->Active && PlayClock >= FromClock && PlayClock < ToClock) - { - // wxDC* dc=new wxClientDC(this); - // dc->SetLogicalFunction(wxXOR); + if (!SnapSel->Active && PlayClock >= FromClock && PlayClock < ToClock) + { +// wxDC* dc = new wxClientDC(this); +// dc->SetLogicalFunction(wxXOR); dc->SetBrush(*wxBLACK_BRUSH); dc->SetPen(*wxBLACK_PEN); int x = Clock2x(PlayClock); //cout<<"JZEventFrame::DrawPlayPosition play pos x "<<x<<" "<<FromClock<<" "<<ToClock<<endl; - //dc->DrawRectangle(x, CanvasY, 2*LittleBit, hTop); - dc->DrawLine(x, CanvasY,x, yEvents+hEvents); //draw a line, 2 pixwels wide - dc->DrawLine(x+1,CanvasY,x+1,yEvents+hEvents); + //dc->DrawRectangle(x, CanvasY, 2*LittleBit, mTopInfoHeight); + dc->DrawLine(x, CanvasY, x, mEventsY + mEventsHeight); //draw a line, 2 pixwels wide + dc->DrawLine(x + 1, CanvasY, x + 1, mEventsY + mEventsHeight); dc->SetLogicalFunction(wxCOPY); - } + } if (NextWin) + { NextWin->DrawPlayPosition(dc); + } } // ************************************************************************** @@ -668,7 +666,9 @@ if (!SnapSel->Selected) { if (msg == 0) + { msg = "please select some events first"; + } wxMessageBox((char *)msg, "Error", wxOK); return 0; } Modified: trunk/jazz/src/EventWindow.h =================================================================== --- trunk/jazz/src/EventWindow.h 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/EventWindow.h 2008-03-17 06:25:43 UTC (rev 327) @@ -103,21 +103,21 @@ wxFont* mpFixedFont; // remains with 12pt int hFixedFont; // Height of letters - int LittleBit; - int hLine; + int LittleBit; + int mTrackHeight; - int hTop; - int wLeft; - int FontSize; - int ClocksPerPixel; - bool UseColors; + int mTopInfoHeight; + int mLeftInfoWidth; + int FontSize; + int ClocksPerPixel; + bool UseColors; // Parameters changed, e.g. Song loaded virtual void Setup(); // filled by OnPaint() //wxDC *dc; - int xEvents, yEvents, wEvents, hEvents; + int mEventsX, mEventsY, mEventsWidth, mEventsHeight; int CanvasX, CanvasY, CanvasW, CanvasH; // canvas coords int FromClock, ToClock; int FromLine, ToLine; @@ -164,7 +164,7 @@ // Mixer-Dialog wxDialog* MixerForm; - virtual void GetVirtSize(int *w, int *h); + virtual void GetVirtualEventSize(int& Width, int& Height); // Edit-Menu Modified: trunk/jazz/src/MouseAction.cpp =================================================================== --- trunk/jazz/src/MouseAction.cpp 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/MouseAction.cpp 2008-03-17 06:25:43 UTC (rev 327) @@ -230,9 +230,9 @@ // in the parent window. void tSelection::Draw(wxDC& Dc) { - cout - << "tSelection::Draw ---------------------------------------------------" - << endl; +// cout +// << "tSelection::Draw ---------------------------------------------------" +// << endl; // Dc.DrawRectangle(100,100,100,100); // if (Selected) //we cant check for "selected" here, because... // { Modified: trunk/jazz/src/PianoFrame.cpp =================================================================== --- trunk/jazz/src/PianoFrame.cpp 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/PianoFrame.cpp 2008-03-17 06:25:43 UTC (rev 327) @@ -393,12 +393,12 @@ DialogBox = 0; MixerForm = 0; - hTop = 40; - wLeft = 100; - xEvents = wLeft; - yEvents = hTop; - wEvents = hEvents = 0; - hLine = 0; + mTopInfoHeight = 40; + mLeftInfoWidth = 100; + mEventsX = mLeftInfoWidth; + mEventsY = mTopInfoHeight; + mEventsWidth = mEventsHeight = 0; + mTrackHeight = 0; LittleBit = 1; FontSize = PianoFontSizes[1]; // Must be an entry in the array. @@ -426,9 +426,9 @@ mpToolBar->ToggleTool(MEN_SNAP_16, TRUE); nSnaps = 0; - for (int i = 0; i < MaxTracks; i++) + for (int i = 0; i < eMaxTrackCount; i++) { - FromLines[i] = 64; + mFromLines[i] = 64; } DrumFont = 0; @@ -479,6 +479,7 @@ { delete mpGuitarFrame; } + delete mpToolBar; } @@ -541,7 +542,7 @@ LittleBit = (int)(lx/2); dc->GetTextExtent("HXWjgi", &lx, &ly); - hLine = (int)ly + LittleBit; + mTrackHeight = (int)ly + LittleBit; delete dc; @@ -552,7 +553,7 @@ dc=new wxClientDC(Canvas); dc->SetFont(*mpFixedFont); dc->GetTextExtent("H", &x, &y); - hTop = hFixedFont + 2 * LittleBit; + mTopInfoHeight = hFixedFont + 2 * LittleBit; dc->SetFont(*mpFont); dc->GetTextExtent("H", &x, &y); @@ -564,7 +565,7 @@ dc->GetTextExtent("Low Conga mid 2 or so", &x, &y); wPiano = (int)x + LittleBit; - wLeft = wPiano; + mLeftInfoWidth = wPiano; delete dc; } @@ -583,7 +584,7 @@ void JZPianoFrame::NewPosition(int track, int clock) { - FromLines[TrackNr] = FromLine; + mFromLines[TrackNr] = FromLine; // change track if (track >= 0) @@ -597,7 +598,7 @@ if (clock >= 0) { int x = Clock2x(clock); - Canvas->SetScrollPosition(x - wLeft, Line2y(FromLines[TrackNr])); + Canvas->SetScrollPosition(x - mLeftInfoWidth, Line2y(mFromLines[TrackNr])); } // SN++ Ist geaendert. OnPaint zeichnet immer neu -> Bug Fix bei ZoomOut! @@ -1197,41 +1198,41 @@ dc->DestroyClippingRegion(); dc->SetBackground(*wxWHITE_BRUSH); DrawPlayPosition(dc); - SnapSel->Draw(*dc, xEvents, yEvents, wEvents, hEvents); + SnapSel->Draw(*dc, mEventsX, mEventsY, mEventsWidth, mEventsHeight); dc->Clear(); /////////////////////////////////////////////////////////////// // horizontal lines(ripped from drawpianoroll code) -// for (y = Line2y(FromLine); y < yEvents + hEvents; y += hLine) -// if (y > yEvents) // cheaper than clipping -// dc->DrawLine(xEvents+1, y, xEvents + wEvents, y); +// for (y = Line2y(FromLine); y < mEventsY + mEventsHeight; y += mTrackHeight) +// if (y > mEventsY) // cheaper than clipping +// dc->DrawLine(mEventsX+1, y, mEventsX + mEventsWidth, y); dc->SetPen(*wxGREY_PEN); wxBrush blackKeysBrush=wxBrush(wxColor(250,240,240),wxSOLID); int Pitch = 127 - FromLine; y = Line2y(FromLine); - while (Pitch >= 0 && y < yEvents + hEvents) + while (Pitch >= 0 && y < mEventsY + mEventsHeight) { if (IsBlack(Pitch)) { dc->SetBrush(blackKeysBrush);//*wxLIGHT_GREY_PEN - dc->DrawRectangle(CanvasX, y, 2000, hLine); + dc->DrawRectangle(CanvasX, y, 2000, mTrackHeight); } else if ((Pitch % 12) == 0) { dc->SetPen(*wxCYAN_PEN); - dc->DrawLine(CanvasX, y + hLine, 2000, y + hLine); + dc->DrawLine(CanvasX, y + mTrackHeight, 2000, y + mTrackHeight); } else if (!IsBlack(Pitch - 1)) { dc->SetPen(*wxGREEN_PEN); - dc->DrawLine(CanvasX, y + hLine, 2000, y + hLine); + dc->DrawLine(CanvasX, y + mTrackHeight, 2000, y + mTrackHeight); } - y += hLine; + y += mTrackHeight; --Pitch; } @@ -1241,7 +1242,7 @@ MouseLine = -1; - #define VLine(x) DrawLine(x, CanvasY, x, yEvents+hEvents) + #define VLine(x) DrawLine(x, CanvasY, x, mEventsY + mEventsHeight) #define HLine(y) DrawLine(CanvasX, y, CanvasX + CanvasW, y) dc->SetPen(*wxBLACK_PEN); @@ -1249,11 +1250,11 @@ // vertical lines dc->VLine(xPiano); - dc->VLine(xEvents); - dc->VLine(xEvents-1); - dc->HLine(yEvents); - dc->HLine(yEvents-1); - dc->HLine(yEvents + hEvents); + dc->VLine(mEventsX); + dc->VLine(mEventsX-1); + dc->HLine(mEventsY); + dc->HLine(mEventsY-1); + dc->HLine(mEventsY + mEventsHeight); // draw vlines and bar numbers @@ -1270,11 +1271,11 @@ int i; dc->SetPen(*wxBLACK_PEN); sprintf(buf, "%d", BarInfo.BarNr + 1 - intro); - if (x > xEvents) + if (x > mEventsX) { - dc->DrawText(buf, x + LittleBit, yEvents - hFixedFont - 2); + dc->DrawText(buf, x + LittleBit, mEventsY - hFixedFont - 2); dc->SetPen(*wxGREY_PEN); - dc->DrawLine(x, yEvents - hFixedFont, x, yEvents+hEvents); + dc->DrawLine(x, mEventsY - hFixedFont, x, mEventsY + mEventsHeight); } dc->SetPen(*wxLIGHT_GREY_PEN); @@ -1282,13 +1283,15 @@ { clk += BarInfo.TicksPerBar / BarInfo.CountsPerBar; x = Clock2x(clk); - if (x > xEvents) - dc->DrawLine(x, yEvents+1, x, yEvents+hEvents); + if (x > mEventsX) + { + dc->DrawLine(x, mEventsY + 1, x, mEventsY + mEventsHeight); + } } BarInfo.Next(); } - LineText(dc, CanvasX, CanvasY, wPiano, hTop); + LineText(dc, CanvasX, CanvasY, wPiano, mTopInfoHeight); dc->SetPen(*wxBLACK_PEN); DrawPianoRoll(dc); @@ -1309,7 +1312,7 @@ sbrush.SetColour(230,255,230); #endif - //dc->SetClippingRegion(xEvents, yEvents, wEvents, hEvents); + //dc->SetClippingRegion(mEventsX, mEventsY, mEventsWidth, mEventsHeight); dc->SetLogicalFunction(wxXOR); dc->SetPen(*wxTRANSPARENT_PEN); @@ -1326,13 +1329,13 @@ HBChord scale = context->Scale(); int x = Clock2x(start); - if (x < xEvents) // clip to left border - x = xEvents; + if (x < mEventsX) // clip to left border + x = mEventsX; int w = Clock2x(stop) - x; if (w <= 0) continue; - int h = hLine; + int h = mTrackHeight; for (int i = 0; i < 12; i++) { int pitch = i; @@ -1351,7 +1354,7 @@ while (pitch < 127) { int y = Pitch2y(pitch); - if (y >= yEvents && y <= yEvents + hEvents - h) // y-clipping + if (y >= mEventsY && y <= mEventsY + mEventsHeight - h) // y-clipping { dc->DrawRectangle(x, y, w, h); } @@ -1409,7 +1412,7 @@ dc->SetBrush(*wxBLACK_BRUSH); dc->SetBackground(*wxWHITE_BRUSH); // xor-bug - SnapSel->Draw(*dc, xEvents, yEvents, wEvents, hEvents); + SnapSel->Draw(*dc, mEventsX, mEventsY, mEventsWidth, mEventsHeight); DrawPlayPosition(dc); //OBSOLETE dc->EndDrawing(); @@ -1423,7 +1426,7 @@ char buf[20]; dc->SetBrush(*wxLIGHT_GREY_BRUSH); - dc->DrawRectangle(xPiano, yEvents, wPiano, hEvents); //draw grey bg for keyboard + dc->DrawRectangle(xPiano, mEventsY, wPiano, mEventsHeight); //draw grey bg for keyboard dc->SetBrush(*wxBLACK_BRUSH); // dc->SetTextBackground(*wxLIGHT_GREY); @@ -1439,45 +1442,45 @@ { dc->SetFont(*mpFixedFont); - while (Pitch >= 0 && y < yEvents + hEvents) + while (Pitch >= 0 && y < mEventsY + mEventsHeight) { if (IsBlack(Pitch)) { - dc->DrawRectangle(CanvasX, y, wBlack, hLine); - dc->DrawLine(CanvasX + wBlack, y + hLine/2, CanvasX + wPiano, y + hLine/2); + dc->DrawRectangle(CanvasX, y, wBlack, mTrackHeight); + dc->DrawLine(CanvasX + wBlack, y + mTrackHeight/2, CanvasX + wPiano, y + mTrackHeight/2); dc->SetPen(*wxWHITE_PEN); - dc->DrawLine(CanvasX + wBlack+1, y + hLine/2+1, CanvasX + wPiano, y + hLine/2+1); + dc->DrawLine(CanvasX + wBlack+1, y + mTrackHeight/2+1, CanvasX + wPiano, y + mTrackHeight/2+1); dc->DrawLine(CanvasX, y, CanvasX + wBlack, y); dc->SetPen(*wxBLACK_PEN); } else if ((Pitch % 12) == 0) { - dc->DrawLine(CanvasX, y + hLine, CanvasX + wPiano, y + hLine); + dc->DrawLine(CanvasX, y + mTrackHeight, CanvasX + wPiano, y + mTrackHeight); dc->SetPen(*wxWHITE_PEN); - dc->DrawLine(CanvasX, y + hLine+1, CanvasX + wPiano, y + hLine+1); + dc->DrawLine(CanvasX, y + mTrackHeight + 1, CanvasX + wPiano, y + mTrackHeight + 1); dc->SetPen(*wxBLACK_PEN); sprintf(buf, "%d", Pitch / 12); - dc->DrawText(buf, CanvasX + wBlack + LittleBit, y + hLine / 2); + dc->DrawText(buf, CanvasX + wBlack + LittleBit, y + mTrackHeight / 2); } else if (!IsBlack(Pitch - 1)) { - dc->DrawLine(CanvasX, y + hLine, CanvasX + wPiano, y + hLine); + dc->DrawLine(CanvasX, y + mTrackHeight, CanvasX + wPiano, y + mTrackHeight); dc->SetPen(*wxWHITE_PEN); - dc->DrawLine(CanvasX, y + hLine+1, CanvasX + wPiano, y + hLine+1); + dc->DrawLine(CanvasX, y + mTrackHeight + 1, CanvasX + wPiano, y + mTrackHeight + 1); dc->SetPen(*wxBLACK_PEN); } - y += hLine; + y += mTrackHeight; --Pitch; } } else if (Track->GetAudioMode()) { dc->SetFont(*DrumFont); - while (Pitch >= 0 && y < yEvents + hEvents) + while (Pitch >= 0 && y < mEventsY + mEventsHeight) { dc->DrawText(gpMidiPlayer->GetSampleName(Pitch), CanvasX + LittleBit, y); - y += hLine; + y += mTrackHeight; --Pitch; } } @@ -1487,14 +1490,14 @@ if (VisibleKeyOn && VisibleDrumNames) { dc->SetFont(*DrumFont); - while (Pitch >= 0 && y < yEvents + hEvents) + while (Pitch >= 0 && y < mEventsY + mEventsHeight) { dc->DrawText( gpConfig->DrumName(Pitch + 1).first.c_str(), CanvasX + LittleBit, y); - y += hLine; + y += mTrackHeight; --Pitch; } @@ -1502,41 +1505,41 @@ else if (VisibleController) { dc->SetFont(*DrumFont); - while (Pitch >= 0 && y < yEvents + hEvents) + while (Pitch >= 0 && y < mEventsY + mEventsHeight) { dc->DrawText( gpConfig->CtrlName(Pitch + 1).first.c_str(), CanvasX + LittleBit, y); - y += hLine; + y += mTrackHeight; --Pitch; } } else if (VisibleProgram) { dc->SetFont(*DrumFont); - while (Pitch >= 0 && y < yEvents + hEvents) + while (Pitch >= 0 && y < mEventsY + mEventsHeight) { dc->DrawText( gpConfig->VoiceName(Pitch + 1).first.c_str(), CanvasX + LittleBit, y); - y += hLine; + y += mTrackHeight; --Pitch; } } else if (VisibleSysex) { dc->SetFont(*DrumFont); - while (Pitch >= 0 && y < yEvents + hEvents) + while (Pitch >= 0 && y < mEventsY + mEventsHeight) { dc->DrawText( tSynthSysex::GetSysexGroupName(Pitch + 1), CanvasX + LittleBit, y); - y += hLine; + y += mTrackHeight; --Pitch; } } @@ -1571,7 +1574,7 @@ if (!xoor) { dc->SetBrush(*wxWHITE_BRUSH); - dc->DrawRectangle(x, y + LittleBit, length, hLine - 2 * LittleBit); + dc->DrawRectangle(x, y + LittleBit, length, mTrackHeight - 2 * LittleBit); } // show velocity as colors @@ -1587,7 +1590,7 @@ } // end velocity colors - dc->DrawRectangle(x, y + LittleBit, length, hLine - 2 * LittleBit); + dc->DrawRectangle(x, y + LittleBit, length, mTrackHeight - 2 * LittleBit); if (xoor) { @@ -1602,7 +1605,7 @@ void JZPianoFrame::DrawEvents(wxDC* dc, tTrack *t, int Stat, const wxBrush* Brush, int force_color) { - //dc->SetClippingRegion(xEvents, yEvents, wEvents, hEvents); + //dc->SetClippingRegion(mEventsX, mEventsY, mEventsWidth, mEventsHeight); dc->SetBrush(*Brush); tEventIterator Iterator(t); @@ -1635,10 +1638,10 @@ { int DrawLength = Length/ClocksPerPixel; // do clipping ourselves - if (x1 < xEvents) + if (x1 < mEventsX) { - DrawLength -= xEvents - x1; - x1 = xEvents; + DrawLength -= mEventsX - x1; + x1 = mEventsX; } // Always draw at least two pixels to avoid invisible (behind a // vertical line) or zero-length events: @@ -1659,7 +1662,7 @@ } // end velocity colors - dc->DrawRectangle(x1, y1 + LittleBit, DrawLength, hLine - 2 * LittleBit); + dc->DrawRectangle(x1, y1 + LittleBit, DrawLength, mTrackHeight - 2 * LittleBit); //shouldnt it be in drawevent? odd. if (pEvent->IsPlayTrack()) @@ -1694,8 +1697,8 @@ dc->GetTextExtent((const char*)pEvent->IsText()->GetText(), &textX, &textY); dc->SetBrush(*wxWHITE_BRUSH); - int textlabely=CanvasY+hTop;//text labels drawn at top - dc->DrawRectangle(x1-textX, textlabely + LittleBit, textX, textY);//hLine - 2 * LittleBit); + int textlabely = CanvasY + mTopInfoHeight;//text labels drawn at top + dc->DrawRectangle(x1-textX, textlabely + LittleBit, textX, textY);//mTrackHeight - 2 * LittleBit); dc->DrawText(buf, x1-textX, textlabely + LittleBit); } } @@ -2466,7 +2469,7 @@ r.x = CanvasX + LittleBit; r.y = CanvasY; r.SetWidth(wPiano - 2 * LittleBit); - r.SetHeight(hTop); + r.SetHeight(mTopInfoHeight); tVelocCounter *VelocCounter = new tVelocCounter(this, &r, k); VelocCounter->Event(Event); @@ -2502,12 +2505,12 @@ if (MouseLine >= 0) { // Erase the previous highlight. - dc.DrawRectangle(xPiano, Line2y(MouseLine) + LittleBit, wPiano, hLine - 2 * LittleBit); + dc.DrawRectangle(xPiano, Line2y(MouseLine) + LittleBit, wPiano, mTrackHeight - 2 * LittleBit); } MouseLine = line; // Draw the new position. - dc.DrawRectangle(xPiano, Line2y(MouseLine) + LittleBit, wPiano, hLine - 2*LittleBit); + dc.DrawRectangle(xPiano, Line2y(MouseLine) + LittleBit, wPiano, mTrackHeight - 2*LittleBit); dc.SetLogicalFunction(wxCOPY); } @@ -2533,13 +2536,13 @@ int x, y; LogicalMousePosition(Event, &x, &y); - if (y > yEvents) // click in event area? + if (y > mEventsY) // click in event area? { if (xPiano < x && x < xPiano + wPiano) { MousePiano(Event); } - else if (xEvents < x && x < xEvents + wEvents) + else if (mEventsX < x && x < mEventsX + mEventsWidth) { MouseEvents(Event); } @@ -2548,7 +2551,7 @@ OnEventWinMouseEvent(Event); } } - else if (x > xEvents) + else if (x > mEventsX) { // click in top line int action = MousePlay.Action(Event); @@ -2730,7 +2733,7 @@ { SnapSel->SetXSnap(0,0,0); } - SnapSel->SetYSnap(FromLine * hLine + hTop, yEvents + hEvents, hLine); + SnapSel->SetYSnap(FromLine * mTrackHeight + mTopInfoHeight, mEventsY + mEventsHeight, mTrackHeight); } @@ -2840,7 +2843,7 @@ } int x = Clock2x(Clock); - Canvas->SetScrollPosition(x - wLeft, CanvasY); + Canvas->SetScrollPosition(x - mLeftInfoWidth, CanvasY); } if (!SnapSel->Active) // sets clipping @@ -2878,9 +2881,9 @@ dc->SetBrush(*wxBLACK_BRUSH); dc->SetPen(*wxBLACK_PEN); int x = Clock2x(PlayClock); - //dc->DrawRectangle(x, CanvasY, 2*LittleBit, hTop); - dc->DrawLine(x, CanvasY,x, yEvents+hEvents); //draw a line, 2 pixwels wide - dc->DrawLine(x+1,CanvasY,x+1,yEvents+hEvents); + //dc->DrawRectangle(x, CanvasY, 2*LittleBit, mTopInfoHeight); + dc->DrawLine(x, CanvasY,x, mEventsY + mEventsHeight); //draw a line, 2 pixwels wide + dc->DrawLine(x+1,CanvasY,x+1,mEventsY + mEventsHeight); dc->SetLogicalFunction(wxCOPY); } } @@ -2892,12 +2895,12 @@ int JZPianoFrame::Clock2x(int clk) { - return xEvents + (clk - FromClock) / ClocksPerPixel; + return mEventsX + (clk - FromClock) / ClocksPerPixel; } int JZPianoFrame::Line2y(int Line) { - return Line * hLine + hTop; + return Line * mTrackHeight + mTopInfoHeight; } void JZPianoFrame::ActSettingsDialog(wxCommandEvent& Event) @@ -3048,15 +3051,17 @@ int JZPianoFrame::x2Clock(int x) { - return (x - xEvents) * ClocksPerPixel + FromClock; + return (x - mEventsX) * ClocksPerPixel + FromClock; } int JZPianoFrame::y2Line(int y, int up) { if (up) - y += hLine; - y -= hTop; - return y / hLine; + { + y += mTrackHeight; + } + y -= mTopInfoHeight; + return y / mTrackHeight; } int JZPianoFrame::x2BarClock(int x, int next) @@ -3078,7 +3083,7 @@ int x; int y; LogicalMousePosition(Event, &x, &y); - if (xEvents < x && x < xEvents + wEvents && yEvents < y && y < yEvents + hEvents) + if (mEventsX < x && x < mEventsX + mEventsWidth && mEventsY < y && y < mEventsY + mEventsHeight) { if (Event.LeftDown()) { @@ -3125,13 +3130,13 @@ CanvasW = xc; CanvasH = yc; - xEvents = CanvasX + wLeft; - yEvents = CanvasY + hTop; - wEvents = CanvasW - wLeft; - hEvents = CanvasH - hTop; + mEventsX = CanvasX + mLeftInfoWidth; + mEventsY = CanvasY + mTopInfoHeight; + mEventsWidth = CanvasW - mLeftInfoWidth; + mEventsHeight = CanvasH - mTopInfoHeight; - FromLine = CanvasY / hLine; - ToLine = (CanvasY + CanvasH - hTop) / hLine; + FromLine = CanvasY / mTrackHeight; + ToLine = (CanvasY + CanvasH - mTopInfoHeight) / mTrackHeight; FromClock = CanvasX * ClocksPerPixel; ToClock = x2Clock(CanvasX + CanvasW); } @@ -3139,18 +3144,22 @@ int JZPianoFrame::y2yLine(int y, int up) { if (up) - y += hLine; - y -= hTop; - y -= y % hLine; - y += hTop; + { + y += mTrackHeight; + } + y -= mTopInfoHeight; + y -= y % mTrackHeight; + y += mTopInfoHeight; return y; } -void JZPianoFrame::GetVirtSize(int *w, int *h) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZPianoFrame::GetVirtualEventSize(int& Width, int& Height) { - int clk = Song->MaxQuarters * Song->TicksPerQuarter; - *w = clk / ClocksPerPixel + wLeft; - *h = 127 * hLine + hTop; + int TotalClockTics = Song->MaxQuarters * Song->TicksPerQuarter; + Width = TotalClockTics / ClocksPerPixel + mLeftInfoWidth; + Height = 127 * mTrackHeight + mTopInfoHeight; } bool JZPianoFrame::OnCharHook(wxKeyEvent& Event) @@ -3258,7 +3267,7 @@ void JZPianoFrame::ButtonLabelDisplay(const wxString& Text, bool IsButtonDown) { wxClientDC Dc(Canvas); - LineText(&Dc, 0, 0, wPiano, hTop, Text, IsButtonDown); + LineText(&Dc, 0, 0, wPiano, mTopInfoHeight, Text, IsButtonDown); } Modified: trunk/jazz/src/PianoFrame.h =================================================================== --- trunk/jazz/src/PianoFrame.h 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/PianoFrame.h 2008-03-17 06:25:43 UTC (rev 327) @@ -77,7 +77,7 @@ int xSnaps[MaxSnaps]; - int FromLines[MaxTracks]; + int mFromLines[eMaxTrackCount]; int IsVisible(JZEvent *e); int IsVisible(tTrack *t); @@ -215,7 +215,7 @@ int OnEventWinMouseEvent(wxMouseEvent &e); void OnEventWinPaintSub(int x, int y); int y2yLine(int y, int up = 0); - void GetVirtSize(int *w, int *h); + void GetVirtualEventSize(int& Width, int& Height); bool OnCharHook(wxKeyEvent& e); JZPianoWindow *Canvas; @@ -227,12 +227,12 @@ wxFont* mpFont; wxFont* mpFixedFont; //remains with 12pt/ bleibt bei 12pt int hFixedFont; //Height letters/ Hoehe eines Buchstaben - int hTop; - int wLeft; + int mTopInfoHeight; + int mLeftInfoWidth; int LittleBit; int FromLine, ToLine; - int hLine; - int xEvents, yEvents, wEvents, hEvents; + int mTrackHeight; + int mEventsX, mEventsY, mEventsWidth, mEventsHeight; int CanvasX, CanvasY, CanvasW, CanvasH; // canvas coords int FromClock, ToClock; tSnapSelection* SnapSel; Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/PianoWindow.cpp 2008-03-17 06:25:43 UTC (rev 327) @@ -94,10 +94,10 @@ void JZPianoWindow::SetScrollRanges() { - int w, h; - mpPianoFrame->GetVirtSize(&w, &h); - SetScrollbars(ScLine, ScLine, w/ScLine, h/ScLine, ScPage, ScPage); - EnableScrolling(FALSE, FALSE); + int Width, Height; + mpPianoFrame->GetVirtualEventSize(Width, Height); + SetScrollbars(ScLine, ScLine, Width / ScLine, Height / ScLine); + EnableScrolling(false, false); } void JZPianoWindow::SetScrollPosition(int x, int y) Modified: trunk/jazz/src/Song.cpp =================================================================== --- trunk/jazz/src/Song.cpp 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/Song.cpp 2008-03-17 06:25:43 UTC (rev 327) @@ -31,50 +31,48 @@ #include "Metronome.h" -JZSong::~JZSong() -{ - int i; - Clear(); - for (i = 0; i < MaxTracks; i++) - { - delete Tracks[i]; - } -} - JZSong::JZSong() + : mTracks() { - int i; - nTracks = MaxTracks; + nTracks = eMaxTrackCount; TicksPerQuarter = 120; intro_length = 0; - for (i = 0; i < MaxTracks; i++) - Tracks[i] = new tTrack(); - MaxQuarters = 100 * 4; // start with 100 bars ... + + // Start with 100 measures of 4:4 time. + MaxQuarters = 100 * 4; } +JZSong::~JZSong() +{ + Clear(); +} + void JZSong::Clear() { for (int i = 0; i < nTracks; i++) - Tracks[i]->Clear(); - nTracks = MaxTracks; + { + mTracks[i].Clear(); + } + nTracks = eMaxTrackCount; } int JZSong::Speed() { - return Tracks[0]->GetDefaultSpeed(); + return mTracks[0].GetDefaultSpeed(); } void JZSong::Read(tReadBase &io, const char *fname) { int i; wxBeginBusyCursor(); - for (i = 0; i < MaxTracks; i++) { - // cout << Tracks<<"\n"; - Tracks[i]->Clear(); + for (i = 0; i < eMaxTrackCount; ++i) + { + mTracks[i].Clear(); } int n = io.Open(fname); - for (i = 0; i < n && i < MaxTracks; i++) { - Tracks[i]->Read(io); + for (i = 0; i < n && i < eMaxTrackCount; ++i) + { + mTracks[i].Read(io); } io.Close(); TicksPerQuarter = io.TicksPerQuarter; @@ -102,9 +100,9 @@ void JZSong::Write(tWriteBase &io, const char *fname) { // Make sure track 0 has a synth reset - if (!Tracks[0]->Reset) + if (!mTracks[0].Reset) { - Tracks[0]->Reset = gpSynth->Reset()->IsSysEx(); + mTracks[0].Reset = gpSynth->Reset()->IsSysEx(); } int n = NumUsedTracks(); @@ -114,8 +112,10 @@ } wxBeginBusyCursor(); - for (int i = 0; i < n; i++) - Tracks[i]->Write(io); + for (int i = 0; i < n; ++i) + { + mTracks[i].Write(io); + } io.Close(); wxEndBusyCursor(); } @@ -124,7 +124,9 @@ tTrack *JZSong::GetTrack(int Nr) { if (Nr >= 0 && Nr < nTracks) - return Tracks[Nr]; + { + return &mTracks[Nr]; + } return 0; } @@ -134,9 +136,11 @@ int max = 0; for (int i = 0; i < nTracks; i++) { - int clk = Tracks[i]->GetLastClock(); + int clk = mTracks[i].GetLastClock(); if (clk > max) + { max = clk; + } } return max; } @@ -191,28 +195,30 @@ int solo = 0; for (i = 0; i < nTracks; i++) { - if (Tracks[i]->State == tsSolo) + if (mTracks[i].State == tsSolo) { solo = 1; break; } } - for (i = 0; i < nTracks; i++) + for (i = 0; i < nTracks; ++i) { - tTrack *t = Tracks[i]; - if (t->State == tsSolo || (!solo && t->State == tsPlay)) + tTrack* pTrack = &mTracks[i]; + if (pTrack->State == tsSolo || (!solo && pTrack->State == tsPlay)) { - if (t->GetAudioMode() != mode) + if (pTrack->GetAudioMode() != mode) + { continue; + } - tEventIterator Iterator(Tracks[i]); + tEventIterator Iterator(&mTracks[i]); JZEvent *e = Iterator.Range(FrClock, ToClock); while (e) { JZEvent *c = e->Copy(); c->SetClock(c->GetClock() + delta); - c->SetDevice(t->GetDevice()); + c->SetDevice(pTrack->GetDevice()); Destin->Put(c); if(c->IsPlayTrack()) @@ -239,21 +245,21 @@ if(recursionDepth>100) //yes yes, you should use symbolics... return; fprintf(stderr, "playtrack %d\n",c->track); - tTrack *t=Tracks[c->track];//the track we want to play - tEventIterator IteratorPL(t); //get an iterator of all events the playtrack is pointing to + tTrack* pTrack = &mTracks[c->track];//the track we want to play + tEventIterator IteratorPL(pTrack); //get an iterator of all events the playtrack is pointing to JZEvent *f; //FIXME this is just to test the idea, it would be good to modify getlastclock instead i think //find an EOT event, otherwise default to the last clock(should be + length of the last event as well) int loopLength = 0; - tEventIterator IteratorEOT(t); //get an iterator of all events the playtrack is pointing to - f = IteratorEOT.Range(0, t->GetLastClock()); - loopLength=t->GetLastClock(); + tEventIterator IteratorEOT(pTrack); //get an iterator of all events the playtrack is pointing to + f = IteratorEOT.Range(0, pTrack->GetLastClock()); + loopLength = pTrack->GetLastClock(); while(f) { if (f->IsEndOfTrack()) { - loopLength = t->GetLastClock(); + loopLength = pTrack->GetLastClock(); } f = IteratorEOT.Next(); } @@ -286,7 +292,7 @@ { MergePlayTrackEvent(d->IsPlayTrack(), Destin, recursionDepth); } - d->SetDevice(t->GetDevice()); + d->SetDevice(pTrack->GetDevice()); Destin->Put(d); f = IteratorPL.Next(); } @@ -344,7 +350,7 @@ JZBarInfo::JZBarInfo(JZSong *Song) - : Iterator(Song->Tracks[0]) + : Iterator(&Song->mTracks[0]) { BarNr = 0; Clock = 0; @@ -426,23 +432,29 @@ void JZSong::NewUndoBuffer() { - for (int i = 0; i < nTracks; i++) - Tracks[i]->NewUndoBuffer(); + for (int i = 0; i < nTracks; ++i) + { + mTracks[i].NewUndoBuffer(); + } } void JZSong::Undo() { wxBeginBusyCursor(); - for (int i = 0; i < nTracks; i++) - Tracks[i]->Undo(); + for (int i = 0; i < nTracks; ++i) + { + mTracks[i].Undo(); + } wxEndBusyCursor(); } void JZSong::Redo() { wxBeginBusyCursor(); - for (int i = 0; i < nTracks; i++) - Tracks[i]->Redo(); + for (int i = 0; i < nTracks; ++i) + { + mTracks[i].Redo(); + } wxEndBusyCursor(); } @@ -455,12 +467,12 @@ int tt, ee; double f = (double)NewTicks / (double)TicksPerQuarter; - for (tt = 0; tt < nTracks; tt++) + for (tt = 0; tt < nTracks; ++tt) { - tTrack *t = Tracks[tt]; - for (ee = 0; ee < t->nEvents; ee++) + tTrack* pTrack = &mTracks[tt]; + for (ee = 0; ee < pTrack->nEvents; ee++) { - JZEvent *e = t->Events[ee]; + JZEvent *e = pTrack->Events[ee]; e->SetClock((int)(f * e->GetClock() + 0.5)); tKeyOn *k = e->IsKeyOn(); if (k) @@ -491,13 +503,15 @@ // evtl vorhandene TimeSignatures loeschen - tTrack *t = Tracks[0]; - tEventIterator Iterator(t); + tTrack* pTrack = &mTracks[0]; + tEventIterator Iterator(pTrack); JZEvent *e = Iterator.Range(FrClock, ToClock); while (e) { if (e->IsTimeSignat()) - t->Kill(e); + { + pTrack->Kill(e); + } e = Iterator.Next(); } @@ -515,8 +529,8 @@ } e = new tTimeSignat(FrClock, Numerator, Shift); - t->Put(e); - t->Cleanup(); + pTrack->Put(e); + pTrack->Cleanup(); return 0; } @@ -525,8 +539,12 @@ { int n; for (n = nTracks; n > 1; n--) - if (!Tracks[n-1]->IsEmpty()) + { + if (!mTracks[n - 1].IsEmpty()) + { break; + } + } return n; } @@ -534,20 +552,25 @@ // SN++ void JZSong::moveTrack(int from, int to) { - tTrack *Track; + tTrack* pTrack; int i; if (from == to) return; - Track = Tracks[from]; - if (from > to) { - for (i=from;i>=to;i--) - Tracks[i] = Tracks[i-1]; - } else { - for (i=from;i<=to;i++) - Tracks[i] = Tracks[i+1]; + pTrack = &mTracks[from]; + if (from > to) + { + for (i = from; i >= to; i--) + { + mTracks[i] = mTracks[i - 1]; + } } - Tracks[to] = Track; + else + { + for (i = from; i <= to; i++) + { + mTracks[i] = mTracks[i + 1]; + } + } + mTracks[to] = *pTrack; } - - Modified: trunk/jazz/src/Song.h =================================================================== --- trunk/jazz/src/Song.h 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/Song.h 2008-03-17 06:25:43 UTC (rev 327) @@ -25,6 +25,7 @@ #include "Track.h" #include "Configuration.h" +#include "Globals.h" class tMetronomeInfo; class JZSong; @@ -55,9 +56,6 @@ int TicksPerQuarter; }; -// same as keys in pianowin -#define MaxTracks 127 - class JZSong { friend class JZBarInfo; @@ -75,7 +73,8 @@ int nTracks; int TicksPerQuarter; - tTrack *Tracks[MaxTracks]; + tTrack mTracks[eMaxTrackCount]; + void NewUndoBuffer(); void Undo(); void Redo(); Modified: trunk/jazz/src/SynthesizerSettingsDialog.cpp =================================================================== --- trunk/jazz/src/SynthesizerSettingsDialog.cpp 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/SynthesizerSettingsDialog.cpp 2008-03-17 06:25:43 UTC (rev 327) @@ -1,7 +1,7 @@ //***************************************************************************** // The JAZZ++ Midi Sequencer // -// Modifications Copyright (C) 2008 Peter J. Stieber +// Copyright (C) 2008 Peter J. Stieber // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #include "SynthesizerSettingsDialog.h" #include "Configuration.h" #include "Globals.h" +#include "Knob.h" using namespace std; @@ -35,6 +36,8 @@ mpSynthesizerListbox(0), mpStartListbox(0) { + JZKnob* pKnob = new JZKnob(this, wxID_ANY, 100, 0, 128); + mpSynthesizerListbox = new wxListBox(this, wxID_ANY); int Selection = 0; @@ -72,6 +75,8 @@ wxBoxSizer* pLeftSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* pRightSizer = new wxBoxSizer(wxVERTICAL); + pLeftSizer->Add(pKnob, 0, wxALL, 2); + pLeftSizer->Add( new wxStaticText(this, wxID_ANY, "Synthesizer Type"), 0, Modified: trunk/jazz/src/TrackFrame.cpp =================================================================== --- trunk/jazz/src/TrackFrame.cpp 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/TrackFrame.cpp 2008-03-17 06:25:43 UTC (rev 327) @@ -440,10 +440,10 @@ gpProject->OpenSong(FileName); SetTitle(FileName); // NextWin->NewPosition(1, 0); - mpTrackWindow->SetScrollRanges(); - mpTrackWindow->SetScrollPosition(0, 0); + mpTrackWindow->SetScrollRanges(0, 0); +// mpTrackWindow->SetScrollPosition(0, 0); // NextWin->Canvas->SetScrollRanges(); - Refresh(); + mpTrackWindow->Refresh(false); // tTrack::changed = false; } } Modified: trunk/jazz/src/TrackWindow.cpp =================================================================== --- trunk/jazz/src/TrackWindow.cpp 2008-03-17 06:22:14 UTC (rev 326) +++ trunk/jazz/src/TrackWindow.cpp 2008-03-17 06:25:43 UTC (rev 327) @@ -41,6 +41,7 @@ //----------------------------------------------------------------------------- BEGIN_EVENT_TABLE(JZTrackWindow, wxScrolledWindow) EVT_SIZE(JZTrackWindow::OnSize) + EVT_ERASE_BACKGROUND(JZTrackWindow::OnEraseBackground) END_EVENT_TABLE() //----------------------------------------------------------------------------- @@ -49,10 +50,6 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const int JZTrackWindow::mScrollPage = 8; - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- JZTrackWindow::JZTrackWindow( JZTrackFrame* pParent, JZSong* pSong, @@ -69,32 +66,44 @@ mpSong(pSong), mpGreyColor(0), mpGreyBrush(0), - hLine(0), - hTop(40), - wLeft(100), + mTrackHeight(10), + mTopInfoHeight(40), + mLeftInfoWidth(100), mClocksPerPixel(36), mPlayClock(-1), mUseColors(true), - mLittleBit(0), - mCanvasX(0), - mCanvasY(0), + mLittleBit(2), + mEventsX(), + mEventsY(), + mEventsWidth(), + mEventsHeight(), + mScrolledX(0), + mScrolledY(0), mCanvasWidth(0), mCanvasHeight(0), mFromClock(0), mToClock(0), mFromLine(0), mToLine(0), - xPatch(0), - wPatch(0), - nBars(0), + mNumberWidth(), + mTrackNameX(), + mTrackNameWidth(), + mStateX(), + mStateWidth(), + mPatchX(0), + mPatchWidth(0), + mBarCount(0), mCounterMode(eCmProgram), - mNumberMode(eNmMidiChannel), +// mNumberMode(eNmMidiChannel), + mNumberMode(eNmTrackNr), mpFixedFont(0), mFixedFontHeight(0), mFontSize(12), mpFont(0), mPreviouslyRecording(false), - mPreviousClock(0) + mPreviousClock(0), + mDrawing(false), + mpFrameBuffer(0) { #ifdef __WXMSW__ mpGreyColor = new wxColor(192, 192, 192); @@ -109,6 +118,8 @@ mpFilter = new tFilter(mpSong); SetBackgroundColour(*wxWHITE); + + mpFrameBuffer = new wxBitmap; } //----------------------------------------------------------------------------- @@ -121,63 +132,65 @@ delete mpFont; delete mpSnapSel; delete mpFilter; + delete mpFrameBuffer; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void JZTrackWindow::Create() { - int x, y; + wxClientDC Dc(this); - wxDC* pDc = new wxClientDC(this); + Dc.SetFont(wxNullFont); - pDc->SetFont(wxNullFont); - delete mpFixedFont; mpFixedFont = new wxFont(12, wxSWISS, wxNORMAL, wxNORMAL); - pDc->SetFont(*mpFixedFont); - pDc->GetTextExtent("M", &x, &mFixedFontHeight); + Dc.SetFont(*mpFixedFont); + int Width, Height; + Dc.GetTextExtent("M", &Width, &mFixedFontHeight); + delete mpFont; mpFont = new wxFont(mFontSize, wxSWISS, wxNORMAL, wxNORMAL); - pDc->SetFont(*mpFont); + Dc.SetFont(*mpFont); - pDc->GetTextExtent("M", &x, &y); - mLittleBit = (int)(x / 2); + Dc.GetTextExtent("M", &Width, &Height); + mLittleBit = Width / 2; - pDc->GetTextExtent("HXWjgi", &x, &y); - hLine = y + mLittleBit; + Dc.GetTextExtent("HXWjgi", &Width, &Height); + mTrackHeight = Height + 2 * mLittleBit; - hTop = mFixedFontHeight + 2 * mLittleBit; + mTopInfoHeight = mFixedFontHeight + 2 * mLittleBit; - pDc->GetTextExtent("99", &x, &y); - wNumber = x + mLittleBit; + Dc.GetTextExtent("999", &Width, &Height); + mNumberWidth = Width + 2 * mLittleBit; - pDc->GetTextExtent("Normal Trackname", &x, &y); - wName = x + mLittleBit; + Dc.GetTextExtent("Normal Track Name", &Width, &Height); + mTrackNameWidth = Width + 2 * mLittleBit; - pDc->GetTextExtent("m", &x, &y); - wState = x + mLittleBit; + Dc.GetTextExtent("m", &Width, &Height); + mStateWidth = Width + 2 * mLittleBit; - pDc->GetTextExtent("999", &x, &y); - wPatch = x + 2 * mLittleBit; + Dc.GetTextExtent("999", &Width, &Height); + mPatchWidth = Width + 2 * mLittleBit; - wLeft = wNumber + wName + wState + wPatch + 1; + mLeftInfoWidth = mNumberWidth + mTrackNameWidth + mStateWidth + mPatchWidth + 1; - cout - << ' ' << wNumber - << ' ' << wName - << ' ' << wState - << ' ' << wPatch - << ' ' << wLeft - << endl; +//DEBUG cout +//DEBUG << ' ' << mNumberWidth +//DEBUG << ' ' << mTrackNameWidth +//DEBUG << ' ' << mStateWidth +//DEBUG << ' ' << mPatchWidth +//DEBUG << ' ' << mLeftInfoWidth +//DEBUG << endl; UnMark(); - delete pDc; +// delete pDc; } //----------------------------------------------------------------------------- +// Description: // Update the play position to the clock argument, and trigger a redraw so // the play bar will be drawn. //----------------------------------------------------------------------------- @@ -197,7 +210,7 @@ return; } int x = Clock2x(Clock); - SetScrollPosition(x - wLeft, mCanvasY); + SetScrollPosition(x - mLeftInfoWidth, mScrolledY); } if (!mpSnapSel->Active) // sets clipping @@ -208,17 +221,19 @@ mPlayClock = Clock; wxRect invalidateRect; invalidateRect.x = Clock2x(OldPlayClock) - 1; - invalidateRect.y = mCanvasY; + invalidateRect.y = mScrolledY; invalidateRect.width = 3; invalidateRect.height= 100000000; //DrawPlayPosition(); + Refresh(true, &invalidateRect); invalidateRect.x = Clock2x(mPlayClock) - 1; + Refresh(true, &invalidateRect); //DrawPlayPosition(); - Refresh(); + Refresh(false); } } } @@ -230,7 +245,7 @@ Marked.SetX(x2xBar(x)); Marked.SetY(y2yLine(y)); Marked.SetWidth(x2wBar(x)); - Marked.SetHeight(hLine); + Marked.SetHeight(mTrackHeight); wxDC* pDc = new wxClientDC(this); LineText(*pDc, Marked.GetX(), Marked.GetY(), Marked.GetWidth(), ">"); @@ -249,27 +264,36 @@ void JZTrackWindow::OnSize(wxSizeEvent& Event) { GetClientSize(&mCanvasWidth, &mCanvasHeight); - if (mCanvasWidth && mCanvasHeight) + if (mCanvasWidth > 0 && mCanvasHeight > 0) { - SetScrollRanges(); - SetScrollPosition(0, 0); - Refresh(); + mpFrameBuffer->Create(mCanvasWidth, mCanvasHeight); + SetScrollRanges(mScrolledX, mScrolledY); +// SetScrollPosition(0, 0); } } //----------------------------------------------------------------------------- +// Description: +// Do nothing, to avoid flickering. //----------------------------------------------------------------------------- +void JZTrackWindow::OnEraseBackground(wxEraseEvent& Event) +{ +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZTrackWindow::ZoomIn() { if (mClocksPerPixel >= 2) { mClocksPerPixel /= 2; - int x = mCanvasX * 2; - int y = mCanvasY; + int x = mScrolledX * 2; + int y = mScrolledY; - SetScrollRanges(); - SetScrollPosition(x, y); - Refresh(); + SetScrollRanges(x, y); +// SetScrollPosition(x, y); + + Refresh(false); } } @@ -280,12 +304,13 @@ if (mClocksPerPixel <= 120) { mClocksPerPixel *= 2; - int x = mCanvasX / 2; - int y = mCanvasY; + int x = mScrolledX / 2; + int y = mScrolledY; - SetScrollRanges(); - SetScrollPosition(x, y); - Refresh(); + SetScrollRanges(x, y); +// SetScrollPosition(x, y); + + Refresh(false); } } @@ -293,57 +318,113 @@ //----------------------------------------------------------------------------- void JZTrackWindow::OnDraw(wxDC& Dc) { - GetViewStart(&mCanvasX, &mCanvasY); - mCanvasX *= mScrollLine; - mCanvasY *= mScrollLine; + Draw(Dc); +} +//----------------------------------------------------------------------------- +// Description: +// Draw the static portion of the scenario in the static bitmap. +//----------------------------------------------------------------------------- +void JZTrackWindow::Draw(wxDC& Dc) +{ + if (!mpFrameBuffer->Ok() || mDrawing) + { + return; + } + + mDrawing = true; + + // Create a memory device context and select the frame bitmap into it. + wxMemoryDC LocalDc; + LocalDc.SelectObject(*mpFrameBuffer); + + LocalDc.SetFont(*mpFont); + + // Setup the brush that is used to clear the background. + LocalDc.SetBackground(*wxWHITE_BRUSH); + + // Clear the background using the brush that was just setup, + // in case the following drawing calls fail. + LocalDc.Clear(); + + // Get the location, in scrolling units, of the upper left hand corner of + // viewable portion of the virtual window that makes up the scrolled window. + // Note that the bitmap we are drawing to always has upper left coordinates + // of (0, 0). The y value is used to draw the proper tracks and the x + // value is used to draw the proper measures or bars. + GetViewStart(&mScrolledX, &mScrolledY); + + // Convert scrolling units into pixels. + mScrolledX *= mScrollLine; + mScrolledY *= mScrollLine; + GetClientSize(&mCanvasWidth, &mCanvasHeight); + cout + << "mCanvasWidth: " << mCanvasWidth + << " mCanvasHeight: " << mCanvasHeight + << endl; - xEvents = mCanvasX + wLeft; - yEvents = mCanvasY + hTop; - wEvents = mCanvasWidth - wLeft; - hEvents = mCanvasHeight - hTop; + mEventsX = mLeftInfoWidth; + mEventsY = mTopInfoHeight; - mFromLine = mCanvasY / hLine; - mToLine = 1 + (mCanvasY + mCanvasHeight - hTop) / hLine; - mFromClock = mCanvasX * mClocksPerPixel; - mToClock = x2Clock(mCanvasX + mCanvasWidth); + mEventsWidth = mCanvasWidth - mLeftInfoWidth; + mEventsHeight = mCanvasHeight - mTopInfoHeight; - xNumber = mCanvasX; - xName = xNumber + wNumber; - xState = xName + wName; - xPatch = xState + wState; + mFromLine = mScrolledY / mTrackHeight; - Dc.DestroyClippingRegion(); + mToLine = 1 + (mScrolledY + mCanvasHeight - mTopInfoHeight) / mTrackHeight; + mFromClock = mScrolledX * mClocksPerPixel; +//OLD mToClock = x2Clock(mScrolledX + mCanvasWidth); + mToClock = x2Clock(mScrolledX + mCanvasWidth - mLeftInfoWidth); + mTrackNameX = mNumberWidth; + mStateX = mTrackNameX + mTrackNameWidth; + mPatchX = mStateX + mStateWidth; - Dc.SetPen(*wxBLACK_PEN); + LocalDc.DestroyClippingRegion(); + LocalDc.SetPen(*wxBLACK_PEN); + // Draw the vertical lines. - DrawVerticalLine(Dc, xNumber); - DrawVerticalLine(Dc, xName); - DrawVerticalLine(Dc, xState); - DrawVerticalLine(Dc, xPatch); + DrawVerticalLine(LocalDc, 0); + DrawVerticalLine(LocalDc, mTrackNameX); + DrawVerticalLine(LocalDc, mStateX); + DrawVerticalLine(LocalDc, mPatchX); - DrawVerticalLine(Dc, xEvents - 1); - DrawHorizontalLine(Dc, yEvents); - DrawHorizontalLine(Dc, yEvents - 1); + DrawVerticalLine(LocalDc, mEventsX - 1); + DrawHorizontalLine(LocalDc, mEventsY); + DrawHorizontalLine(LocalDc, mEventsY - 1); if (mpSong) { JZBarInfo BarInfo(mpSong); + + cout + << "mCanvasWidth - mLeftInfoWidth: " << mCanvasWidth - mLeftInfoWidth << '\n' + << "BarInfo.TicksPerBar " << BarInfo.TicksPerBar << '\n' + << "From Clock: " << mFromClock << '\n' + << "To Clock: " << mToClock << '\n' + << "Clocks/Pixel: " << mClocksPerPixel << '\n' + << "From Measure: " << mFromClock / BarInfo.TicksPerBar << '\n' + << "To Measure: " << mToClock / BarInfo.TicksPerBar +// << "From X: " << mFromClock << '\n' +// << "To X: " << mToClock << '\n' + << endl; + + BarInfo.SetClock(mFromClock); - nBars = 0; - int intro = gpProject->GetIntroLength(); - Dc.SetPen(*wxGREY_PEN); + mBarCount = 0; + int Intro = gpProject->GetIntroLength(); + LocalDc.SetPen(*wxGREY_PEN); while (1) { int x = Clock2x(BarInfo.Clock); - if (x > mCanvasX + mCanvasWidth) + if (x > mScrolledX + mCanvasWidth) { break; } - if (x >= xEvents) // so ne Art clipping + + if (x >= mEventsX) { int c; if (mClocksPerPixel > 48) @@ -354,97 +435,120 @@ { c = 4; } - if (((BarInfo.BarNr - intro + 96) % c) == 0) + if (((BarInfo.BarNr - Intro + 96) % c) == 0) { - Dc.SetPen(*wxBLACK_PEN); + LocalDc.SetPen(*wxBLACK_PEN); ostringstream Oss; - Oss << BarInfo.BarNr + 1 - intro; - Dc.DrawText(Oss.str().c_str(), x + mLittleBit, yEvents - hLine); - Dc.SetPen(*wxGREY_PEN); - Dc.DrawLine(x, yEvents + 1 - hLine, x, yEvents + hEvents); + Oss << BarInfo.BarNr + 1 - Intro; + LocalDc.DrawText(Oss.str().c_str(), x + mLittleBit, mEventsY - mTrackHeight); + LocalDc.SetPen(*wxGREY_PEN); + LocalDc.DrawLine(x, mEventsY + 1 - mTrackHeight, x, mEventsY + mEventsHeight); } else { - Dc.SetPen(*wxLIGHT_GREY_PEN); - Dc.DrawLine(x, yEvents + 1, x, yEvents + hEvents); + LocalDc.SetPen(*wxLIGHT_GREY_PEN); + LocalDc.DrawLine(x, mEventsY + 1, x, mEventsY + mEventsHeight); } // x-coordinate for MouseAction->Snap() - if (nBars < eMaxBars) + if (mBarCount < eMaxBars) { - xBars[nBars++] = x; + mBarX[mBarCount++] = x; } } BarInfo.Next(); } - Dc.SetPen(*wxBLACK_PEN); + LocalDc.SetPen(*wxBLACK_PEN); } // For each track show the MIDI channel, name, state, prg. int TrackNumber = mFromLine; - for (int y = Line2y(TrackNumber); y < yEvents + hEvents; y += hLine) + for (int y = Track2y(TrackNumber); y < mEventsY + mEventsHeight; y += mTrackHeight) { - Dc.SetClippingRegion( - mCanvasX, - yEvents, + LocalDc.SetClippingRegion( + 0, + mEventsY, mCanvasWidth, - hEvents); + mEventsHeight); - Dc.SetPen(*wxGREY_PEN); - Dc.DrawLine(xEvents + 1, y, mCanvasX + mCanvasWidth, y); - Dc.SetPen(*wxBLACK_PEN); - Dc.DrawLine(mCanvasX, y, xEvents, y); + LocalDc.SetPen(*wxGREY_PEN); + LocalDc.DrawLine(mEventsX + 1, y, mCanvasWidth, y); + LocalDc.SetPen(*wxBLACK_PEN); + LocalDc.DrawLine(0, y, mEventsX, y); - Dc.DestroyClippingRegion(); + LocalDc.DestroyClippingRegion(); tTrack* pTrack = gpProject->GetTrack(TrackNumber); if (pTrack) { - Dc.SetClippingRegion( - xName, - yEvents, - wName + wState, - hEvents); + LocalDc.SetClippingRegion( + mTrackNameX, + mEventsY, + mTrackNameWidth + mStateWidth, + mEventsHeight); // Draw the track name. if (pTrack->DialogBox) { // Show the button pressed when the dialog box is open. - LineText(Dc, xName, y, wName, pTrack->GetName(), -1, true); + LineText(LocalDc, mTrackNameX, y, mTrackNameWidth, pTrack->GetName(), -1, true); } else { - LineText(Dc, xName, y, wName, pTrack->GetName(), -1, false); + LineText(LocalDc, mTrackNameX, y, mTrackNameWidth, pTrack->GetName(), -1, false); } // Draw the track status. - LineText(Dc, xState, y, wState, pTrack->GetStateChar()); + LineText(LocalDc, mStateX, y, mStateWidth, pTrack->GetStateChar()); - Dc.DestroyClippingRegion(); + LocalDc.DestroyClippingRegion(); } + else + { + LineText(LocalDc, mTrackNameX, y, mTrackNameWidth, "", -1, false); + LineText(LocalDc, mStateX, y, mStateWidth, ""); + } + ++TrackNumber; } - DrawNumbers(Dc); - DrawSpeed(Dc); - DrawCounters(Dc); + DrawNumbers(LocalDc); + DrawSpeed(LocalDc); + DrawCounters(LocalDc); - LineText(Dc, xState, mCanvasY - 1, wState, "", hTop); + LineText(LocalDc, mStateX, -1, mStateWidth, "", mTopInfoHeight); - DrawEvents(Dc); + DrawEvents(LocalDc); if (Marked.x > 0) { - LineText(Dc, Marked.x, Marked.y, Marked.width, ">"); + LineText(LocalDc, Marked.x, Marked.y, Marked.width, ">"); } - Dc.DestroyClippingRegion(); + LocalDc.DestroyClippingRegion(); - DrawPlayPosition(Dc); + DrawPlayPosition(LocalDc); // Draw the selection box. - mpSnapSel->Draw(Dc, xEvents, yEvents, wEvents, hEvents); + mpSnapSel->Draw(LocalDc, mEventsX, mEventsY, mEventsWidth, mEventsHeight); + +// LocalDc.SetClippingRegion(0, 0, mCanvasWidth, mCanvasHeight); + Dc.Blit( + mScrolledX, + mScrolledY, + mCanvasWidth, + mCanvasHeight, + &LocalDc, + 0, + 0, + wxCOPY); +// LocalDc.DestroyClippingRegion(); + + LocalDc.SetFont(wxNullFont); + LocalDc.SelectObject(wxNullBitmap); + + mDrawing = false; } //----------------------------------------------------------------------------- @@ -454,10 +558,10 @@ //----------------------------------------------------------------------------- void JZTrackWindow::DrawNumbers(wxDC& Dc) { - const char* pString = NumberStr(); - LineText(Dc, xNumber, mCanvasY - 1, wNumber, pString, hTop); + const char* pString = GetNumberString(); + LineText(Dc, 0, -1, mNumberWidth, pString, mTopInfoHeight); - Dc.SetClippingRegion(xNumber, yEvents, wNumber, hEvents); + Dc.SetClippingRegion(0, mEventsY, mNumberWidth, mEventsHeight); for (int i = mFromLine; i < mToLine; ++i) { tTrack* pTrack = gpProject->GetTrack(i); @@ -465,7 +569,7 @@ { if (pTrack->GetAudioMode()) { - LineText(Dc, xNumber, Line2y(i), wNumber, "Au"); + LineText(Dc, 0, Track2y(i), mNumberWidth, "Au"); } else { @@ -473,7 +577,7 @@ switch (mNumberMode) { case eNmTrackNr: - Value = i; + Value = i + 1; break; case eNmMidiChannel: Value = pTrack->Channel; @@ -484,9 +588,13 @@ } ostringstream Oss; Oss << setw(2) << Value; - LineText(Dc, xNumber, Line2y(i), wNumber, Oss.str().c_str()); + LineText(Dc, 0, Track2y(i), mNumberWidth, Oss.str().c_str()); } } + else + { + LineText(Dc, 0, Track2y(i), mNumberWidth, ""); + } } Dc.DestroyClippingRegion(); } @@ -506,7 +614,7 @@ ostringstream Oss; Oss << "speed: " << setw(3) << Value; - LineText(Dc, xName, mCanvasY - 1, wName, Oss.str().c_str(), hTop, Down); + LineText(Dc, mTrackNameX, -1, mTrackNameWidth, Oss.str().c_str(), mTopInfoHeight, Down); } //----------------------------------------------------------------------------- @@ -521,15 +629,11 @@ Dc.SetBrush(*wxBLACK_BRUSH); Dc.SetPen(*wxBLACK_PEN); -// Dc.SetLogicalFunction(wxXOR); - int x = Clock2x(mPlayClock); // Draw a line, 2 pixwels wide. - Dc.DrawLine(x, mCanvasY, x, yEvents + hEvents); - Dc.DrawLine(x + 1, mCanvasY, x + 1, yEvents + hEvents); - -// Dc.SetLogicalFunction(wxCOPY); + Dc.DrawLine(x, 0, x, mEventsY + mEventsHeight); + Dc.DrawLine(x + 1, 0, x + 1, mEventsY + mEventsHeight); } // if (mpNextWin) // { @@ -550,7 +654,7 @@ { if (Height <= 0) { - Height = hLine; + Height = mTrackHeight; y = y2yLine(y); } if (Width && Height) @@ -599,10 +703,10 @@ void JZTrackWindow::DrawCounters(wxDC& Dc) { int i; - const char... [truncated message content] |