|
From: <pst...@us...> - 2008-12-26 22:22:53
|
Revision: 654
http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=654&view=rev
Author: pstieber
Date: 2008-12-26 21:37:56 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
1. Added a snap select stop function.
2. Started adding record capability. This is a WIP.
Modified Paths:
--------------
trunk/jazz/src/EventWindow.h
trunk/jazz/src/TrackFrame.cpp
trunk/jazz/src/TrackFrame.h
trunk/jazz/src/TrackWindow.cpp
trunk/jazz/src/TrackWindow.h
Modified: trunk/jazz/src/EventWindow.h
===================================================================
--- trunk/jazz/src/EventWindow.h 2008-12-26 21:35:52 UTC (rev 653)
+++ trunk/jazz/src/EventWindow.h 2008-12-26 21:37:56 UTC (rev 654)
@@ -78,6 +78,10 @@
protected:
+ virtual void SnapSelStop(wxMouseEvent& Event)
+ {
+ }
+
void DrawVerticalLine(wxDC& Dc, int XPosition) const;
void DrawHorizontalLine(wxDC& Dc, int YPosition) const;
Modified: trunk/jazz/src/TrackFrame.cpp
===================================================================
--- trunk/jazz/src/TrackFrame.cpp 2008-12-26 21:35:52 UTC (rev 653)
+++ trunk/jazz/src/TrackFrame.cpp 2008-12-26 21:37:56 UTC (rev 654)
@@ -75,6 +75,8 @@
//-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(JZTrackFrame, wxFrame)
+ EVT_MENU(wxID_NEW, JZTrackFrame::OnFileNew)
+
EVT_MENU(wxID_OPEN, JZTrackFrame::OnFileOpen)
EVT_MENU(wxID_SAVEAS, JZTrackFrame::OnFileSaveAs)
@@ -85,6 +87,8 @@
EVT_MENU(ID_PLAY_LOOP, JZTrackFrame::OnPlayLoop)
+ EVT_MENU(ID_RECORD, JZTrackFrame::OnRecord)
+
EVT_MENU(ID_PIANOWIN, JZTrackFrame::OnPianoWindow)
EVT_MENU(ID_METRONOME_TOGGLE, JZTrackFrame::OnMetroOn)
@@ -142,6 +146,16 @@
//-----------------------------------------------------------------------------
JZTrackFrame::~JZTrackFrame()
{
+ int XPosition, YPosition, Width, Height;
+
+ GetPosition(&XPosition, &YPosition);
+ GetSize(&Width, &Height);
+
+ gpConfig->Put(C_TrackWinXpos, XPosition);
+ gpConfig->Put(C_TrackWinYpos, YPosition);
+ gpConfig->Put(C_TrackWinWidth, Width);
+ gpConfig->Put(C_TrackWinHeight, Height);
+
delete mpToolBar;
}
@@ -433,6 +447,18 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+void JZTrackFrame::OnFileNew(wxCommandEvent& Event)
+{
+ if (wxMessageBox("Clear Song?", "Sure?", wxOK | wxCANCEL) == wxOK)
+ {
+ gpProject->Clear();
+ mpTrackWindow->Refresh(false);
+// NextWin->NewPosition(1, 0);
+ }
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZTrackFrame::OnFileOpen(wxCommandEvent& Event)
{
// Use an open dialog to find the Jazz++ configuration file.
@@ -509,6 +535,14 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+void JZTrackFrame::OnRecord(wxCommandEvent& Event)
+{
+ wxMouseEvent MouseEvent;
+ MousePlay(MouseEvent, eRecordButton);
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZTrackFrame::OnPianoWindow(wxCommandEvent& Event)
{
JZProjectManager::Instance()->CreatePianoView();
@@ -629,169 +663,4 @@
void JZTrackFrame::MousePlay(wxMouseEvent& Event, TEMousePlayMode Mode)
{
mpTrackWindow->MousePlay(Event, Mode);
-
-/*
- if (Mode == eMouse && !Event.ButtonDown())
- {
- return;
- }
-
- // This is a little hack to keep it working for now.
- // All this stuff needs to be moved.
- JZRecordingInfo* pRecInfo = gpProject->GetRecInfo();
-
- if (!gpProject->IsPlaying())
- {
- switch (Mode)
- {
- case eMouse:
- int x, y;
- Event.GetPosition(&x, &y);
- gpProject->SetPlayPosition(x2BarClock((long)x));
- gpProject->Mute((Event.RightDown() != 0));
- if (mpSnapSel->Selected && (Event.ShiftDown() || Event.MiddleDown()))
- {
- gpProject->SetLoop(true);
- }
- else
- {
- gpProject->SetLoop(false);
- mPreviouslyRecording = mpSnapSel->Selected;
- }
- break;
-
- case eSpaceBar:
- break;
-
- case ePlayButton:
- gpProject->SetLoop(false);
- gpProject->SetRecord(false);
- break;
-
- case ePlayLoopButton:
- if (!EventsSelected("please select loop range first"))
- {
- return;
- }
- gpProject->SetLoop(true);
- gpProject->SetRecord(false);
- break;
-
- case eRecordButton:
- if (!EventsSelected("please select record track/bar first"))
- {
- return;
- }
- JZBarInfo bi(gpProject);
-
- bi.SetClock(mpFilter->FromClock);
-
- if (bi.BarNr > 0)
- {
- bi.SetBar(bi.BarNr - 1);
- }
- gpProject->SetPlayPosition(bi.Clock);
- gpProject->SetRecord(true);
- gpProject->SetLoop(false);
- break;
- }
-
- // todo: Figure out if we should have getters for these instead
- // and make them private jppProject members
- bool loop = gpProject->mLoop;
- bool muted = gpProject->mMuted;
- bool record = gpProject->mRecord;
-
- // Is it possible to record?
- if (record && mpSnapSel->Selected)
- {
- pRecInfo->mTrackIndex = mpFilter->FromTrack;
-
- pRecInfo->mpTrack = gpProject->GetTrack(pRecInfo->mTrackIndex);
-
- pRecInfo->mFromClock = mpFilter->FromClock;
- pRecInfo->mToClock = mpFilter->ToClock;
-
- if (muted)
- {
- pRecInfo->mIsMuted = true;
- pRecInfo->mpTrack->SetState(tsMute);
-#ifdef OBSOLETE
- LineText(
- *pDc,
- xState,
- Line2y(pRecInfo.mTrackIndex),
- wState,
- pRecInfo.Track->GetStateChar());
-#endif
- }
- else
- {
- pRecInfo->mIsMuted = false;
- }
- }
- else
- {
- pRecInfo->mpTrack = 0;
- }
-
- // Is it possible to loop?
- int loop_clock = 0;
- if (loop && mpSnapSel->Selected)
- {
- mPreviousClock = mpFilter->FromClock;
- loop_clock = mpFilter->ToClock;
- }
-
- //if (pRecInfo->Track) // recording?
- //gpProject->Midi->SetRecordInfo(pRecInfo);
- //else
- //gpProject->Midi->SetRecordInfo(0);
-
- gpProject->mStartTime = mPreviousClock;
- gpProject->mStopTime = loop_clock;
- gpProject->Play();
-
- } //if(!Midi->Playing)
- else
- {
- gpProject->Stop();
- if (pRecInfo->mpTrack)
- {
- if (pRecInfo->mIsMuted)
- {
-// wxDC* pDc = new wxClientDC(mpTrackWindow);
-
- pRecInfo->mpTrack->SetState(tsPlay);
-// LineText(
-// *pDc,
-// xState,
-// Line2y(pRecInfo->mTrackIndex),
-// wState,
-// pRecInfo->mpTrack->GetStateChar());
-
-// delete pDc;
- }
- if (
- !pRecInfo->mpTrack->GetAudioMode() &&
- !gpProject->GetPlayer()->RecdBuffer.IsEmpty())
- {
- //int choice = wxMessageBox("Keep recorded events?", "You played", wxOK | wxCANCEL);
- //if (choice == wxOK)
- {
- wxBeginBusyCursor();
- gpProject->NewUndoBuffer();
- pRecInfo->mpTrack->MergeRange(
- &gpProject->GetPlayer()->RecdBuffer,
- pRecInfo->mFromClock,
- pRecInfo->mToClock,
- pRecInfo->mIsMuted);
- wxEndBusyCursor();
- Refresh();
- NextWin->Refresh();
- }
- }
- }
- }
-*/
}
Modified: trunk/jazz/src/TrackFrame.h
===================================================================
--- trunk/jazz/src/TrackFrame.h 2008-12-26 21:35:52 UTC (rev 653)
+++ trunk/jazz/src/TrackFrame.h 2008-12-26 21:37:56 UTC (rev 654)
@@ -68,6 +68,8 @@
void CreateMenu();
+ void OnFileNew(wxCommandEvent& Event);
+
void OnFileOpen(wxCommandEvent& Event);
void OnFileSaveAs(wxCommandEvent& Event);
@@ -82,6 +84,8 @@
void OnPlayLoop(wxCommandEvent& Event);
+ void OnRecord(wxCommandEvent& Event);
+
void OnPianoWindow(wxCommandEvent& Event);
void OnToolsHarmonyBrowser(wxCommandEvent& Event);
Modified: trunk/jazz/src/TrackWindow.cpp
===================================================================
--- trunk/jazz/src/TrackWindow.cpp 2008-12-26 21:35:52 UTC (rev 653)
+++ trunk/jazz/src/TrackWindow.cpp 2008-12-26 21:37:56 UTC (rev 654)
@@ -266,7 +266,22 @@
{
wxPoint Point = Event.GetPosition();
- if (
+ if (Point.x < mNumberWidth && Point.y >= mTopInfoHeight)
+ {
+ JZRectangle Rectangle(
+ 0,
+ y2yLine(Point.y),
+ Clock2x(mpSong->GetMaxQuarters() * mpSong->GetTicksPerQuarter()),
+ mTrackHeight);
+ mpSnapSel->Select(
+ Rectangle,
+ mEventsX,
+ mEventsY,
+ mEventsWidth,
+ mEventsHeight);
+ SnapSelStop(Event);
+ }
+ else if (
Point.x >= mEventsX && Point.x < mEventsX + mEventsWidth &&
Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight)
{
@@ -1314,10 +1329,10 @@
// and make them private jppProject members
bool loop = gpProject->mLoop;
bool muted = gpProject->mMuted;
- bool record = gpProject->mRecord;
+ bool Record = gpProject->mRecord;
// Is it possible to record?
- if (record && mpSnapSel->IsSelected())
+ if (Record && mpSnapSel->IsSelected())
{
pRecInfo->mTrackIndex = mpFilter->FromTrack;
@@ -1359,10 +1374,14 @@
// GO!
- //if (pRecInfo->Track) // recording?
- //gpProject->Midi->SetRecordInfo(pRecInfo);
- //else
- //gpProject->Midi->SetRecordInfo(0);
+ if (pRecInfo->mpTrack) // recording?
+ {
+ gpMidiPlayer->SetRecordInfo(pRecInfo);
+ }
+ else
+ {
+ gpMidiPlayer->SetRecordInfo(0);
+ }
gpProject->mStartTime = mPreviousClock;
gpProject->mStopTime = loop_clock;
Modified: trunk/jazz/src/TrackWindow.h
===================================================================
--- trunk/jazz/src/TrackWindow.h 2008-12-26 21:35:52 UTC (rev 653)
+++ trunk/jazz/src/TrackWindow.h 2008-12-26 21:37:56 UTC (rev 654)
@@ -83,6 +83,12 @@
void SetScrollRanges();
+ protected:
+
+ virtual void SnapSelStop(wxMouseEvent& Event)
+ {
+ }
+
private:
void OnSize(wxSizeEvent& Event);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|