From: <pst...@us...> - 2008-04-27 22:23:49
|
Revision: 476 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=476&view=rev Author: pstieber Date: 2008-04-27 15:23:47 -0700 (Sun, 27 Apr 2008) Log Message: ----------- 1. Renamed the tControl data members Control to mControl and Value to mValue. 2. Changed various local variable names (ctrl, copy, c, and k) to indicate they are control pointers (pControl and pControlCopy). 3. Added member functions to the track class to increase and decrease the volume (DecreaseVolume and IncreaseVolume). 4. Renamed a local event pointer e to pEvent. 5. Added code to the track window to increase or decrease the volume by clicking the left (increase) or right (decrease) mouse button in the patch column. 6. Changed the logic to ToggleTrackState could be removed from the track window. 7. Fixed a typo in a comment in the track window header. Modified Paths: -------------- trunk/jazz/src/Command.cpp trunk/jazz/src/ControlEdit.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Events.h trunk/jazz/src/Track.cpp trunk/jazz/src/Track.h trunk/jazz/src/TrackWindow.cpp trunk/jazz/src/TrackWindow.h trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/Command.cpp =================================================================== --- trunk/jazz/src/Command.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/Command.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -750,15 +750,15 @@ void tCmdSearchReplace::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tControl *ctrl; - if ((ctrl = pEvent->IsControl()) != 0) + tControl* pControl = pEvent->IsControl(); + if (pControl) { - if (ctrl->Control == fr) + if (pControl->mControl == fr) { - tControl *copy = (tControl *)ctrl->Copy(); - copy->Control = to; - pTrack->Kill(ctrl); - pTrack->Put(copy); + tControl* pControlCopy = (tControl *)pControl->Copy(); + pControlCopy->mControl = to; + pTrack->Kill(pControl); + pTrack->Put(pControlCopy); } } } Modified: trunk/jazz/src/ControlEdit.cpp =================================================================== --- trunk/jazz/src/ControlEdit.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/ControlEdit.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -314,10 +314,10 @@ { if (IsCtrlEdit(pEvent)) { - if (Clock2Val(pEvent->GetClock()) != pEvent->IsControl()->Value) + if (Clock2Val(pEvent->GetClock()) != pEvent->IsControl()->mValue) { pControlCopy = pEvent->Copy()->IsControl(); - pControlCopy->Value = Clock2Val(pEvent->GetClock()); + pControlCopy->mValue = Clock2Val(pEvent->GetClock()); track->Kill(pEvent); track->Put(pControlCopy); } @@ -470,13 +470,13 @@ int tCtrlEdit::IsCtrlEdit(JZEvent* pEvent) { - tControl *c = pEvent->IsControl(); - return (c && c->Control == ctrl_num); + tControl* pControl = pEvent->IsControl(); + return (pControl && pControl->mControl == ctrl_num); } int tCtrlEdit::GetValue(JZEvent* pEvent) { - return pEvent->IsControl()->Value; + return pEvent->IsControl()->mValue; } JZEvent * tCtrlEdit::NewEvent(long clock, int val) Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/Dialogs.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -853,16 +853,16 @@ // Choice("Controller", &gpConfig->GetCtrlName(0), &Control) { Event = e; - Value = e->Value; - Control = e->Control + 1; + Value = e->mValue; + Control = e->mControl + 1; } bool tControlDlg::OnClose() { - ((tControl *)Copy)->Value = Value; + ((tControl *)Copy)->mValue = Value; // Choice.GetValue(); - ((tControl *)Copy)->Control = Control - 1; + ((tControl *)Copy)->mControl = Control - 1; return tChEventDlg::OnClose(); } Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/Events.h 2008-04-27 22:23:47 UTC (rev 476) @@ -739,20 +739,20 @@ { public: - unsigned char Control; - unsigned char Value; + unsigned char mControl; + unsigned char mValue; tControl(int clk, int cha, unsigned char ctl, unsigned char val) : tChannelEvent(clk, StatControl, cha) { - Control = ctl; - Value = val; + mControl = ctl; + mValue = val; } virtual int Write(JZWriteBase &io) { edb(); - return io.Write(this, Control, Value); + return io.Write(this, mControl, mValue); } virtual tControl* IsControl() @@ -770,19 +770,19 @@ virtual int GetValue() const { edb(); - return Control; + return mControl; } virtual int GetPitch() const { edb(); - return Control; + return mControl; } virtual void SetPitch(int p) { edb(); - Control = p; + mControl = p; } virtual const wxPen* GetPen() const Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/Track.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -246,14 +246,14 @@ } tDrumInstrumentParameter::tDrumInstrumentParameter(tNrpn *par) - : pitch(par->Lsb.Value), + : pitch(par->Lsb.mValue), next(0) { for (int i = drumPitchIndex; i < numDrumParameters; i++) { param[i] = 0; } - param[drumParam2Index(par->Msb.Value)] = par; + param[drumParam2Index(par->Msb.mValue)] = par; } tNrpn *tDrumInstrumentParameter::Get(int index) @@ -264,7 +264,7 @@ void tDrumInstrumentParameter::Put(tNrpn *par) { - param[par->Lsb.Value] = par; + param[par->Lsb.mValue] = par; } tDrumInstrumentParameter *tDrumInstrumentParameter::Next() @@ -304,7 +304,7 @@ void tDrumInstrumentParameterList::PutParam(tNrpn *par) { - tDrumInstrumentParameter *ptr = GetElem(par->Lsb.Value); + tDrumInstrumentParameter* ptr = GetElem(par->Lsb.mValue); if (!ptr) { ptr = new tDrumInstrumentParameter(par); @@ -313,7 +313,7 @@ } else { - ptr->param[drumParam2Index(par->Msb.Value)] = par; + ptr->param[drumParam2Index(par->Msb.mValue)] = par; } } @@ -731,7 +731,7 @@ void tEventArray::Cleanup(bool dont_delete_killed_events) { JZEvent *e; - tControl *c; + tControl* pControl; tSysEx *s; int i; @@ -845,32 +845,32 @@ { MtcOffset = e->IsMtcOffset(); } - if ((c = e->IsControl()) != 0) + if ((pControl = e->IsControl()) != 0) { - switch (c->Control) + switch (pControl->mControl) { case 0x07: if (!Volume) { - Volume = c; + Volume = pControl; } break; case 0x0a: if (!Pan) { - Pan = c; + Pan = pControl; } break; case 0x5b: if (!Reverb) { - Reverb = c; + Reverb = pControl; } break; case 0x5d: if (!Chorus) { - Chorus = c; + Chorus = pControl; } break; } @@ -1380,7 +1380,7 @@ WrittenBefore = 0; if (e->IsControl()) { - switch (e->IsControl()->Control) + switch (e->IsControl()->mControl) { // Don't write these again if present as events // and clock == 0 (should not happen) @@ -1451,22 +1451,22 @@ } if (e->IsControl()) { - switch (e->IsControl()->Control) + switch (e->IsControl()->mControl) { // Grab Rpn/Nrpn/Bank from file and save them, don't put // them into event-array case 0x63: case 0x65: - Msb = e->IsControl()->Value; // Rpn/Nrpn Msb + Msb = e->IsControl()->mValue; // Rpn/Nrpn Msb SpecialEvent = 1; break; case 0x62: case 0x64: - Lsb = e->IsControl()->Value; // Rpn/Nrpn Lsb + Lsb = e->IsControl()->mValue; // Rpn/Nrpn Lsb SpecialEvent = 1; break; case 0x06: - Data = e->IsControl()->Value; // Rpn/Nrpn Data + Data = e->IsControl()->mValue; // Rpn/Nrpn Data SpecialEvent = 1; cha = e->IsControl()->Channel; switch (Msb) @@ -2142,7 +2142,7 @@ { if (Volume) { - return Volume->Value + 1; + return Volume->mValue + 1; } return 0; } @@ -2155,20 +2155,58 @@ } if (Value > 0) { - JZEvent *e = new tControl(0, Channel - 1, 0x07, Value - 1); - Put(e); - gpMidiPlayer->OutNow(this, e); + JZEvent* pEvent = new tControl(0, Channel - 1, 0x07, Value - 1); + Put(pEvent); + gpMidiPlayer->OutNow(this, pEvent); } Cleanup(); } +bool JZTrack::DecreaseVolume() +{ + if (Volume && Volume->mValue > 0) + { + Kill(Volume); + + --Volume->mValue; + + JZEvent* pEvent = new tControl(0, Channel - 1, 0x07, Volume->mValue); + Put(pEvent); + gpMidiPlayer->OutNow(this, pEvent); + + Cleanup(); + + return true; + } + return false; +} + +bool JZTrack::IncreaseVolume() +{ + if (Volume && Volume->mValue < 127) + { + Kill(Volume); + + ++Volume->mValue; + + JZEvent* pEvent = new tControl(0, Channel - 1, 0x07, Volume->mValue); + Put(pEvent); + gpMidiPlayer->OutNow(this, pEvent); + + Cleanup(); + + return true; + } + return false; +} + // ------------------------ Pan ------------------------------ int JZTrack::GetPan() { if (Pan) { - return Pan->Value + 1; + return Pan->mValue + 1; } return 0; } @@ -2194,7 +2232,7 @@ { if (Reverb) { - return Reverb->Value + 1; + return Reverb->mValue + 1; } return 0; } @@ -2220,7 +2258,7 @@ { if (Chorus) { - return Chorus->Value + 1; + return Chorus->mValue + 1; } return 0; } @@ -2250,7 +2288,7 @@ if (mpBank) { DEBUG(fprintf(stderr,"Bank %d selected.\n\n",mpBank->Value);) - return mpBank->Value; + return mpBank->mValue; } else { @@ -2263,8 +2301,8 @@ for (int i=0; gpConfig->BankEntry(i).Command[0]>=0; i++) { if ( - gpConfig->BankEntry(i).Command[0] == mpBank->Value && - gpConfig->BankEntry(i).Command[1] == mpBank2->Value) + gpConfig->BankEntry(i).Command[0] == mpBank->mValue && + gpConfig->BankEntry(i).Command[1] == mpBank2->mValue) { DEBUG(fprintf(stderr,"Bank %d selected.\n\n",i);) return i; Modified: trunk/jazz/src/Track.h =================================================================== --- trunk/jazz/src/Track.h 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/Track.h 2008-04-27 22:23:47 UTC (rev 476) @@ -72,7 +72,7 @@ virtual void SetCha( unsigned char cha ); virtual int GetVal() { - return( DataMsb.Value ); + return DataMsb.mValue; } tControl Msb; @@ -472,6 +472,8 @@ int GetVolume(); void SetVolume(int Volume); + bool DecreaseVolume(); + bool IncreaseVolume(); int GetPan(); void SetPan(int Pan); @@ -575,8 +577,6 @@ tMtcTime* GetMtcOffset(); void SetMtcOffset( tMtcTime* mtc ); - - }; Modified: trunk/jazz/src/TrackWindow.cpp =================================================================== --- trunk/jazz/src/TrackWindow.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/TrackWindow.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -142,7 +142,8 @@ Dc.GetTextExtent("999", &Width, &Height); mPatchWidth = Width + 2 * mLittleBit; - mLeftInfoWidth = mNumberWidth + mTrackNameWidth + mStateWidth + mPatchWidth + 1; + mLeftInfoWidth = + mNumberWidth + mTrackNameWidth + mStateWidth + mPatchWidth + 1; //DEBUG cout //DEBUG << ' ' << mNumberWidth @@ -280,10 +281,10 @@ // Check to see if the mouse was clicked in the top header. if (Point.y < mTopInfoHeight) { - // Check to see if the mouse was clicked inside of the number mode - // indicator. - if (Point.x < mNumberWidth && Point.y < mTopInfoHeight) + if (Point.x < mNumberWidth) { + // The point is inside of the number mode indicator, so toggle the first + // column between track index and MIDI channel. if (mNumberMode == eNmTrackNr) { mNumberMode = eNmMidiChannel; @@ -295,11 +296,13 @@ Refresh(false); } } - // Check to see if the mouse was clicked inside of the track name header. else if ( Point.x >= mTrackNameX && Point.x < mTrackNameX + mTrackNameWidth) { + // The point is inside of the track name header. This cell indicates + // the song tempo. + // Bump up the speed value one tick. int SpeedBpm = gpProject->GetTrack(0)->GetDefaultSpeed(); ++SpeedBpm; @@ -309,9 +312,10 @@ } Refresh(false); } - // Check to see if the mouse was clicked inside of the patch header. else if (Point.x >= mPatchX && Point.x < mPatchX + mPatchWidth) { + // The point is inside the patch header. + // Toggle the patch type. switch (mCounterMode) { @@ -338,29 +342,46 @@ Refresh(false); } } - else if (Point.x >= mStateX && Point.x < mStateX + mStateWidth) + else { - ToggleTrackState(Point); - } - // Check to see if the mouse was clicked inside of a track name. - else if ( - Point.x >= mTrackNameX && - Point.x < mTrackNameX + mTrackNameWidth) - { - // Edit the track settings. + // The point is not in the top header row. + + // Get the track associated with the y position. JZTrack* pTrack = y2Track(Point.y); if (pTrack) { - pTrack->Dialog(this); - Refresh(false); + if (Point.x < mNumberWidth) + { + // The point is inside the number field. + } + else if ( + Point.x >= mTrackNameX && + Point.x < mTrackNameX + mTrackNameWidth) + { + // The point is inside of a track name column. Edit the track + // settings. + pTrack->Dialog(this); + Refresh(false); + } + else if (Point.x >= mStateX && Point.x < mStateX + mStateWidth) + { + // The point is inside the track name field. Toggle the track state. + pTrack->ToggleState(1); + Refresh(false); + } + else if (Point.x >= mPatchX && Point.x < mPatchX + mPatchWidth) + { + IncreaseTrackNumberField(pTrack); + } + else if ( + Point.x >= mEventsX && Point.x < mEventsX + mEventsWidth && + Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight) + { + // The point is in event area. + SnapSelectionStop(Event); + } } } - else if ( - Point.x >= mEventsX && Point.x < mEventsX + mEventsWidth && - Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight) - { - SnapSelectionStop(Event); - } } //----------------------------------------------------------------------------- @@ -369,29 +390,103 @@ { wxPoint Point = Event.GetPosition(); - if ( - Point.x >= mTrackNameX && Point.x < mTrackNameX + mTrackNameWidth && - Point.y < mTopInfoHeight) + if (Point.y < mTopInfoHeight) { - // Knock down the speed value one tick. - int SpeedBpm = gpProject->GetTrack(0)->GetDefaultSpeed(); - --SpeedBpm; - if (SpeedBpm > 0 && SpeedBpm < 300) + // The point is inside the top header line. + + if (Point.x >= mTrackNameX && Point.x < mTrackNameX + mTrackNameWidth) { - gpProject->GetTrack(0)->SetDefaultSpeed(SpeedBpm); + // The point is inside the track name field. + int SpeedBpm = gpProject->GetTrack(0)->GetDefaultSpeed(); + + // Knock down the speed value one tick. + --SpeedBpm; + + if (SpeedBpm > 0 && SpeedBpm < 300) + { + gpProject->GetTrack(0)->SetDefaultSpeed(SpeedBpm); + } + Refresh(false); } + } + else + { + // The point is below the top header line. + + // Get the track associated with the y position. + JZTrack* pTrack = y2Track(Point.y); + if (pTrack) + { + if (Point.x < mNumberWidth) + { + // The point is inside the number field. + } + else if (Point.x >= mStateX && Point.x < mStateX + mStateWidth) + { + // The point is inside the track name field. + } + else if (Point.x >= mPatchX && Point.x < mPatchX + mPatchWidth) + { + DecreaseTrackNumberField(pTrack); + } + } + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZTrackWindow::IncreaseTrackNumberField(JZTrack* pTrack) +{ + bool UpdateFlag = false; + + switch (mCounterMode) + { + case eCmProgram: + break; + case eCmBank: + break; + case eCmVolume: + UpdateFlag = pTrack->IncreaseVolume(); + break; + case eCmPan: + break; + case eCmReverb: + break; + case eCmChorus: + default: + break; + } + if (UpdateFlag) + { Refresh(false); } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZTrackWindow::ToggleTrackState(const wxPoint& Point) +void JZTrackWindow::DecreaseTrackNumberField(JZTrack* pTrack) { - JZTrack* pTrack = y2Track(Point.y); - if (pTrack) + bool UpdateFlag = false; + + switch (mCounterMode) { - pTrack->ToggleState(1); + case eCmProgram: + break; + case eCmBank: + break; + case eCmVolume: + UpdateFlag = pTrack->DecreaseVolume(); + break; + case eCmPan: + break; + case eCmReverb: + break; + case eCmChorus: + default: + break; + } + if (UpdateFlag) + { Refresh(false); } } Modified: trunk/jazz/src/TrackWindow.h =================================================================== --- trunk/jazz/src/TrackWindow.h 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/TrackWindow.h 2008-04-27 22:23:47 UTC (rev 476) @@ -104,8 +104,10 @@ void VerticalScroll(wxScrollWinEvent& Event); - void ToggleTrackState(const wxPoint& Point); + void IncreaseTrackNumberField(JZTrack* pTrack); + void DecreaseTrackNumberField(JZTrack* pTrack); + virtual void OnDraw(wxDC& Dc); void Draw(wxDC& Dc); @@ -157,7 +159,7 @@ int mPlayClock; bool mUseColors; - // The values indicate the staring postions and widths of the track fields + // The values indicate the starting postions and widths of the track fields // on the left hand side of the screen. Note that the position of the // first field displayed is always 0, so it doesn't need to be recorded. int mNumberWidth; Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -299,10 +299,10 @@ case StatControl: { - tControl *k = e->IsControl(); - u.c[0] = 0xB0 | k->Channel; - u.c[1] = k->Control; - u.c[2] = k->Value; + tControl* pControl = e->IsControl(); + u.c[0] = 0xB0 | pControl->Channel; + u.c[1] = pControl->mControl; + u.c[2] = pControl->mValue; } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |