- commit
- a5425704a7273f2e45bba4ad1d10562b13b8700c
- parent
- 1993a0185965bed5b60b0c4af124cec46bcf41d1
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2010-11-01 19:42
mouse contrlls seeker
Diffstat
| M | gui/a.out | 0 | |
| M | gui/xiRTMainFrame.cpp | 24 | ++++++++++++++++-------- |
| M | gui/xiRTMainFrame.h | 3 | +++ |
| M | gui/xiRetimer_wxfb.cpp | 4 | ++++ |
| M | gui/xiRetimer_wxfb.fbp | 4 | ++-- |
| M | gui/xiRetimer_wxfb.h | 2 | ++ |
| M | src/curve.cpp | 22 | ++++++++++++++++++---- |
| M | src/curve.h | 3 | +++ |
| M | src/sample.cpp | 2 | +- |
9 files changed, 49 insertions, 15 deletions
diff --git a/gui/a.out b/gui/a.out
Binary files differ.diff --git a/gui/xiRTMainFrame.cpp b/gui/xiRTMainFrame.cpp
@@ -8,7 +8,8 @@ 8 8 #include <wx/string.h> 9 9 #include <wx/filedlg.h> 10 1011 -1 // TODO move seeker with mouse-1 11 #include <iostream> -1 12 12 13 // TODO icon bar 13 14 14 15 xiRTMainFrame::xiRTMainFrame( wxWindow* parent ) : MainFrame( parent ) { @@ -17,12 +18,20 @@ xiRTMainFrame::xiRTMainFrame( wxWindow* parent ) : MainFrame( parent ) { 17 18 curve->setSeeker(0.7); 18 19 curve->addMarker(); 19 20 curve->setSeeker(0.3); -1 21 width=100; // anything greater than 2 20 22 } 21 23 22 24 xiRTMainFrame::~xiRTMainFrame() { 23 25 delete[] curve; 24 26 } 25 27 -1 28 void xiRTMainFrame::OnLeftDown( wxMouseEvent& event ) { -1 29 std::cout << event.m_x << " " << event.m_x/(float)width <<std::endl; -1 30 curve->setSeeker(event.m_x/(float)width); -1 31 } -1 32 -1 33 void xiRTMainFrame::OnLeftUp( wxMouseEvent& event ) {} -1 34 26 35 void xiRTMainFrame::OnOpenClick( wxCommandEvent& event ) 27 36 { 28 37 wxFileDialog* dialog = new wxFileDialog( (wxWindow*)NULL ); @@ -87,10 +96,9 @@ void xiRTMainFrame::OnMRmClick( wxCommandEvent& event ) 87 96 void xiRTMainFrame::paint() { 88 97 // TODO dont repaint all the time 89 98 wxClientDC dc2(this);90 -1 int w=0;91 99 int h=0;92 -1 dc2.GetSize(&w,&h);93 -1 wxBufferedDC dc(&dc2,wxSize(w,h));-1 100 dc2.GetSize(&width,&h); -1 101 wxBufferedDC dc(&dc2,wxSize(width,h)); 94 102 95 103 wxBrush brush(*wxBLACK); // red pen of width 1 96 104 dc.SetBackground(brush); @@ -100,17 +108,17 @@ void xiRTMainFrame::paint() { 100 108 dc.SetPen(penCurve); 101 109 dc.Clear(); 102 110 // TODO nicer looking shape103 -1 for (int i=0; i<w-1; ++i) {104 -1 dc.DrawLine(i,int(curve->get(i/(float)(w-1))*h+h)/2,i+1,int(curve->get((i+1)/(float)(w-1))*h+h)/2);-1 111 for (int i=0; i<width-1; ++i) { -1 112 dc.DrawLine(i,int(curve->get(i/(float)(width-1))*h+h)/2,i+1,int(curve->get((i+1)/(float)(width-1))*h+h)/2); 105 113 } 106 114 // TODO display tempo bars ... 107 115 dc.SetPen(penMarker); 108 116 for (int i=0; i<curve->getMarkerLength(); ++i) {109 -1 int n=int(curve->getMarker(i)*(w-1));-1 117 int n=int(curve->getMarker(i)*(width-1)); 110 118 dc.DrawLine(n,0,n,h); 111 119 } 112 120 dc.SetPen(penSeeker);113 -1 int seek=int(curve->getSeeker()*(w-1));-1 121 int seek=int(curve->getSeeker()*(width-1)); 114 122 dc.DrawLine(seek,0,seek,h); 115 123 } 116 124
diff --git a/gui/xiRTMainFrame.h b/gui/xiRTMainFrame.h
@@ -16,6 +16,8 @@ class xiRTMainFrame : public MainFrame 16 16 { 17 17 protected: 18 18 // Handlers for MainFrame events. -1 19 void OnLeftDown( wxMouseEvent& event ); -1 20 void OnLeftUp( wxMouseEvent& event ); 19 21 void OnOpenClick( wxCommandEvent& event ); 20 22 void OnExportClick( wxCommandEvent& event ); 21 23 void OnPrefsClick( wxCommandEvent& event ); @@ -29,6 +31,7 @@ protected: 29 31 void paint(); 30 32 Sample* sample; 31 33 Curve* curve; -1 34 int width; 32 35 33 36 public: 34 37 /** Constructor */
diff --git a/gui/xiRetimer_wxfb.cpp b/gui/xiRetimer_wxfb.cpp
@@ -65,6 +65,8 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co 65 65 m_statusBar1 = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY ); 66 66 67 67 // Connect Events -1 68 this->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MainFrame::OnLeftDown ) ); -1 69 this->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( MainFrame::OnLeftUp ) ); 68 70 this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( MainFrame::OnUpdateUI ) ); 69 71 this->Connect( m_open->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnOpenClick ) ); 70 72 this->Connect( m_export->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnExportClick ) ); @@ -77,6 +79,8 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co 77 79 MainFrame::~MainFrame() 78 80 { 79 81 // Disconnect Events -1 82 this->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MainFrame::OnLeftDown ) ); -1 83 this->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( MainFrame::OnLeftUp ) ); 80 84 this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( MainFrame::OnUpdateUI ) ); 81 85 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnOpenClick ) ); 82 86 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnExportClick ) );
diff --git a/gui/xiRetimer_wxfb.fbp b/gui/xiRetimer_wxfb.fbp
@@ -60,8 +60,8 @@ 60 60 <event name="OnKillFocus"></event> 61 61 <event name="OnLeaveWindow"></event> 62 62 <event name="OnLeftDClick"></event>63 -1 <event name="OnLeftDown"></event>64 -1 <event name="OnLeftUp"></event>-1 63 <event name="OnLeftDown">OnLeftDown</event> -1 64 <event name="OnLeftUp">OnLeftUp</event> 65 65 <event name="OnMiddleDClick"></event> 66 66 <event name="OnMiddleDown"></event> 67 67 <event name="OnMiddleUp"></event>
diff --git a/gui/xiRetimer_wxfb.h b/gui/xiRetimer_wxfb.h
@@ -43,6 +43,8 @@ class MainFrame : public wxFrame 43 43 wxStatusBar* m_statusBar1; 44 44 45 45 // Virtual event handlers, overide them in your derived class -1 46 virtual void OnLeftDown( wxMouseEvent& event ) { event.Skip(); } -1 47 virtual void OnLeftUp( wxMouseEvent& event ) { event.Skip(); } 46 48 virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } 47 49 virtual void OnOpenClick( wxCommandEvent& event ) { event.Skip(); } 48 50 virtual void OnExportClick( wxCommandEvent& event ) { event.Skip(); }
diff --git a/src/curve.cpp b/src/curve.cpp
@@ -9,6 +9,7 @@ Curve::Curve() {
9 9 sample=new Sample(marker);
10 10 seeker=0;
11 11 tempo=90;
-1 12 selMarker=0;
12 13 }
13 14
14 15 Curve::~Curve() {
@@ -29,15 +30,29 @@ void Curve::setSeeker(float nn) {
29 30 void Curve::setTempo(int bpm) {tempo=bpm;}
30 31 int Curve::getTempo() {return tempo;}
31 32
32 -1 // TODO select and move marker
33 33 void Curve::addMarker() {
34 34 float n=marker->nnew2new(seeker);
35 35 marker->add(marker->new2old(n),n);
-1 36 // update selMarker
-1 37 if (n<selMarker) --selMarker;
-1 38 if (selMarker>=getMarkerLength()) --selMarker;
36 39 }
37 40
38 41 void Curve::removeMarker() {
39 -1 int i=marker->getAreaNew(marker->nnew2new(seeker));
40 -1 marker->remove(i);
-1 42 marker->remove(selMarker);
-1 43 // update selMarker
-1 44 if (selMarker>=getMarkerLength()) --selMarker;
-1 45 }
-1 46
-1 47 void Curve::setMarker(float nn) {
-1 48 int i=marker->getAreaNew(marker->nnew2new(nn));
-1 49 if (i!=selMarker || i!=selMarker-1) return;
-1 50 marker->setNew(selMarker,marker->nnew2new(nn));
-1 51 }
-1 52
-1 53 void Curve::selectMarker(int i) {
-1 54 if (i<0 || i>=getMarkerLength()) return;
-1 55 selMarker=i;
41 56 }
42 57
43 58 int Curve::getMarkerLength() {return marker->getLength();}
@@ -53,4 +68,3 @@ void Curve::print() {
53 68 }
54 69 }
55 70
56 -1
diff --git a/src/curve.h b/src/curve.h
@@ -24,10 +24,13 @@ public: 24 24 void removeMarker(); 25 25 int getMarkerLength(); 26 26 float getMarker(int i); -1 27 void selectMarker(int i); -1 28 void setMarker(float nn); 27 29 private: 28 30 float seeker; // 0-1 29 31 Marker* marker; 30 32 int tempo; // bpm -1 33 int selMarker; 31 34 }; 32 35 33 36 /*
diff --git a/src/sample.cpp b/src/sample.cpp
@@ -23,7 +23,7 @@ float Sample::get(float nn) {
23 23 return data[i];
24 24 }
25 25
26 -1 loat Sample::getOld(float o) {
-1 26 float Sample::getOld(float o) {
27 27 // TODO interpolation?
28 28 int i=int((olength-1)*o);
29 29 if (i<0 || i>=olength) return NULL;