From: <pst...@us...> - 2009-05-17 17:52:03
|
Revision: 722 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=722&view=rev Author: pstieber Date: 2009-05-17 17:51:49 +0000 (Sun, 17 May 2009) Log Message: ----------- 1. Changed tMouseAction to JZMouseAction, added window scrolling information to all of the virtual functions in this class, moved ProcessMouseEvent from the header to the source file, and implemented in-line functions outside of the class declaration. 2. Made SnapSelectionStart and SnapSelectionStop pure virtual in the JZEventWindow base class. 3. Removed extra header sentry check for wx/timer.h in MouseAction.h and reordered the includes. 4. Updated some function comment headers. 5. Changed tMouseMapper to JZMouseMapper, removed an unused default constructor, renamed the Button enumeration to TEButton, changed Action to GetAction, and prefixed enumeration entries with an e. 6. Removed unneeded JZSelection::Select(JZRectangle&, int, int, int, int), and changed JZSelection::Select(JZRectangle&) to JZSelection::Select(const JZRectangle&). 7. Added window scrolling information to JZSnapSelection::Snap. 8. Used a preprocessor to remove the unused tMouseButton class. 9. Updated some variable names to match the new style convention. 10. Translated a comment in the song module and fixed a typo in a comment in the track frame header. 11. Commented unused JZTrackWindow::Mark, fixed selection bugs in the track window when the window was scrolled, removed the line (y = y2yLine(y)) that forced discrete instead of smooth scrolling of the track text, and commented out unused JZTrackWindow::x2xBar and JZTrackWindow::x2wBar. x2xBar and x2wBar need to take into account scrolling if they are reinstated. 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/Song.cpp 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.cpp =================================================================== --- trunk/jazz/src/EventWindow.cpp 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/EventWindow.cpp 2009-05-17 17:51:49 UTC (rev 722) @@ -552,18 +552,6 @@ } //----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -void JZEventWindow::SnapSelectionStart(wxMouseEvent& MouseEvent) -{ -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -void JZEventWindow::SnapSelectionStop(wxMouseEvent& MouseEvent) -{ -} - -//----------------------------------------------------------------------------- // Descriptions: // This mouse handler delegates to the subclassed event window. //----------------------------------------------------------------------------- @@ -588,7 +576,7 @@ // invalidate a rect). Refresh(); // } - mpSnapSel->ProcessMouseEvent(MouseEvent); + mpSnapSel->ProcessMouseEvent(MouseEvent, mScrolledX, mScrolledY); mpMouseAction = mpSnapSel; } } @@ -598,7 +586,7 @@ { // mpMouseAction active - if (mpMouseAction->ProcessMouseEvent(MouseEvent)) + if (mpMouseAction->ProcessMouseEvent(MouseEvent, mScrolledX, mScrolledY)) { // mpMouseAction finished Modified: trunk/jazz/src/EventWindow.h =================================================================== --- trunk/jazz/src/EventWindow.h 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/EventWindow.h 2009-05-17 17:51:49 UTC (rev 722) @@ -26,7 +26,7 @@ #include <wx/window.h> class JZFilter; -class tMouseAction; +class JZMouseAction; class JZSnapSelection; class JZSong; class wxDialog; @@ -102,9 +102,9 @@ int SnapClock(int Clock, bool Up); - virtual void SnapSelectionStart(wxMouseEvent& MouseEvent); + virtual void SnapSelectionStart(wxMouseEvent& MouseEvent) = 0; - virtual void SnapSelectionStop(wxMouseEvent& MouseEvent); + virtual void SnapSelectionStop(wxMouseEvent& MouseEvent) = 0; void DrawVerticalLine(wxDC& Dc, int XPosition) const; @@ -126,7 +126,7 @@ JZFilter* mpFilter; - tMouseAction* mpMouseAction; + JZMouseAction* mpMouseAction; protected: Modified: trunk/jazz/src/MouseAction.cpp =================================================================== --- trunk/jazz/src/MouseAction.cpp 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/MouseAction.cpp 2009-05-17 17:51:49 UTC (rev 722) @@ -24,52 +24,64 @@ #include "EventWindow.h" +#include <wx/brush.h> #include <wx/dcclient.h> -#include <wx/brush.h> +//DEBUG#include <iostream> + using namespace std; -// ----------------------------------------------------------------- -// tMouseMapper - map mouse button to Command-ID -// ----------------------------------------------------------------- - -tMouseMapper::tMouseMapper(const int a[12]) +//***************************************************************************** +// Description: +// This is the mouse mapper class declaration. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZMouseMapper::JZMouseMapper(const int Actions[12]) + : mActions(), + mLeftAction(0) { for (int i = 0; i < 12; i++) - actions[i] = a[i]; - left_action = 0; + { + mActions[i] = Actions[i]; + } } -tMouseMapper::tMouseMapper() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZMouseMapper::SetAction( + int Action, + TEButton Button, + bool Shift, + bool Ctrl) { - for (int i = 0; i < 12; i++) - actions[i] = 0; - left_action = 0; -} - -void tMouseMapper::SetAction(int code, Button but, bool shift, bool ctrl) -{ int i = 0; - switch (but) + switch (Button) { - case Left: + case eLeft: i = 0; break; - case Middle: + case eMiddle: i = 1; break; - case Right: + case eRight: i = 2; break; } - if (shift) + if (Shift) + { i += 3; - if (ctrl) + } + if (Ctrl) + { i += 6; - actions[i] = code; + } + mActions[i] = Action; } -int tMouseMapper::Action(wxMouseEvent& MouseEvent) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZMouseMapper::GetAction(wxMouseEvent& MouseEvent) { if (!MouseEvent.ButtonDown()) { @@ -77,15 +89,16 @@ } if ( - left_action > 0 && + mLeftAction > 0 && MouseEvent.LeftDown() && !MouseEvent.ShiftDown() && !MouseEvent.ControlDown()) { - return left_action; + return mLeftAction; } - int i = 0; // left down + // Assume the left button is down. + int i = 0; if (MouseEvent.MiddleDown()) { i = 1; @@ -99,15 +112,70 @@ { i += 3; } + if (MouseEvent.ControlDown()) { i += 6; } - return actions[i]; + + return mActions[i]; } //***************************************************************************** // Description: +// This is the mouse action base class definition. Derived classes are +// instantiated in the mouse handler of the event window, for example, to +// retain state during mouse operations, like drag and drop and so on. +// The ProcessMouseEvent() function is used to determine what to do with an +// incoming event. Normally, if the event is a left button down event, call +// the LeftDown function of the class, and so on. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZMouseAction::~JZMouseAction() +{ +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZMouseAction::ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) +{ + if (MouseEvent.Dragging()) + { + return Dragging(MouseEvent, ScrolledX, ScrolledY); + } + else if (MouseEvent.LeftDown()) + { + return LeftDown(MouseEvent, ScrolledX, ScrolledY); + } + else if (MouseEvent.LeftUp()) + { + return LeftUp(MouseEvent, ScrolledX, ScrolledY); + } + else if (MouseEvent.MiddleDown()) + { + return MiddleDown(MouseEvent, ScrolledX, ScrolledY); + } + else if (MouseEvent.MiddleUp()) + { + return MiddleUp(MouseEvent, ScrolledX, ScrolledY); + } + else if (MouseEvent.RightDown()) + { + return RightDown(MouseEvent, ScrolledX, ScrolledY); + } + else if (MouseEvent.RightUp()) + { + return RightUp(MouseEvent, ScrolledX, ScrolledY); + } + return 0; +} + +//***************************************************************************** +// Description: // This is the selection class definition. //***************************************************************************** //----------------------------------------------------------------------------- @@ -132,26 +200,32 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZSelection::ProcessMouseEvent(wxMouseEvent& MouseEvent) +int JZSelection::ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { if (MouseEvent.ButtonDown()) { - return ButtonDown(MouseEvent); + return ButtonDown(MouseEvent, ScrolledX, ScrolledY); } else if (MouseEvent.ButtonUp()) { - return ButtonUp(MouseEvent); + return ButtonUp(MouseEvent, ScrolledX, ScrolledY); } else if (MouseEvent.Dragging()) { - return Dragging(MouseEvent); + return Dragging(MouseEvent, ScrolledX, ScrolledY); } return 0; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZSelection::ButtonDown(wxMouseEvent& MouseEvent) +int JZSelection::ButtonDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { if (!mActive) { @@ -161,14 +235,14 @@ // Continue selection JZRectangle Rectangle = mRectangle; Rectangle.SetNormal(); - Dragging(MouseEvent); + Dragging(MouseEvent, ScrolledX, ScrolledY); } else { mSelected = false; - int x = MouseEvent.GetX(); - int y = MouseEvent.GetY(); - Snap(x, y, 0); + int x = MouseEvent.GetX() + ScrolledX; + int y = MouseEvent.GetY() + ScrolledY; + Snap(x, y, ScrolledX, ScrolledY, false); mRectangle.x = x; mRectangle.y = y; mRectangle.width = 1; @@ -180,17 +254,41 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZSelection::Dragging(wxMouseEvent& MouseEvent) +int JZSelection::ButtonUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { + if (mActive) + { + mActive = false; + mRectangle.SetNormal(); + + // Only select if the rectangle is larger than 3x3 pixels. + mSelected = (mRectangle.width > 3 && mRectangle.height > 3); + return 1; + } + + mpWindow->Refresh(); + return 0; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZSelection::Dragging( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) +{ if (!mActive) { - ButtonDown(MouseEvent); + ButtonDown(MouseEvent, ScrolledX, ScrolledY); } if (mActive) { - int x = MouseEvent.GetX(); - int y = MouseEvent.GetY(); + int x = MouseEvent.GetX() + ScrolledX; + int y = MouseEvent.GetY() + ScrolledY; if (x < 0) { x = 0; @@ -199,7 +297,7 @@ { y = 0; } - Snap(x, y, 1); + Snap(x, y, ScrolledX, ScrolledY, true); mRectangle.width = x - mRectangle.x; mRectangle.height = y - mRectangle.y; @@ -209,27 +307,8 @@ } //----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -int JZSelection::ButtonUp(wxMouseEvent& MouseEvent) -{ - if (mActive) - { - mActive = false; - mRectangle.SetNormal(); - - // Only select if the rectangle is larger than 3x3 pixels. - mSelected = (mRectangle.width > 3 && mRectangle.height > 3); - return 1; - } - - mpWindow->Refresh(); - return 0; -} - -//----------------------------------------------------------------------------- // Description: -// Draw the selected rectangle, normally called from OnDraw -// in the parent window. +// Draw the selected rectangle. //----------------------------------------------------------------------------- void JZSelection::Draw(wxDC& Dc, int ScrolledX, int ScrolledY) { @@ -279,26 +358,15 @@ // It did this by drawing directly in the device context. This is bad, so I // tried changing it to invalidation instead. //----------------------------------------------------------------------------- -void JZSelection::Select(JZRectangle& Rectangle, int x, int y, int w, int h) +void JZSelection::Select(const JZRectangle& Rectangle) { - // clear old rectangle - // Draw(x, y, w, h); - // make new one mRectangle = Rectangle; mSelected = true; - // Draw(x, y, w, h); // Inefficient because should invalidate only the rectangle. mpWindow->Refresh(); } -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -void JZSelection::Select(JZRectangle& Rectangle) -{ - Select(Rectangle, 0, 0, 3000, 3000); -} - //***************************************************************************** // Description: // This is the snap selection class definition. @@ -320,47 +388,52 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZSnapSelection::Snap(int& x, int& y, bool drag) +void JZSnapSelection::Snap( + int& x, + int& y, + int ScrolledX, + int ScrolledY, + bool Up) { if (!mXCoordinates.empty()) { - SnapToVector(x, mXCoordinates, drag); + SnapToVector(x, mXCoordinates, ScrolledX, Up); } else if (mXStep) { - SnapMod(x, mXMin, mXMax, mXStep, drag); + SnapMod(x, mXMin, mXMax, mXStep, ScrolledX, Up); } if (!mYCoordinates.empty()) { - SnapToVector(y, mYCoordinates, drag); + SnapToVector(y, mYCoordinates, ScrolledY, Up); } else if (mYStep) { - SnapMod(y, mYMin, mYMax, mYStep, drag); + SnapMod(y, mYMin, mYMax, mYStep, ScrolledY, Up); } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZSnapSelection::SetXSnap(int XCount, int* pXVector) +void JZSnapSelection::SetXSnap(int XCount, int* pXVector, int ScrolledX) { mXCoordinates.clear(); for (int i = 0; i < XCount; ++i) { - mXCoordinates.push_back(pXVector[i]); + mXCoordinates.push_back(pXVector[i] + ScrolledX); } mXStep = 0; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZSnapSelection::SetYSnap(int YCount, int* pYVector) +void JZSnapSelection::SetYSnap(int YCount, int* pYVector, int ScrolledY) { mYCoordinates.clear(); for (int i = 0; i < YCount; ++i) { - mXCoordinates.push_back(pYVector[i]); + mXCoordinates.push_back(pYVector[i] + ScrolledY); } mYStep = 0; } @@ -390,8 +463,10 @@ void JZSnapSelection::SnapToVector( int& Coordinate, vector<int> Vector, + int Scrolled, bool Up) { +//DEBUG cout << "In: " << Coordinate; for (unsigned i = 0; i < Vector.size(); ++i) { if (Vector[i] > Coordinate) @@ -404,9 +479,11 @@ { Coordinate = Vector[i - 1]; } +//DEBUG cout << " Out: " << Coordinate << endl; return; } } +//DEBUG cout << " Out: " << Coordinate << endl; Coordinate = Vector[Vector.size() - 1]; } @@ -417,8 +494,10 @@ int Min, int Max, int Step, + int Scrolled, bool Up) { +//DEBUG cout << "In: " << Coordinate; if (Coordinate <= Min) { Coordinate = Min; @@ -427,13 +506,15 @@ if (Coordinate >= Max) { Coordinate = Max; +//DEBUG cout << "Max: " << Coordinate << endl; return; } - Coordinate -= (Coordinate - Min) % Step; + Coordinate -= (Coordinate - Min) % Step - (Scrolled % Step); if (Up) { Coordinate += Step; } +//DEBUG cout << " Out: " << Coordinate << endl; } @@ -461,7 +542,10 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tMouseCounter::LeftDown(wxMouseEvent& MouseEvent) +int tMouseCounter::LeftDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { Delta = MouseEvent.ShiftDown() ? 10 : 1; Start(Timeout); @@ -478,7 +562,10 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tMouseCounter::LeftUp(wxMouseEvent& MouseEvent) +int tMouseCounter::LeftUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { Stop(); ShowValue(FALSE); @@ -487,7 +574,10 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tMouseCounter::RightDown(wxMouseEvent& MouseEvent) +int tMouseCounter::RightDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { Delta = MouseEvent.ShiftDown() ? -10 : -1; Start(Timeout); @@ -505,7 +595,10 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tMouseCounter::RightUp(wxMouseEvent& MouseEvent) +int tMouseCounter::RightUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { Stop(); ShowValue(FALSE); @@ -558,7 +651,10 @@ //Frame->SetStatusText("Click Destination point"); } -int tMarkDestin::ButtonDown(wxMouseEvent& MouseEvent) +int tMarkDestin::ButtonDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { wxCursor c = wxCursor(wxCURSOR_ARROW); Canvas->SetCursor(c); @@ -571,28 +667,38 @@ x=point.x; y=point.y; - // cout<<"tMarkDestin::ButtonDown "<<x<<" "<<y<<endl; +//DEBUG cout << "tMarkDestin::ButtonDown " << x << ' ' << y <<endl; return 1; } -int tMarkDestin::RightDown(wxMouseEvent& MouseEvent) +int tMarkDestin::RightDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { - ButtonDown(MouseEvent); + ButtonDown(MouseEvent, ScrolledX, ScrolledY); Aborted = 1; //Frame->SetStatusText("Operation aborted"); return 1; } -int tMarkDestin::LeftDown(wxMouseEvent& MouseEvent) +int tMarkDestin::LeftDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { - ButtonDown(MouseEvent); + ButtonDown(MouseEvent, ScrolledX, ScrolledY); Aborted = 0; //Frame->SetStatusText(""); return 1; } +#if 0 + //***************************************************************************** -// tMouseButton - simulate a 3D button +// Description: +// This is the mouse button class definition. This class simulates a 3D +// button. //***************************************************************************** //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -640,7 +746,10 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tMouseButton::ProcessMouseEvent(wxMouseEvent& MouseEvent) +int tMouseButton::ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { if (MouseEvent.ButtonUp()) { @@ -663,3 +772,5 @@ } return 0; } + +#endif Modified: trunk/jazz/src/MouseAction.h =================================================================== --- trunk/jazz/src/MouseAction.h 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/MouseAction.h 2009-05-17 17:51:49 UTC (rev 722) @@ -23,16 +23,16 @@ #ifndef JZ_MOUSEACTION_H #define JZ_MOUSEACTION_H -#ifndef wx_timerh -#include <wx/timer.h> -#endif - #include "Rectangle.h" #include <vector> +#include <wx/timer.h> + class JZEventWindow; +//***************************************************************************** +//***************************************************************************** enum TEMousePlayMode { eMouse, @@ -43,110 +43,115 @@ }; //***************************************************************************** +// Description: +// This is the mouse mapper class declaration. This class maps the state of +// the mouse and certain keyboard keys into user defined integer codes. There +// are 12 possible mouse button / keyboard key combinations. They are: +// +// 0, 1, 2 = left, middle, right down +// 3, 4, 5 = left, middle, right down + shift +// 6, 7, 8 = left, middle, right down + ctrl +// 9, 10, 11 = left, middle, right down + ctrl + shift +// +// Note that combinations or mouse buttons are not considered. +// The function GetAction converts a wxWidgets mouse event into a user +// defined code. The default code for all mouse actions is 0. //***************************************************************************** -class tMouseMapper +class JZMouseMapper { public: - // actions - // 0..2 = left/middle/right down - // 3..5 = left/middle/right down + shift - // 6..8 = left/middle/right down + ctrl - // 9..11 = left/middle/right down + ctrl + shift + JZMouseMapper(const int Actions[12]); - tMouseMapper(const int actions[12]); - - tMouseMapper(); - - enum Button + enum TEButton { - Left, - Middle, - Right + eLeft, + eMiddle, + eRight }; + int GetAction(wxMouseEvent& MouseEvent); + void SetAction( - int code, - Button but = Left, - bool shift = false, - bool ctrl = false); + int Action, + TEButton Button = eLeft, + bool Shift = false, + bool Ctrl = false); - int Action(wxMouseEvent& MouseEvent); - - void SetLeftAction(int id = 0) + void SetLeftAction(int Action = 0) { - left_action = id; + mLeftAction = Action; } private: - int actions[12]; + int mActions[12]; - int left_action; + int mLeftAction; }; //***************************************************************************** // Description: -// This is a base class for mouse actions. The classes are instantiated in -// the mouse handler of the event window, for example, to keep state during -// mouse operations, like drag and drop and so on. +// This is the mouse action base class declaration. Derived classes are +// instantiated in the mouse handler of the event window, for example, to +// retain state during mouse operations, like drag and drop and so on. // The ProcessMouseEvent() function is used to determine what to do with an -// incoming event. Normally, if the event is a drag event, call the drag -// function of the class, and so on. +// incoming event. Normally, if the event is a left button down event, call +// the LeftDown function of the class, and so on. //***************************************************************************** -class tMouseAction +class JZMouseAction { public: - virtual ~tMouseAction() {} - virtual int Dragging(wxMouseEvent& MouseEvent) { return 0; } - virtual int LeftDown(wxMouseEvent& MouseEvent) { return 0; } - virtual int LeftUp(wxMouseEvent& MouseEvent) { return 0; } - virtual int RightDown(wxMouseEvent& MouseEvent) { return 0; } - virtual int RightUp(wxMouseEvent& MouseEvent) { return 0; } - virtual int MiddleDown(wxMouseEvent& MouseEvent) { return 0; } - virtual int MiddleUp(wxMouseEvent& MouseEvent) { return 0; } - virtual int ProcessMouseEvent(wxMouseEvent& MouseEvent) - { - if (MouseEvent.Dragging()) - { - return Dragging(MouseEvent); - } - else if (MouseEvent.LeftDown()) - { - return LeftDown(MouseEvent); - } - else if (MouseEvent.LeftUp()) - { - return LeftUp(MouseEvent); - } - else if (MouseEvent.MiddleDown()) - { - return MiddleDown(MouseEvent); - } - else if (MouseEvent.MiddleUp()) - { - return MiddleUp(MouseEvent); - } - else if (MouseEvent.RightDown()) - { - return RightDown(MouseEvent); - } - else if (MouseEvent.RightUp()) - { - return RightUp(MouseEvent); - } - return 0; - } + virtual ~JZMouseAction(); + + virtual int LeftDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int LeftUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int RightDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int RightUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int MiddleDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int MiddleUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int Dragging( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); }; - //***************************************************************************** // Description: // This is the selection class declaration. This class selects events using // the mouse and draws indicating the selected events. //***************************************************************************** -class JZSelection : public tMouseAction +class JZSelection : public JZMouseAction { public: @@ -179,17 +184,34 @@ mRectangle = Rectangle; } - virtual void Snap(int& x, int& y, bool drag) + virtual void Snap( + int& x, + int& y, + int ScrolledX, + int ScrolledY, + bool Up) { } - virtual int Dragging(wxMouseEvent& MouseEvent); + virtual int Dragging( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); - virtual int ProcessMouseEvent(wxMouseEvent& MouseEvent); + virtual int ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); - virtual int ButtonDown(wxMouseEvent& MouseEvent); + virtual int ButtonDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); - virtual int ButtonUp(wxMouseEvent& MouseEvent); + virtual int ButtonUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); virtual void Draw(wxDC& Dc, int ScrolledX, int ScrolledY); @@ -203,17 +225,15 @@ int ClipWidth, int ClipHeight); - // May not be called while dragging. - void Select(JZRectangle& rr, int x, int y, int w, int h); + void Select(const JZRectangle& Rectangle); - void Select(JZRectangle& Rectangle); - private: bool mActive; // The following indicates if the rectangle is valid. bool mSelected; + JZRectangle mRectangle; wxWindow* mpWindow; @@ -231,11 +251,16 @@ JZSnapSelection(wxWindow* pWindow); - virtual void Snap(int& x, int& y, bool Up); + virtual void Snap( + int& x, + int& y, + int ScrolledX, + int ScrolledY, + bool Up); - void SetXSnap(int XCount, int* pXVector); + void SetXSnap(int XCount, int* pXVector, int ScrolledX); - void SetYSnap(int YCount, int* pYVector); + void SetYSnap(int YCount, int* pYVector, int ScrolledY); void SetXSnap(int XMin, int XMax, int XStep); @@ -246,6 +271,7 @@ static void SnapToVector( int& Coordinate, std::vector<int> Vector, + int Scrolled, bool Up); static void SnapMod( @@ -253,6 +279,7 @@ int Min, int Max, int Step, + int Scrolled, bool Up); protected: @@ -291,7 +318,7 @@ //***************************************************************************** // MouseCounter - let you enter numbers with left/right mouse button //***************************************************************************** -class tMouseCounter : public wxTimer, public tMouseAction +class tMouseCounter : public wxTimer, public JZMouseAction { public: @@ -314,11 +341,28 @@ int Wait; // don't inc/dec at Init tButtonLabelInterface *win; - virtual int LeftDown(wxMouseEvent& MouseEvent); - virtual int LeftUp(wxMouseEvent& MouseEvent); - virtual int RightDown(wxMouseEvent& MouseEvent); - virtual int RightUp(wxMouseEvent& MouseEvent); + virtual int LeftDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int LeftUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int RightDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int RightUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + virtual void Notify(); + virtual void ShowValue(bool down); }; @@ -326,26 +370,44 @@ //***************************************************************************** // tMarkDestin - mark destination of some operation //***************************************************************************** -class tMarkDestin : public tMouseAction +class tMarkDestin : public JZMouseAction { public: + int Aborted; float x, y; - virtual int LeftDown(wxMouseEvent& MouseEvent); - virtual int RightDown(wxMouseEvent& MouseEvent); + virtual int LeftDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + + virtual int RightDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); + tMarkDestin(wxWindow* canvas, wxFrame* frame, int left); private: + wxWindow *Canvas; wxFrame *Frame; - int ButtonDown(wxMouseEvent& MouseEvent); + + int ButtonDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); }; +#if 0 + //***************************************************************************** -// tMouseButton - simulate a 3D button +// Description: +// This is the mouse button class declaration. This class simulates a 3D +// button. //***************************************************************************** -class tMouseButton : public tMouseAction +class tMouseButton : public JZMouseAction { public: @@ -353,11 +415,14 @@ JZEventWindow* pEventWindow, JZRectangle* pRectangle, const char* pDownString, - const char* upUpString = 0); + const char* pUpString = 0); virtual ~tMouseButton(); - virtual int ProcessMouseEvent(wxMouseEvent& MouseEvent); + virtual int ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); protected: @@ -376,4 +441,87 @@ wxString mUpString; }; +#endif + +//***************************************************************************** +// Description: +// These are the mouse action class inline member functions. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +int JZMouseAction::LeftDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) +{ + return 0; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +int JZMouseAction::LeftUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) +{ + return 0; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +int JZMouseAction::RightDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) +{ + return 0; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +int JZMouseAction::RightUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) +{ + return 0; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +int JZMouseAction::MiddleDown( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) +{ + return 0; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +int JZMouseAction::MiddleUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) +{ + return 0; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +int JZMouseAction::Dragging( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) +{ + return 0; +} + #endif // !defined(JZ_MOUSEACTION_H) Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/PianoWindow.cpp 2009-05-17 17:51:49 UTC (rev 722) @@ -95,13 +95,18 @@ // Description: // JZMousePlay - Click in pianoroll //***************************************************************************** -class JZMousePlay : public tMouseAction +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +class JZMousePlay : public JZMouseAction { public: JZMousePlay(JZPianoWindow* pPianoWindow); - virtual int ProcessMouseEvent(wxMouseEvent& MouseEvent); + virtual int ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); private: @@ -123,7 +128,10 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZMousePlay::ProcessMouseEvent(wxMouseEvent& MouseEvent) +int JZMousePlay::ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { int x, y; MouseEvent.GetPosition(&x, &y); @@ -193,17 +201,26 @@ // Description: // tKeyLengthDragger //***************************************************************************** -class tKeyLengthDragger : public tMouseAction +class tKeyLengthDragger : public JZMouseAction { public: tKeyLengthDragger(tKeyOn* pKeyOn, JZPianoWindow* pPianoWindow); - int Dragging(wxMouseEvent& MouseEvent); + int Dragging( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); - int ButtonUp(wxMouseEvent& MouseEvent); + int ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); - int ProcessMouseEvent(wxMouseEvent& MouseEvent); + int ButtonUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); private: @@ -237,22 +254,28 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tKeyLengthDragger::ProcessMouseEvent(wxMouseEvent& MouseEvent) +int tKeyLengthDragger::ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { if (MouseEvent.Dragging()) { - return Dragging(MouseEvent); + return Dragging(MouseEvent, ScrolledX, ScrolledY); } else if (MouseEvent.ButtonUp()) { - return ButtonUp(MouseEvent); + return ButtonUp(MouseEvent, ScrolledX, ScrolledY); } return 0; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tKeyLengthDragger::Dragging(wxMouseEvent& MouseEvent) +int tKeyLengthDragger::Dragging( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { wxClientDC Dc(Win); Win->PrepareDC(Dc); //to translate scrolled coordinates @@ -273,7 +296,10 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tKeyLengthDragger::ButtonUp(wxMouseEvent& MouseEvent) +int tKeyLengthDragger::ButtonUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { // SN++ Key_Aftertouch if (Copy->GetEventLength() < mpKeyOn->GetEventLength()) @@ -325,17 +351,26 @@ // tPlayTrackLengthDragger JAVE this is just copied from tKeyLengthDragger, // the need to be inherited somehow //***************************************************************************** -class tPlayTrackLengthDragger : public tMouseAction +class tPlayTrackLengthDragger : public JZMouseAction { public: tPlayTrackLengthDragger(tPlayTrack* k, JZPianoWindow* pPianoWindow); - int Dragging(wxMouseEvent& MouseEvent); + int Dragging( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); - int ButtonUp(wxMouseEvent& MouseEvent); + int ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); - int ProcessMouseEvent(wxMouseEvent& MouseEvent); + int ButtonUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); private: tPlayTrack* mpKeyOn; @@ -365,22 +400,28 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tPlayTrackLengthDragger::ProcessMouseEvent(wxMouseEvent& MouseEvent) +int tPlayTrackLengthDragger::ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { if (MouseEvent.Dragging()) { - return Dragging(MouseEvent); + return Dragging(MouseEvent, ScrolledX, ScrolledY); } else if (MouseEvent.ButtonUp()) { - return ButtonUp(MouseEvent); + return ButtonUp(MouseEvent, ScrolledX, ScrolledY); } return 0; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tPlayTrackLengthDragger::Dragging(wxMouseEvent& MouseEvent) +int tPlayTrackLengthDragger::Dragging( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { wxClientDC Dc(Win); Win->PrepareDC(Dc); @@ -399,7 +440,10 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tPlayTrackLengthDragger::ButtonUp(wxMouseEvent& MouseEvent) +int tPlayTrackLengthDragger::ButtonUp( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { wxClientDC Dc(Win); Win->PrepareDC(Dc); @@ -441,7 +485,10 @@ Dc.SetFont(*(Win->GetFixedFont())); } - virtual int ProcessMouseEvent(wxMouseEvent& MouseEvent); + virtual int ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY); private: @@ -452,9 +499,12 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tVelocCounter::ProcessMouseEvent(wxMouseEvent& MouseEvent) +int tVelocCounter::ProcessMouseEvent( + wxMouseEvent& MouseEvent, + int ScrolledX, + int ScrolledY) { - if (tMouseCounter::ProcessMouseEvent(MouseEvent)) + if (tMouseCounter::ProcessMouseEvent(MouseEvent, ScrolledX, ScrolledY)) { tKeyOn* pKeyOnCopy = (tKeyOn *)mpKeyOn->Copy(); pKeyOnCopy->SetVelocity(Value); @@ -538,24 +588,26 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const int play_actions[12] = +static const int PlayAreaActions[12] = { + // Depressed mouse button: // left middle right MA_PLAY, MA_CYCLE, 0, // plain MA_CYCLE, 0, 0, // shift 0, 0, 0, // ctrl - 0, 0, 0 // shift+ctrl + 0, 0, 0 // shift + ctrl }; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const int evnt_actions[12] = +static const int EventAreaActions[12] = { + // Depressed mouse button: // left middle right MA_SELECT, MA_CUTPASTE, MA_LENGTH, // plain MA_CONTSEL, MA_COPY, MA_LISTEN, // shift MA_VELOCITY, MA_DIALOG, MA_VELOCITY, // ctrl - MA_CUTPASTE, 0, MA_COPY // shift+ctrl + MA_CUTPASTE, 0, MA_COPY // shift + ctrl }; @@ -598,8 +650,8 @@ mpTrack(0), mTrackIndex(0), mpCtrlEdit(0), - mMousePlay(play_actions), - mMouseEvent(evnt_actions), + mMousePlay(PlayAreaActions), + mMouseEvent(EventAreaActions), mUseColors(true), mMouseLine(-1), mFontSize(12), @@ -1653,7 +1705,7 @@ else if (x > mEventsX) { // click in top line - int action = mMousePlay.Action(MouseEvent); + int action = mMousePlay.GetAction(MouseEvent); if (action) { @@ -1897,11 +1949,11 @@ } if (mSnapCount < eMaxSnaps) { - mpSnapSel->SetXSnap(mSnapCount, mSnapsX); + mpSnapSel->SetXSnap(mSnapCount, mSnapsX, 0); } else { - mpSnapSel->SetXSnap(0,0,0); + mpSnapSel->SetXSnap(0, 0, 0); } mpSnapSel->SetYSnap( mFromLine * mTrackHeight + mTopInfoHeight, @@ -2028,7 +2080,7 @@ // invalidate a rect). Refresh(); // } - mpSnapSel->ProcessMouseEvent(MouseEvent); + mpSnapSel->ProcessMouseEvent(MouseEvent, mScrolledX, mScrolledY); mpMouseAction = mpSnapSel; } } @@ -2038,7 +2090,7 @@ { // mpMouseAction active - if (mpMouseAction->ProcessMouseEvent(MouseEvent)) + if (mpMouseAction->ProcessMouseEvent(MouseEvent, mScrolledX, mScrolledY)) { // mpMouseAction finished @@ -2137,7 +2189,7 @@ //----------------------------------------------------------------------------- void JZPianoWindow::MouseEvents(wxMouseEvent& MouseEvent) { - int action = mMouseEvent.Action(MouseEvent); + int action = mMouseEvent.GetAction(MouseEvent); if (action) { @@ -2220,7 +2272,7 @@ r.SetHeight(mTopInfoHeight); tVelocCounter *VelocCounter = new tVelocCounter(this, &r, pKeyOn); - VelocCounter->ProcessMouseEvent(MouseEvent); + VelocCounter->ProcessMouseEvent(MouseEvent, mScrolledX, mScrolledY); mpMouseAction = VelocCounter; } break; @@ -2236,7 +2288,8 @@ if (MouseEvent.ButtonDown()) { mpMouseAction = new JZMousePlay(this); - int Status = mpMouseAction->ProcessMouseEvent(MouseEvent); + int Status = + mpMouseAction->ProcessMouseEvent(MouseEvent, mScrolledX, mScrolledY); if (Status == 1) { delete mpMouseAction; Modified: trunk/jazz/src/PianoWindow.h =================================================================== --- trunk/jazz/src/PianoWindow.h 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/PianoWindow.h 2009-05-17 17:51:49 UTC (rev 722) @@ -305,8 +305,8 @@ tCtrlEditBase* mpCtrlEdit; - tMouseMapper mMousePlay; - tMouseMapper mMouseEvent; + JZMouseMapper mMousePlay; + JZMouseMapper mMouseEvent; // Number of colors to use for velocity representation. enum Modified: trunk/jazz/src/SampleWindow.cpp =================================================================== --- trunk/jazz/src/SampleWindow.cpp 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/SampleWindow.cpp 2009-05-17 17:51:49 UTC (rev 722) @@ -42,7 +42,7 @@ #include <wx/msgdlg.h> #include <wx/scrolbar.h> -#include <iostream> +//DEBUG#include <iostream> #define MEN_LOAD 1 #define MEN_SAVE 2 @@ -158,6 +158,7 @@ int paint_length; 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 @@ -303,7 +304,7 @@ { int cw, ch; GetClientSize(&cw, &ch); - //snapsel.SetYSnap(0, ch, ch / spl.GetChannels()); +// snapsel.SetYSnap(0, ch, ch / spl.GetChannels()); snapsel.SetYSnap(0, ch, ch); AdjustScrollbars(); @@ -340,12 +341,12 @@ { mouse_up_sets_insertion_point = 1; } - snapsel.ProcessMouseEvent(MouseEvent); + snapsel.ProcessMouseEvent(MouseEvent, 0, 0); } else if (MouseEvent.LeftUp()) { mouse_down = FALSE; - snapsel.ProcessMouseEvent(MouseEvent); + snapsel.ProcessMouseEvent(MouseEvent, 0, 0); if (snapsel.IsSelected()) { snapsel.Draw(*pDc, 0, 0); @@ -368,7 +369,7 @@ } else if (MouseEvent.Dragging() && mouse_down) { - snapsel.ProcessMouseEvent(MouseEvent); + snapsel.ProcessMouseEvent(MouseEvent, 0, 0); } } Modified: trunk/jazz/src/Song.cpp =================================================================== --- trunk/jazz/src/Song.cpp 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/Song.cpp 2009-05-17 17:51:49 UTC (rev 722) @@ -109,7 +109,7 @@ return; } - // Clock + Bar auf Anfang naechster Takt + // Clock + Bar at the beginning of the next cycle. mClock += mTicksPerBar; ++mBarIndex; } Modified: trunk/jazz/src/TrackFrame.cpp =================================================================== --- trunk/jazz/src/TrackFrame.cpp 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/TrackFrame.cpp 2009-05-17 17:51:49 UTC (rev 722) @@ -65,7 +65,7 @@ #include <wx/menu.h> #include <wx/msgdlg.h> -#include <iostream> +//DEBUG#include <iostream> using namespace std; Modified: trunk/jazz/src/TrackFrame.h =================================================================== --- trunk/jazz/src/TrackFrame.h 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/TrackFrame.h 2009-05-17 17:51:49 UTC (rev 722) @@ -55,7 +55,7 @@ void NewPlayPosition(int Clock); - // Overridden tButtonLabelInterface finction. + // Overridden tButtonLabelInterface function. virtual void ButtonLabelDisplay(const wxString& Text, bool IsButtonDown); private: Modified: trunk/jazz/src/TrackWindow.cpp =================================================================== --- trunk/jazz/src/TrackWindow.cpp 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/TrackWindow.cpp 2009-05-17 17:51:49 UTC (rev 722) @@ -33,9 +33,9 @@ #include <wx/dcmemory.h> #include <wx/msgdlg.h> -#include <iostream> -#include <sstream> #include <iomanip> +//DEBUG#include <iostream> +#include <sstream> using namespace std; @@ -211,18 +211,18 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZTrackWindow::Mark(int x, int y) -{ - Marked.SetX(x2xBar(x)); - Marked.SetY(y2yLine(y)); - Marked.SetWidth(x2wBar(x)); - Marked.SetHeight(mTrackHeight); +//void JZTrackWindow::Mark(int x, int y) +//{ +// Marked.SetX(x2xBar(x)); +// Marked.SetY(y2yLine(y)); +// Marked.SetWidth(x2wBar(x)); +// Marked.SetHeight(mTrackHeight); +// +// wxDC* pDc = new wxClientDC(this); +// LineText(*pDc, Marked.GetX(), Marked.GetY(), Marked.GetWidth(), ">"); +// delete pDc; +//} - wxDC* pDc = new wxClientDC(this); - LineText(*pDc, Marked.GetX(), Marked.GetY(), Marked.GetWidth(), ">"); - delete pDc; -} - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void JZTrackWindow::UnMark() @@ -273,15 +273,11 @@ { JZRectangle Rectangle( 0, - y2yLine(Point.y), - Clock2x(mpSong->GetMaxQuarters() * mpSong->GetTicksPerQuarter()), + y2yLine(Point.y + mScrolledY), + Clock2x(mpSong->GetMaxQuarters() * mpSong->GetTicksPerQuarter()) + + mScrolledX, mTrackHeight); - mpSnapSel->Select( - Rectangle, - mEventsX, - mEventsY, - mEventsWidth, - mEventsHeight); + mpSnapSel->Select(Rectangle); SnapSelectionStop(MouseEvent); } else if ( @@ -289,7 +285,8 @@ Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight) { SnapSelectionStart(MouseEvent); - mpSnapSel->ButtonDown(MouseEvent); + + mpSnapSel->ButtonDown(MouseEvent, mScrolledX, mScrolledY); } } @@ -299,7 +296,7 @@ { if (MouseEvent.LeftIsDown()) { - mpSnapSel->Dragging(MouseEvent); + mpSnapSel->Dragging(MouseEvent, mScrolledX, mScrolledY); // SnapSelectionStop(MouseEvent); Refresh(false); } @@ -410,7 +407,7 @@ Point.x >= mEventsX && Point.x < mEventsX + mEventsWidth && Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight) { - mpSnapSel->ButtonUp(MouseEvent); + mpSnapSel->ButtonUp(MouseEvent, mScrolledX, mScrolledY); // The point is in event area. SnapSelectionStop(MouseEvent); @@ -585,8 +582,8 @@ // 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. + // Clear the background using the brush that was just setup, in case the + // following drawing calls fail. LocalDc.Clear(); GetClientSize(&mCanvasWidth, &mCanvasHeight); @@ -638,7 +635,6 @@ //DEBUG << "To X: " << Clock2x(mToClock) << '\n' //DEBUG << endl; - BarInfo.SetClock(mFromClock); mBarCount = 0; @@ -689,6 +685,8 @@ if (mBarCount < eMaxBars) { mBarX[mBarCount++] = x; +//DEBUG LocalDc.SetPen(*wxRED_PEN); +//DEBUG LocalDc.DrawLine(x, 0, x, mCanvasHeight); } } BarInfo.Next(); @@ -918,7 +916,6 @@ if (Height <= 0) { Height = mTrackHeight; - y = y2yLine(y); } if (Width && Height) { @@ -1177,32 +1174,31 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZTrackWindow::x2xBar(int x) -{ - for (int i = 1; i < mBarCount; ++i) - { - if (x < mBarX[i]) - { - return mBarX[i - 1]; - } - } - return -1; -} +//int JZTrackWindow::x2xBar(int x) +//{ +// for (int i = 1; i < mBarCount; ++i) +// { +// if (x < mBarX[i]) +// { +// return mBarX[i - 1]; +// } +// } +// return -1; +//} - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZTrackWindow::x2wBar(int x) -{ - for (int i = 1; i < mBarCount; ++i) - { - if (x < mBarX[i]) - { - return mBarX[i] - mBarX[i - 1]; - } - } - return 0; -} +//int JZTrackWindow::x2wBar(int x) +//{ +// for (int i = 1; i < mBarCount; ++i) +// { +// if (x < mBarX[i]) +// { +// return mBarX[i] - mBarX[i - 1]; +// } +// } +// return 0; +//} //----------------------------------------------------------------------------- // Description: @@ -1437,10 +1433,10 @@ //----------------------------------------------------------------------------- void JZTrackWindow::SnapSelectionStart(wxMouseEvent& MouseEvent) { - mpSnapSel->SetXSnap(mBarCount, mBarX); + mpSnapSel->SetXSnap(mBarCount, mBarX, mScrolledX); mpSnapSel->SetYSnap( TrackIndex2y(mFromLine), - mEventsY + mEventsHeight, + mEventsY + mEventsHeight + mScrolledY, mTrackHeight); } Modified: trunk/jazz/src/TrackWindow.h =================================================================== --- trunk/jazz/src/TrackWindow.h 2009-05-17 17:27:44 UTC (rev 721) +++ trunk/jazz/src/TrackWindow.h 2009-05-17 17:51:49 UTC (rev 722) @@ -138,7 +138,7 @@ int h = -1, bool Down = false); - void Mark(int x, int y); +// void Mark(int x, int y); void UnMark(); @@ -146,9 +146,9 @@ const char* GetNumberString() const; - int x2xBar(int x); +// int x2xBar(int x); - int x2wBar(int x); +// int x2wBar(int x); int TrackIndex2y(int Track); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |