|
From: <pst...@us...> - 2008-05-04 04:43:52
|
Revision: 483
http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=483&view=rev
Author: pstieber
Date: 2008-05-03 21:43:51 -0700 (Sat, 03 May 2008)
Log Message:
-----------
Updated to get selection working in the track window in a very basic way.
This is a WIP and hasn't benn fully integrated with the new scrolling code.
Modified Paths:
--------------
trunk/jazz/src/EventWindow.cpp
trunk/jazz/src/EventWindow.h
trunk/jazz/src/MouseAction.cpp
trunk/jazz/src/MouseAction.h
trunk/jazz/src/PianoWindow.cpp
trunk/jazz/src/PianoWindow.h
trunk/jazz/src/SampleWindow.cpp
trunk/jazz/src/TrackWindow.cpp
trunk/jazz/src/TrackWindow.h
Modified: trunk/jazz/src/EventWindow.cpp
===================================================================
--- trunk/jazz/src/EventWindow.cpp 2008-05-04 04:35:13 UTC (rev 482)
+++ trunk/jazz/src/EventWindow.cpp 2008-05-04 04:43:51 UTC (rev 483)
@@ -33,7 +33,6 @@
using namespace std;
-
//*****************************************************************************
// Description:
// This is the event window class definition.
@@ -79,7 +78,7 @@
mScrolledX(0),
mScrolledY(0)
{
- mpSnapSel = new tSnapSelection(this);
+ mpSnapSel = new JZSnapSelection(this);
mpFilter = new JZFilter(mpSong);
@@ -106,7 +105,7 @@
//-----------------------------------------------------------------------------
int JZEventWindow::EventsSelected(const wxString& Message) const
{
- if (!mpSnapSel->Selected)
+ if (!mpSnapSel->IsSelected())
{
wxMessageBox(Message, "Error", wxOK);
return 0;
@@ -401,7 +400,6 @@
mpFilter = new JZFilter(Song);
}
-
JZEventFrame::~JZEventFrame()
{
delete SnapSel;
@@ -421,18 +419,17 @@
}
}
-
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::CreateMenu()
{
}
-/**
-
-create the canvas component(used for differently dependingon the subclass)
-size it to the client area of the frame(frame size minus toolbar and menus )
-*/
+//-----------------------------------------------------------------------------
+// create the canvas component(used for differently dependingon the subclass)
+// size it to the client area of the frame(frame size minus toolbar and menus )
+//-----------------------------------------------------------------------------
//void JZEventFrame::CreateCanvas()
//{
// cout << "CreateCanvas" << endl;
@@ -451,8 +448,9 @@
Setup();
}
-
+//-----------------------------------------------------------------------------
// Initialize the constants used in drawing.
+//-----------------------------------------------------------------------------
void JZEventFrame::Setup()
{
/*
@@ -478,11 +476,10 @@
*/
}
-
-/**
-this onsize handler is supposed to take care of handling of the resizing the two subwindows sizes to
-they dont overlap
-*/
+//-----------------------------------------------------------------------------
+// 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)
{
// wxFrame::OnSize(Event);
@@ -535,11 +532,8 @@
return OnKeyEvent(e);
}
-// *******************************************************************
-// Coord-Functions
-// *******************************************************************
-
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
int JZEventFrame::y2yLine(int y, int up)
{
if (up)
@@ -552,6 +546,8 @@
return y;
}
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
int JZEventFrame::y2Line(int y, int up)
{
if (up)
@@ -562,13 +558,16 @@
return y / mTrackHeight;
}
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
int JZEventFrame::Line2y(int Line)
{
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)
@@ -618,10 +617,8 @@
}
*/
-// *******************************************************************
-// Painting behavior
-// *******************************************************************
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::Redraw()
{
// wxDC* dc=new wxClientDC(this);
@@ -631,29 +628,26 @@
// //the problem is that onpaint no longer tkes no argument, and is supposed to be called from the framework only, so it should be split
// delete dc;
-
-
// mpEventWindow->Refresh();
-
}
-// ******************************************************************
-// Mouse
-// ******************************************************************
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
bool JZEventFrame::OnKeyEvent(wxKeyEvent &e)
{
return false;
}
-/** seems to handle the "selection" rectangle. normally called from the base class onmouseevent handler */
+//-----------------------------------------------------------------------------
+// seems to handle the "selection" rectangle. normally called from the base
+// class onmouseevent handler
+//-----------------------------------------------------------------------------
int JZEventFrame::OnMouseEvent(wxMouseEvent &e)
{
// cout <<"JZEventFrame::OnMouseEvent"<<endl;
if (!MouseAction)
{
// create SnapSel?
-
int x;
int y;
e.GetPosition(&x, &y);
@@ -664,7 +658,8 @@
{
SnapSelStart(e);
- if (SnapSel->Selected){
+ if (SnapSel->IsSelected())
+ {
Refresh(); //redraw the whole window instead(inefficient, we should rather invalidate a rect)
}
SnapSel->Event(e);
@@ -673,7 +668,6 @@
}
}
}
-
else
{
// MouseAction active
@@ -696,38 +690,36 @@
return 0;
}
-// ******************************************************************
-// dummies
-// ******************************************************************
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
bool JZEventFrame::OnClose()
{
return FALSE;
}
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::OnMenuCommand(int)
{
}
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::SnapSelStart(wxMouseEvent& MouseEvent)
{
}
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::SnapSelStop(wxMouseEvent& MouseEvent)
{
}
//-----------------------------------------------------------------------------
-// PlayPosition
//-----------------------------------------------------------------------------
-
-// **************************************************************************
-// EventsSelected
-// **************************************************************************
-
-int JZEventFrame::EventsSelected(const char *msg)
+int JZEventFrame::EventsSelected(const char* msg)
{
- if (!SnapSel->Selected)
+ if (!SnapSel->IsSelected())
{
if (msg == 0)
{
@@ -739,158 +731,104 @@
return 1;
}
-// **************************************************************************
-// Quantize
-// **************************************************************************
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::MenQuantize()
{
-
-
if (!EventsSelected())
return;
// wxDialogBox *panel = new wxDialogBox(this, "Quantize", FALSE );
tQuantizeDlg * dlg = new tQuantizeDlg(this, mpFilter);
dlg->Create();
-
-
}
-// **************************************************************************
-// Cleanup
-// **************************************************************************
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::MenCleanup()
{
-
-
if (!EventsSelected())
return;
tCleanupDlg * dlg = new tCleanupDlg(this, mpFilter);
dlg->Create();
-
}
-
-// **************************************************************************
-// SearchReplace
-// **************************************************************************
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::MenSearchReplace()
{
-
-
if (!EventsSelected())
return;
tSearchReplaceDlg * dlg = new tSearchReplaceDlg(this, mpFilter);
dlg->Create();
-
-
}
-
-// **************************************************************************
-// SetChannel
-// **************************************************************************
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::MenSetChannel()
{
-
-
if (!EventsSelected())
return;
tSetChannelDlg * dlg = new tSetChannelDlg(mpFilter);
dlg->Create();
-
}
-
-// **************************************************************************
-// Transpose
-// **************************************************************************
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::MenTranspose()
{
-
-
if (!EventsSelected())
return;
tTransposeDlg * dlg = new tTransposeDlg(this, mpFilter);
dlg->Create();
-
-
}
-/**show the "shift events" dialog */
-
+//-----------------------------------------------------------------------------
+// show the "shift events" dialog
+//-----------------------------------------------------------------------------
void JZEventFrame::MenShift(int Unit)
{
if (EventsSelected())
{
-
tShiftDlg * dlg = new tShiftDlg(this, mpFilter, Unit);
dlg->Create();
}
-
-
}
-
-// ********************************************************************************
-// Delete
-// ********************************************************************************
-
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::MenDelete()
{
-
-
if (!EventsSelected())
return;
tDeleteDlg * dlg = new tDeleteDlg(this, mpFilter);
dlg->Create();
}
-// ********************************************************************************
-// Velocity
-// ********************************************************************************
-
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::MenVelocity()
{
-
if (!EventsSelected())
return;
tVelocityDlg * dlg = new tVelocityDlg(mpFilter);
dlg->Create();
}
-// ********************************************************************************
-// Length
-// ********************************************************************************
-
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventFrame::MenLength()
{
-
-
if (!EventsSelected())
return;
tLengthDlg * dlg = new tLengthDlg(this, mpFilter);
dlg->Create();
-
}
-
-// ********************************************************************************
+//-----------------------------------------------------------------------------
// convert to modulation
-// ********************************************************************************
-
-
+//-----------------------------------------------------------------------------
void JZEventFrame::MenConvertToModulation()
{
-
-
if (!EventsSelected())
return;
tCmdConvertToModulation cmd(mpFilter);
@@ -898,30 +836,23 @@
Redraw();
}
-
-
-
-
-// ******************************************************************
+//*****************************************************************************
// MeterChange Dialog
-// ******************************************************************
-
-
+//*****************************************************************************
class tMeterChangeDlg : public tPropertyListDlg
{
-public:
- JZEventFrame *EventWin;
- static int Numerator;
- static int Denomiator;
- static int BarNr;
- tMeterChangeDlg(JZEventFrame *w);
- void AddProperties();
- virtual bool OnClose();
- virtual void OnCancel();
- virtual void OnHelp();
+ public:
+ JZEventFrame *EventWin;
+ static int Numerator;
+ static int Denomiator;
+ static int BarNr;
+ tMeterChangeDlg(JZEventFrame *w);
+ void AddProperties();
+ virtual bool OnClose();
+ virtual void OnCancel();
+ virtual void OnHelp();
};
-
int tMeterChangeDlg::Numerator = 4;
int tMeterChangeDlg::Denomiator = 4;
int tMeterChangeDlg::BarNr = 1;
@@ -932,14 +863,12 @@
EventWin = w;
}
-
void tMeterChangeDlg::OnCancel()
{
EventWin->mpSettingsDialog = 0;
//wxForm::OnCancel();
}
-
bool tMeterChangeDlg::OnClose()
{
BarNr += EventWin->Song->GetIntroLength();
@@ -955,7 +884,6 @@
gpHelpInstance->ShowTopic("Meterchange");
}
-
void tMeterChangeDlg::AddProperties()
{
// Add(wxMakeFormShort("BarNr:", &BarNr, wxFORM_DEFAULT, 0,0,0,100));
@@ -980,8 +908,6 @@
"integer"));//JAVE should be a integer list instead FIXME
}
-
-
void JZEventFrame::MenMeterChange()
{
tMeterChangeDlg *dlg;
Modified: trunk/jazz/src/EventWindow.h
===================================================================
--- trunk/jazz/src/EventWindow.h 2008-05-04 04:35:13 UTC (rev 482)
+++ trunk/jazz/src/EventWindow.h 2008-05-04 04:43:51 UTC (rev 483)
@@ -40,7 +40,7 @@
{
public:
- tSnapSelection* mpSnapSel;
+ JZSnapSelection* mpSnapSel;
JZFilter* mpFilter;
@@ -182,7 +182,7 @@
int FromLine, ToLine;
// Mousehandling
- tSnapSelection *SnapSel;
+ JZSnapSelection *SnapSel;
tMouseAction *MouseAction;
virtual void SnapSelStart(wxMouseEvent &e);
virtual void SnapSelStop(wxMouseEvent &e);
Modified: trunk/jazz/src/MouseAction.cpp
===================================================================
--- trunk/jazz/src/MouseAction.cpp 2008-05-04 04:35:13 UTC (rev 482)
+++ trunk/jazz/src/MouseAction.cpp 2008-05-04 04:43:51 UTC (rev 483)
@@ -67,335 +67,389 @@
actions[i] = code;
}
-int tMouseMapper::Action(wxMouseEvent &e)
+int tMouseMapper::Action(wxMouseEvent& Event)
{
- if (!e.ButtonDown())
+ if (!Event.ButtonDown())
+ {
return 0;
+ }
- if (left_action > 0 && e.LeftDown() &&!e.ShiftDown() && !e.ControlDown())
+ if (
+ left_action > 0 &&
+ Event.LeftDown() &&
+ !Event.ShiftDown() &&
+ !Event.ControlDown())
+ {
return left_action;
+ }
int i = 0; // left down
- if (e.MiddleDown())
+ if (Event.MiddleDown())
+ {
i = 1;
- else
- if (e.RightDown())
+ }
+ else if (Event.RightDown())
+ {
i = 2;
+ }
- if (e.ShiftDown())
+ if (Event.ShiftDown())
+ {
i += 3;
- if (e.ControlDown())
+ }
+ if (Event.ControlDown())
+ {
i += 6;
+ }
return actions[i];
}
-//////////////////////////////////////////////////////////
-//tSelection implementation
-
-tSelection::tSelection(wxWindow* pWindow)
- : win(pWindow),
+//*****************************************************************************
+// Description:
+// This is the selection class definition.
+//*****************************************************************************
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZSelection::JZSelection(wxWindow* pWindow)
+ : mActive(false),
+ mSelected(false),
+ mRectangle(),
+ mpWindow(pWindow),
mpBackgroundBrush(0)
{
- Active = 0;
- Selected = false;
- mpBackgroundBrush = new wxBrush(wxColor(192, 192, 192), wxSOLID);
+// mpBackgroundBrush = new wxBrush(wxColor(192, 192, 192), wxSOLID);
+ mpBackgroundBrush = new wxBrush(wxColor(100, 100, 100), wxSOLID);
}
-tSelection::~tSelection()
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZSelection::~JZSelection()
{
delete mpBackgroundBrush;
}
-int tSelection::Event(wxMouseEvent &e)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+int JZSelection::Event(wxMouseEvent& Event)
{
- if (e.ButtonDown())
- return ButtonDown(e);
- else if (e.ButtonUp())
- return ButtonUp(e);
- else if (e.Dragging())
- return Dragging(e);
+ if (Event.ButtonDown())
+ {
+ return ButtonDown(Event);
+ }
+ else if (Event.ButtonUp())
+ {
+ return ButtonUp(Event);
+ }
+ else if (Event.Dragging())
+ {
+ return Dragging(Event);
+ }
return 0;
}
-int tSelection::ButtonDown(wxMouseEvent &e)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+int JZSelection::ButtonDown(wxMouseEvent& Event)
{
- if (!Active)
+ if (!mActive)
{
-#ifdef __WXMSW__
-//OBSOLETE Canvas->CaptureMouse();
-#endif
- Active = 1;
-// wxDC *dc = new wxPaintDC(win);//Canvas->GetDC();
-// Dc.SetBrush(*mpBackgroundBrush);
-// Dc.SetLogicalFunction(wxXOR);
- if (Selected && e.ShiftDown())
+ mActive = true;
+ if (mSelected && Event.ShiftDown())
{
// Continue selection
- JZRectangle rr = r;
- rr.SetNormal();
-// if (rr.width && rr.height)
-// Dc.DrawRectangle(rr.x, rr.y, rr.width, rr.height);
- Dragging(e);
+ JZRectangle Rectangle = mRectangle;
+ Rectangle.SetNormal();
+ Dragging(Event);
}
else
{
- Selected = false;
- int x, y;
- //e.Position(&x, &y);
- wxDC *dc = new wxClientDC(win);//Canvas->GetDC();
- wxPoint point=e.GetLogicalPosition(*dc);
- delete dc;
- x=point.x;y=point.y;
+ mSelected = false;
+ int x = Event.GetX();
+ int y = Event.GetY();
Snap(x, y, 0);
- r.x = x;
- r.y = y;
- r.width = 1;
- r.height = 1;
-// Dc.DrawRectangle(r.x, r.y, r.width, r.height);
- //Dragging(e);
+ mRectangle.x = x;
+ mRectangle.y = y;
+ mRectangle.width = 1;
+ mRectangle.height = 1;
}
-// Dc.SetLogicalFunction(wxCOPY);
}
- win->Refresh(); //invalidate
return 0;
}
-
-int tSelection::Dragging(wxMouseEvent &e)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+int JZSelection::Dragging(wxMouseEvent& Event)
{
- if (!Active)
- ButtonDown(e);
+ if (!mActive)
+ {
+ ButtonDown(Event);
+ }
- if (Active)
+ if (mActive)
{
- int x, y;
- JZRectangle r1, r2; //r1=previous rect, r2=new rect
-
- wxDC *dc = new wxClientDC(win);
- wxPoint point=e.GetLogicalPosition(*dc);
- delete dc;
-
- x=point.x;
- y=point.y;
- if ((short)x < 0)
+ int x = Event.GetX();
+ int y = Event.GetY();
+ if (x < 0)
+ {
x = 0;
- if ((short)y < 0)
+ }
+ if (y < 0)
+ {
y = 0;
+ }
Snap(x, y, 1);
- r1 = r;
- r1.SetNormal();
-
- r.width = x - r.x;
- r.height = y - r.y;
-
- r2 = r;
- r2.SetNormal();
-
- win->Refresh(TRUE, &r1);
- win->Refresh(TRUE, &r2);
+ mRectangle.width = x - mRectangle.x;
+ mRectangle.height = y - mRectangle.y;
}
- //invalidate both old and new rect
return 0;
}
-
-int tSelection::ButtonUp(wxMouseEvent &e)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+int JZSelection::ButtonUp(wxMouseEvent& Event)
{
- if (Active)
+ if (mActive)
{
-#ifdef __WXMSW__
-//OBSOLETE Canvas->ReleaseMouse();
-#endif
- Active = 0;
- r.SetNormal();
-// wxDC *dc = new wxPaintDC(win);//Canvas->GetDC();
+ mActive = false;
+ mRectangle.SetNormal();
-// Dc.SetLogicalFunction(wxXOR);
-// if (r.width && r.height)
-// Dc.DrawRectangle(r.x, r.y, r.width, r.height);
-// Dc.SetLogicalFunction(wxCOPY);
- Selected = (r.width > 3 && r.height > 3); //its selected only if larger than 3x3 pixels
+ // Only select if the rectangle is larger than 3x3 pixels.
+ mSelected = (mRectangle.width > 3 && mRectangle.height > 3);
return 1;
}
- win->Refresh();
+
+ mpWindow->Refresh();
return 0;
}
+//-----------------------------------------------------------------------------
// Description:
// Draw the selected rectangle, normally called from OnDraw
// in the parent window.
-void tSelection::Draw(wxDC& Dc)
+//-----------------------------------------------------------------------------
+void JZSelection::Draw(wxDC& Dc, int ScrolledX, int ScrolledY)
{
-// cout
-// << "tSelection::Draw ---------------------------------------------------"
-// << endl;
- // Dc.DrawRectangle(100,100,100,100);
-// if (Selected) //we cant check for "selected" here, because...
-// {
+// if (mSelected)
+ {
+ JZRectangle Rectangle = mRectangle;
- JZRectangle rr = r;
-
- Dc.DestroyClippingRegion();
-
Dc.SetLogicalFunction(wxXOR);
Dc.SetBrush(*mpBackgroundBrush);
- rr.SetNormal();
- if (rr.width && rr.height)
+ Rectangle.SetNormal();
+ if (Rectangle.width && Rectangle.height)
{
- Dc.DrawRectangle(rr.x, rr.y, rr.width, rr.height);
+ Dc.DrawRectangle(
+ Rectangle.x - ScrolledX,
+ Rectangle.y - ScrolledY,
+ Rectangle.width,
+ Rectangle.height);
}
Dc.SetLogicalFunction(wxCOPY);
-// }
+ }
}
-// Draw, but use clipping to redruce drawing
-void tSelection::Draw(wxDC& Dc, int x, int y, int w, int h)
+//-----------------------------------------------------------------------------
+// Description:
+// Draw, but use clipping to redruce drawing.
+//-----------------------------------------------------------------------------
+void JZSelection::Draw(
+ wxDC& Dc,
+ int ScrolledX,
+ int ScrolledY,
+ int ClipX,
+ int ClipY,
+ int ClipWidth,
+ int ClipHeight)
{
-// if (Selected)
-// {
- Dc.SetClippingRegion(x, y, w, h);
- Draw(Dc);
+// if (mSelected)
+ {
+ Dc.SetClippingRegion(ClipX, ClipY, ClipWidth, ClipHeight);
+ Draw(Dc, ScrolledX, ScrolledY);
Dc.DestroyClippingRegion();
- // }
+ }
}
+//-----------------------------------------------------------------------------
// I think this one is meant to select a rectangle and repaint it.
// It did this by drawing directly in the device context. This is bad, so I
// tried changing it to invalidation instead.
-void tSelection::Select(JZRectangle &rr, int x, int y, int w, int h)
+//-----------------------------------------------------------------------------
+void JZSelection::Select(JZRectangle& Rectangle, int x, int y, int w, int h)
{
// clear old rectangle
// Draw(x, y, w, h);
// make new one
- r = rr;
- Selected = true;
+ mRectangle = Rectangle;
+ mSelected = true;
// Draw(x, y, w, h);
- win->Refresh(); //inefficient because should invvalidate only the rectangle
+
+ // Inefficient because should invalidate only the rectangle.
+ mpWindow->Refresh();
}
-void tSelection::Select(JZRectangle &rr)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZSelection::Select(JZRectangle& Rectangle)
{
- Select(rr, 0,0,3000,3000);
+ Select(Rectangle, 0, 0, 3000, 3000);
}
-// ***********************************************************************
-// tSnapSelection
-// ***********************************************************************
+//*****************************************************************************
+// Description:
+// This is the snap selection class definition.
+//*****************************************************************************
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZSnapSelection::JZSnapSelection(wxWindow* pWindow)
+ : JZSelection(pWindow),
+ mXCoordinates(),
+ mYCoordinates(),
+ mXMin(0),
+ mXMax(0),
+ mXStep(0),
+ mYMin(0),
+ mYMax(0),
+ mYStep(0)
+{
+}
-
-
-
-static void SnapVec(int &x, int *Coords, int nCoords, int up)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZSnapSelection::Snap(int& x, int& y, bool drag)
{
- int i;
- for (i = 0; i < nCoords; i++)
+ if (!mXCoordinates.empty())
{
- if (Coords[i] > x)
- {
- if (up || i == 0)
- x = Coords[i];
- else
- x = Coords[i-1];
- return;
- }
+ SnapToVector(x, mXCoordinates, drag);
}
- x = Coords[nCoords - 1];
-}
+ else if (mXStep)
+ {
+ SnapMod(x, mXMin, mXMax, mXStep, drag);
+ }
-
-static void SnapMod(int &x, int Min, int Max, int Step, int up)
-{
- if (x <= Min)
+ if (!mYCoordinates.empty())
{
- x = Min;
- return;
+ SnapToVector(y, mYCoordinates, drag);
}
- if (x >= Max)
+ else if (mYStep)
{
- x = Max;
- return;
+ SnapMod(y, mYMin, mYMax, mYStep, drag);
}
- x -= (x - Min) % Step;
- if (up)
- x += Step;
}
-
-
-void tSnapSelection::Snap(float &fx, float &fy, int drag)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZSnapSelection::SetXSnap(int XCount, int* pXVector)
{
- int x = (int)fx;
- int y = (int)fy;
- if (xCoords)
- SnapVec(x, xCoords, nxCoords, drag);
- else if (xStep)
- SnapMod(x, xMin, xMax, xStep, drag);
-
- if (yCoords)
- SnapVec(y, yCoords, nyCoords, drag);
- else if (yStep)
- SnapMod(y, yMin, yMax, yStep, drag);
- fx = x;
- fy = y;
+ mXCoordinates.clear();
+ for (int i = 0; i < XCount; ++i)
+ {
+ mXCoordinates.push_back(pXVector[i]);
+ }
+ mXStep = 0;
}
-
-tSnapSelection::tSnapSelection(wxWindow *c)
- : tSelection(c)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZSnapSelection::SetYSnap(int YCount, int* pYVector)
{
- xCoords = 0;
- yCoords = 0;
- xStep = yStep = 0;
+ mYCoordinates.clear();
+ for (int i = 0; i < YCount; ++i)
+ {
+ mXCoordinates.push_back(pYVector[i]);
+ }
+ mYStep = 0;
}
-void tSnapSelection::SetXSnap(int nx, int *cx)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZSnapSelection::SetXSnap(int XMin, int XMax, int XStep)
{
- xCoords = cx;
- nxCoords = nx;
- xStep = 0;
+ mXMin = XMin;
+ mXMax = XMax;
+ mXStep = XStep;
+ mXCoordinates.clear();
}
-void tSnapSelection::SetYSnap(int ny, int *cy)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZSnapSelection::SetYSnap(int YMin, int YMax, int YStep)
{
- yCoords = cy;
- nyCoords = ny;
- yStep = 0;
+ mYMin = YMin;
+ mYMax = YMax;
+ mYStep = YStep;
+ mYCoordinates.clear();
}
-void tSnapSelection::SetXSnap(int xmin, int xmax, int xstep)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZSnapSelection::SnapToVector(
+ int& Coordinate,
+ vector<int> Vector,
+ bool Up)
{
- xMin = xmin;
- xMax = xmax;
- xStep = xstep;
- xCoords = 0;
+ for (unsigned i = 0; i < Vector.size(); ++i)
+ {
+ if (Vector[i] > Coordinate)
+ {
+ if (Up || i == 0)
+ {
+ Coordinate = Vector[i];
+ }
+ else
+ {
+ Coordinate = Vector[i - 1];
+ }
+ return;
+ }
+ }
+ Coordinate = Vector[Vector.size() - 1];
}
-void tSnapSelection::SetYSnap(int ymin, int ymax, int ystep)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZSnapSelection::SnapMod(
+ int& Coordinate,
+ int Min,
+ int Max,
+ int Step,
+ bool Up)
{
- yMin = ymin;
- yMax = ymax;
- yStep = ystep;
- yCoords = 0;
+ if (Coordinate <= Min)
+ {
+ Coordinate = Min;
+ return;
+ }
+ if (Coordinate >= Max)
+ {
+ Coordinate = Max;
+ return;
+ }
+ Coordinate -= (Coordinate - Min) % Step;
+ if (Up)
+ {
+ Coordinate += Step;
+ }
}
// *************************************************************************
// tMouseCounter
// *************************************************************************
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
tMouseCounter::tMouseCounter(
tButtonLabelInterface* wwin,
- JZRectangle* rr,
+ JZRectangle* Rectangle,
int val,
int min,
int max,
int wait)
{
win = wwin;
- r = *rr;
+ r = *Rectangle;
Value = val;
Min = min;
Max = max;
@@ -403,45 +457,59 @@
Wait = wait;
}
-
-int tMouseCounter::LeftDown(wxMouseEvent &e)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+int tMouseCounter::LeftDown(wxMouseEvent& Event)
{
- Delta = e.ShiftDown() ? 10 : 1;
+ Delta = Event.ShiftDown() ? 10 : 1;
Start(Timeout);
if (Wait)
+ {
ShowValue(TRUE);
+ }
else
+ {
Notify();
+ }
return 0;
}
-int tMouseCounter::LeftUp(wxMouseEvent &e)
+int tMouseCounter::LeftUp(wxMouseEvent& Event)
{
Stop();
ShowValue(FALSE);
return 1;
}
-int tMouseCounter::RightDown(wxMouseEvent &e)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+int tMouseCounter::RightDown(wxMouseEvent& Event)
{
- Delta = e.ShiftDown() ? -10 : -1;
+ Delta = Event.ShiftDown() ? -10 : -1;
Start(Timeout);
if (Wait)
+ {
ShowValue(TRUE);
+ }
else
+ {
Notify();
+ }
return 0;
+
}
-
-int tMouseCounter::RightUp(wxMouseEvent &e)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+int tMouseCounter::RightUp(wxMouseEvent& Event)
{
Stop();
ShowValue(FALSE);
return 1;
}
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void tMouseCounter::Notify()
{
Value += Delta;
@@ -458,7 +526,8 @@
}
}
-
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void tMouseCounter::ShowValue(bool down)
{
char buf[20];
@@ -485,7 +554,7 @@
//Frame->SetStatusText("Click Destination point");
}
-int tMarkDestin::ButtonDown(wxMouseEvent &e)
+int tMarkDestin::ButtonDown(wxMouseEvent& Event)
{
wxCursor c = wxCursor(wxCURSOR_ARROW);
Canvas->SetCursor(c);
@@ -493,7 +562,7 @@
//converts physical coords to logical(scrolled) coords
wxClientDC* scrolledDC=new wxClientDC(Canvas);
Canvas->PrepareDC(*scrolledDC);
- wxPoint point=e.GetLogicalPosition(*scrolledDC);
+ wxPoint point = Event.GetLogicalPosition(*scrolledDC);
delete scrolledDC;
x=point.x;
@@ -502,17 +571,17 @@
return 1;
}
-int tMarkDestin::RightDown(wxMouseEvent &e)
+int tMarkDestin::RightDown(wxMouseEvent& Event)
{
- ButtonDown(e);
+ ButtonDown(Event);
Aborted = 1;
//Frame->SetStatusText("Operation aborted");
return 1;
}
-int tMarkDestin::LeftDown(wxMouseEvent &e)
+int tMarkDestin::LeftDown(wxMouseEvent& Event)
{
- ButtonDown(e);
+ ButtonDown(Event);
Aborted = 0;
//Frame->SetStatusText("");
return 1;
Modified: trunk/jazz/src/MouseAction.h
===================================================================
--- trunk/jazz/src/MouseAction.h 2008-05-04 04:35:13 UTC (rev 482)
+++ trunk/jazz/src/MouseAction.h 2008-05-04 04:43:51 UTC (rev 483)
@@ -29,6 +29,8 @@
#include "Rectangle.h"
+#include <vector>
+
class JZEventWindow;
enum TEMousePlayMode
@@ -140,56 +142,125 @@
//*****************************************************************************
// Description:
-// Selection - draw a rectangle with the mouse, selecting events
-// This class needs to draw in the window, thus it needs access to the
-// device context of the window. This was by storing a wxCanvas pointer
-// in wxwin168, but wxCanvas is gone in wxwin2.
+// This is the selection class declaration. This class selects events using
+// the mouse and draws indicating the selected events.
//*****************************************************************************
-class tSelection : public tMouseAction
+class JZSelection : public tMouseAction
{
public:
- tSelection(wxWindow* w);//wxCanvas *canvas);
- virtual ~tSelection();
+ JZSelection(wxWindow* pWindow);
- int Active;
- virtual void Snap(int &x, int &y, int drag) {}
- JZRectangle r;
- bool Selected; // r is valid
- virtual int Dragging(wxMouseEvent &);
- virtual int Event(wxMouseEvent &e);
- virtual int ButtonDown(wxMouseEvent &);
- virtual int ButtonUp(wxMouseEvent &);
- virtual void Draw(wxDC& Dc);
- virtual void Draw(wxDC& Dc, int x, int y, int w, int h); // clipping
- // may not be called while dragging
- void Select(JZRectangle &rr, int x, int y, int w, int h);
- void Select(JZRectangle &rr);
+ virtual ~JZSelection();
+ virtual bool IsActive() const
+ {
+ return mActive;
+ }
+
+ virtual bool IsSelected() const
+ {
+ return mSelected;
+ }
+
+ virtual void SetSelected(bool Selected)
+ {
+ mSelected = Selected;
+ }
+
+ virtual const JZRectangle& GetRectangle() const
+ {
+ return mRectangle;
+ }
+
+ virtual void SetRectangle(const JZRectangle& Rectangle)
+ {
+ mRectangle = Rectangle;
+ }
+
+ virtual void Snap(int& x, int& y, bool drag)
+ {
+ }
+
+ virtual int Dragging(wxMouseEvent& Event);
+
+ virtual int Event(wxMouseEvent& Event);
+
+ virtual int ButtonDown(wxMouseEvent& Event);
+
+ virtual int ButtonUp(wxMouseEvent& Event);
+
+ virtual void Draw(wxDC& Dc, int ScrolledX, int ScrolledY);
+
+ // Drawing with clipping.
+ virtual void Draw(
+ wxDC& Dc,
+ int ScrolledX,
+ int ScrolledY,
+ int ClipX,
+ int ClipY,
+ int ClipWidth,
+ int ClipHeight);
+
+ // May not be called while dragging.
+ void Select(JZRectangle& rr, int x, int y, int w, int h);
+
+ void Select(JZRectangle& Rectangle);
+
private:
- wxWindow* win;
+ bool mActive;
- // wxCanvas *Canvas;
+ // The following indicates if the rectangle is valid.
+ bool mSelected;
+ JZRectangle mRectangle;
+
+ wxWindow* mpWindow;
+
wxBrush* mpBackgroundBrush;
};
//*****************************************************************************
+// Description:
+// This is the snap selection class declaration.
//*****************************************************************************
-class tSnapSelection : public tSelection
+class JZSnapSelection : public JZSelection
{
public:
- tSnapSelection(wxWindow *c);
- virtual void Snap(float &x, float &y, int up);
- void SetXSnap(int ny, int *cx);
- void SetYSnap(int ny, int *cy);
- void SetXSnap(int xMin, int xMax, int xStep);
- void SetYSnap(int yMin, int yMax, int yStep);
+ JZSnapSelection(wxWindow* pWindow);
+
+ virtual void Snap(int& x, int& y, bool Up);
+
+ void SetXSnap(int XCount, int* pXVector);
+
+ void SetYSnap(int YCount, int* pYVector);
+
+ void SetXSnap(int XMin, int XMax, int XStep);
+
+ void SetYSnap(int YMin, int YMax, int YStep);
+
+ private:
+
+ static void SnapToVector(
+ int& Coordinate,
+ std::vector<int> Vector,
+ bool Up);
+
+ static void SnapMod(
+ int& Coordinate,
+ int Min,
+ int Max,
+ int Step,
+ bool Up);
+
protected:
- int *xCoords, nxCoords;
- int *yCoords, nyCoords;
- int xMin, xMax, xStep, yMin, yMax, yStep;
+
+ std::vector<int> mXCoordinates;
+
+ std::vector<int> mYCoordinates;
+
+ int mXMin, mXMax, mXStep, mYMin, mYMax, mYStep;
};
Modified: trunk/jazz/src/PianoWindow.cpp
===================================================================
--- trunk/jazz/src/PianoWindow.cpp 2008-05-04 04:35:13 UTC (rev 482)
+++ trunk/jazz/src/PianoWindow.cpp 2008-05-04 04:43:51 UTC (rev 483)
@@ -997,7 +997,14 @@
DrawPlayPosition(LocalDc);
// Draw the selection box.
- mpSnapSel->Draw(LocalDc, mEventsX, mEventsY, mEventsWidth, mEventsHeight);
+ mpSnapSel->Draw(
+ LocalDc,
+ mScrolledX,
+ mScrolledY,
+ mEventsX,
+ mEventsY,
+ mEventsWidth,
+ mEventsHeight);
Dc.Blit(
0,
@@ -1022,7 +1029,10 @@
//-----------------------------------------------------------------------------
void JZPianoWindow::DrawPlayPosition(wxDC& Dc)
{
- if (!mpSnapSel->Active && mPlayClock >= mFromClock && mPlayClock < mToClock)
+ if (
+ !mpSnapSel->IsActive() &&
+ mPlayClock >= mFromClock &&
+ mPlayClock < mToClock)
{
Dc.SetBrush(*wxBLACK_BRUSH);
Dc.SetPen(*wxBLACK_PEN);
@@ -1639,7 +1649,7 @@
int Clock, LoopClock;
if (action == MA_CYCLE)
{
- if (mpSnapSel->Selected)
+ if (mpSnapSel->IsSelected())
{
Clock = mpFilter->FromClock;
LoopClock = mpFilter->ToClock;
@@ -1805,10 +1815,11 @@
//-----------------------------------------------------------------------------
void JZPianoWindow::SnapSelStop(wxMouseEvent& Event)
{
- if (mpSnapSel->Selected)
+ if (mpSnapSel->IsSelected())
{
- int fr = y2Pitch((mpSnapSel->r.y + mpSnapSel->r.height - 1));
- int to = y2Pitch(mpSnapSel->r.y + 1);
+ int fr = y2Pitch(
+ mpSnapSel->GetRectangle().y + mpSnapSel->GetRectangle().height - 1);
+ int to = y2Pitch(mpSnapSel->GetRectangle().y + 1);
mpFilter->FltEvents[FltKeyOn].Selected = mVisibleKeyOn;
mpFilter->FltEvents[FltKeyOn].FromValue = fr;
@@ -1847,13 +1858,16 @@
mpFilter->FromTrack = mTrackIndex;
mpFilter->ToTrack = mTrackIndex;
- mpFilter->FromClock = SnapClock(x2Clock(mpSnapSel->r.x + 1));
- mpFilter->ToClock = SnapClock(x2Clock((mpSnapSel->r.x + mpSnapSel->r.width + 1)));
+ mpFilter->FromClock = SnapClock(x2Clock(mpSnapSel->GetRectangle().x + 1));
+ mpFilter->ToClock = SnapClock(x2Clock(
+ mpSnapSel->GetRectangle().x + mpSnapSel->GetRectangle().width + 1));
}
// SN++ Veloc- oder Aftertouch-Editor updaten
if (mpCtrlEdit)
+ {
mpCtrlEdit->UpDate();
+ }
}
//-----------------------------------------------------------------------------
@@ -1905,7 +1919,7 @@
int scroll_clock = (mFromClock + 5 * mToClock) / 6;
if (
- !mpSnapSel->Active &&
+ !mpSnapSel->IsActive() &&
(Clock > scroll_clock || Clock < mFromClock) && Clock >= 0)
{
// Avoid permenent redraws when end of scroll range is reached.
@@ -1920,7 +1934,7 @@
SetXScrollPosition(x);
}
- if (!mpSnapSel->Active) // sets clipping
+ if (!mpSnapSel->IsActive()) // sets clipping
{
if (mPlayClock != Clock)
{
@@ -1947,7 +1961,7 @@
//-----------------------------------------------------------------------------
int JZPianoWindow::EventsSelected(const char *msg)
{
- if (!mpSnapSel->Selected)
+ if (!mpSnapSel->IsSelected())
{
if (msg == 0)
msg = "please select some events first";
@@ -2010,7 +2024,7 @@
{
SnapSelStart(Event);
- if (mpSnapSel->Selected)
+ if (mpSnapSel->IsSelected())
{
// Redraw the whole window instead (inefficient, we should rather
// invalidate a rect).
Modified: trunk/jazz/src/PianoWindow.h
===================================================================
--- trunk/jazz/src/PianoWindow.h 2008-05-04 04:35:13 UTC (rev 482)
+++ trunk/jazz/src/PianoWindow.h 2008-05-04 04:43:51 UTC (rev 483)
@@ -34,7 +34,6 @@
class JZEvent;
class JZFilter;
class tCtrlEditBase;
-class tSnapSelection;
//*****************************************************************************
//*****************************************************************************
Modified: trunk/jazz/src/SampleWindow.cpp
===================================================================
--- trunk/jazz/src/SampleWindow.cpp 2008-05-04 04:35:13 UTC (rev 482)
+++ trunk/jazz/src/SampleWindow.cpp 2008-05-04 04:43:51 UTC (rev 483)
@@ -153,7 +153,7 @@
int paint_offset;
int paint_length;
- tSnapSelection snapsel;
+ JZSnapSelection snapsel;
// sel_fr == 0: no selection and no insertion point
// sel_fr > 0 && sel_fr == sel_to: insertion point
// sel_fr > 0 && sel_fr < sel_to: selected range
@@ -323,48 +323,59 @@
{
mouse_up_sets_insertion_point = 0;
mouse_down = TRUE;
- if (snapsel.Selected)
+ if (snapsel.IsSelected())
{
- snapsel.Draw(*pDc);
- snapsel.Selected = 0;
+ snapsel.Draw(*pDc, 0, 0);
+ snapsel.SetSelected(false);
}
else if (inspt.IsVisible())
+ {
inspt.Draw();
+ }
else
+ {
mouse_up_sets_insertion_point = 1;
+ }
snapsel.Event(e);
}
else if (e.LeftUp())
{
mouse_down = FALSE;
snapsel.Event(e);
- if (snapsel.Selected)
+ if (snapsel.IsSelected())
{
- snapsel.Draw(*pDc);
- sel_fr = Pixel2Sample(snapsel.r.x);
- sel_to = Pixel2Sample(snapsel.r.x + snapsel.r.width);
+ snapsel.Draw(*pDc, 0, 0);
+ sel_fr = Pixel2Sample(
+ snapsel.GetRectangle().x);
+ sel_to = Pixel2Sample(
+ snapsel.GetRectangle().x + snapsel.GetRectangle().width);
}
- else if (mouse_up_sets_insertion_point) {
+ else if (mouse_up_sets_insertion_point)
+ {
int x, y;
e.GetPosition(&x, &y);
sel_fr = sel_to = Pixel2Sample(x);
inspt.Draw(x);
}
else
+ {
sel_fr = sel_to = -1;
+ }
}
else if (e.Dragging() && mouse_down)
+ {
snapsel.Event(e);
+ }
}
void tSampleCnvs::ClearSelection()
{
- if (snapsel.Selected)
+ if (snapsel.IsSelected())
{
wxDC* pDc = new wxClientDC(this);
- snapsel.Draw(*pDc);
- snapsel.Selected = 0;
+ snapsel.Draw(*pDc, 0, 0);
+ snapsel.SetSelected(false);
}
else if (inspt.IsVisible())
{
@@ -395,10 +406,10 @@
GetClientSize(&cw, &ch);
r.SetY(0);
r.SetHeight(ch);
- snapsel.r = r;
- snapsel.Selected = TRUE;
+ snapsel.SetRectangle(r);
+ snapsel.SetSelected(true);
wxDC* pDc = new wxClientDC(this);
- snapsel.Draw(*pDc);
+ snapsel.Draw(*pDc, 0, 0);
}
@@ -452,16 +463,16 @@
DrawTicks(x, y, w);
}
- if (snapsel.Selected)
+ if (snapsel.IsSelected())
{
JZRectangle r;
r.SetX(Sample2Pixel(sel_fr));
r.SetWidth(Sample2Pixel(sel_to) - r.x);
r.SetY(0);
r.SetHeight(ch);
- snapsel.r = r;
+ snapsel.SetRectangle(r);
wxDC* pDc = new wxClientDC(this);
- snapsel.Draw(*pDc);
+ snapsel.Draw(*pDc, 0, 0);
}
else if (sel_fr > 0)
{
Modified: trunk/jazz/src/TrackWindow.cpp
===================================================================
--- trunk/jazz/src/TrackWindow.cpp 2008-05-04 04:35:13 UTC (rev 482)
+++ trunk/jazz/src/TrackWindow.cpp 2008-05-04 04:43:51 UTC (rev 483)
@@ -50,6 +50,8 @@
EVT_LEFT_DOWN(JZTrackWindow::OnLeftButtonDown)
+ EVT_MOTION(JZTrackWindow::OnMouseMove)
+
EVT_LEFT_UP(JZTrackWindow::OnLeftButtonUp)
EVT_RIGHT_UP(JZTrackWindow::OnRightButtonUp)
@@ -166,7 +168,7 @@
int scroll_clock = (mFromClock + 5 * mToClock) / 6;
if (
- !mpSnapSel->Active &&
+ !mpSnapSel->IsActive() &&
(Clock > scroll_clock || Clock < mFromClock) && Clock >= 0)
{
// Avoid permanent redraws when end of scroll range is reached.
@@ -181,7 +183,7 @@
SetXScrollPosition(x);
}
- if (!mpSnapSel->Active) // sets clipping
+ if (!mpSnapSel->IsActive()) // sets clipping
{
if (mPlayClock != Clock)
{
@@ -269,11 +271,24 @@
Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight)
{
SnapSelectionStart(Event);
+ mpSnapSel->ButtonDown(Event);
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+void JZTrackWindow::OnMouseMove(wxMouseEvent& Event)
+{
+ if (Event.LeftIsDown())
+ {
+ mpSnapSel->Dragging(Event);
+// SnapSelectionStop(Event);
+ Refresh(false);
+ }
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZTrackWindow::OnLeftButtonUp(wxMouseEvent& Event)
{
wxPoint Point = Event.GetPosition();
@@ -377,6 +392,8 @@
Point.x >= mEventsX && Point.x < mEventsX + mEventsWidth &&
Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight)
{
+ mpSnapSel->ButtonUp(Event);
+
// The point is in event area.
SnapSelectionStop(Event);
}
@@ -633,9 +650,16 @@
LocalDc.SetPen(*wxBLACK_PEN);
ostringstream Oss;
Oss << BarInfo.GetBarIndex() + 1 - Intro;
- LocalDc.DrawText(Oss.str().c_str(), x + mLittleBit, mEventsY - mTrackHeight);
+ LocalDc.DrawText(
+ Oss.str().c_str(),
+ x + mLittleBit,
+ mEventsY - mTrackHeight);
LocalDc.SetPen(*wxGREY_PEN);
- LocalDc.DrawLine(x, mEventsY + 1 - mTrackHeight, x, mEventsY + mEventsHeight);
+ LocalDc.DrawLine(
+ x,
+ mEventsY + 1 - mTrackHeight,
+ x,
+ mEventsY + mEventsHeight);
}
else
{
@@ -741,7 +765,14 @@
DrawPlayPosition(LocalDc);
// Draw the selection box.
- mpSnapSel->Draw(LocalDc, mEventsX, mEventsY, mEventsWidth, mEventsHeight);
+ mpSnapSel->Draw(
+ LocalDc,
+ mScrolledX,
+ mScrolledY,
+ mEventsX,
+ mEventsY,
+ mEventsWidth,
+ mEventsHeight);
Dc.Blit(
0,
@@ -839,7 +870,10 @@
//-----------------------------------------------------------------------------
void JZTrackWindow::DrawPlayPosition(wxDC& Dc)
{
- if (!mpSnapSel->Active && mPlayClock >= mFromClock && mPlayClock < mToClock)
+ if (
+ !mpSnapSel->IsActive() &&
+ mPlayClock >= mFromClock &&
+ mPlayClock < mToClock)
{
Dc.SetBrush(*wxBLACK_BRUSH);
Dc.SetPen(*wxBLACK_PEN);
@@ -1179,7 +1213,7 @@
//-----------------------------------------------------------------------------
int JZTrackWindow::EventsSelected(const wxString& Message)
{
- if (!mpSnapSel->Selected)
+ if (!mpSnapSel->IsSelected())
{
wxMessageBox(Message, "Error", wxOK);
return 0;
@@ -1227,14 +1261,16 @@
Event.GetPosition(&x, &y);
gpProject->SetPlayPosition(x2BarClock(x));
gpProject->Mute((Event.RightDown() != 0));
- if (mpSnapSel->Selected && (Event.ShiftDown() || Event.MiddleDown()))
+ if (
+ mpSnapSel->IsSelected() &&
+ (Event.ShiftDown() || Event.MiddleDown()))
{
gpProject->SetLoop(true);
}
else
{
gpProject->SetLoop(false);
- mPreviouslyRecording = mpSnapSel->Selected;
+ mPreviouslyRecording = mpSnapSel->IsSelected();
}
break;
@@ -1281,7 +1317,7 @@
bool record = gpProject->mRecord;
// Is it possible to record?
- if (record && mpSnapSel->Selected)
+ if (record && mpSnapSel->IsSelected())
{
pRecInfo->mTrackIndex = mpFilter->FromTrack;
@@ -1315,7 +1351,7 @@
// Is it possible to loop?
int loop_clock = 0;
- if (loop && mpSnapSel->Selected)
+ if (loop && mpSnapSel->IsSelected())
{
mPreviousClock = mpFilter->FromClock;
loop_clock = mpFilter->ToClock;
@@ -1390,14 +1426,15 @@
//-----------------------------------------------------------------------------
void JZTrackWindow::SnapSelectionStop(wxMouseEvent& Event)
{
- if (mpSnapSel->Selected)
+ if (mpSnapSel->IsSelected())
{
- mpFilter->FromTrack = y2TrackIndex(mpSnapSel->r.y);
- mpFilter->ToTrack = y2TrackIndex(
- mpSnapSel->r.y + mpSnapSel->r.GetHeight() - 1);
- mpFilter->FromClock = x2BarClock(mpSnapSel->r.x + 1);
+ mpFilter->FromTrack = y2TrackIndex(mpSnapSel->GetRectangle().y);
+ mpFilter->ToTrack = y2TrackIndex(
+ mpSnapSel->GetRectangle().y +
+ mpSnapSel->GetRectangle().GetHeight() - 1);
+ mpFilter->FromClock = x2BarClock(mpSnapSel->GetRectangle().x + 1);
mpFilter->ToClock = x2BarClock(
- mpSnapSel->r.x + mpSnapSel->r.GetWidth() + 1);
+ mpSnapSel->GetRectangle().x + mpSnapSel->GetRectangle().GetWidth() + 1);
// NextWin->NewPosition(mpFilter->FromTrack, mpFilter->FromClock);
}
}
Modified: trunk/jazz/src/TrackWindow.h
===================================================================
--- trunk/jazz/src/TrackWindow.h 2008-05-04 04:35:13 UTC (rev 482)
+++ trunk/jazz/src/TrackWindow.h 2008-05-04 04:43:51 UTC (rev 483)
@@ -30,7 +30,6 @@
class JZSong;
class JZTrack;
class JZFilter;
-class tSnapSelection;
class wxFont;
enum TECounterModes
@@ -94,6 +93,8 @@
void OnLeftButtonDown(wxMouseEvent& Event);
+ void OnMouseMove(wxMouseEvent& Event);
+
void OnLeftButtonUp(wxMouseEvent& Event);
void OnRightButtonUp(wxMouseEvent& Event);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|