6 #include "cwindowgui.h"
8 #include "edlsession.h"
9 #include "localsession.h"
10 #include "mainclock.h"
12 #include "mwindowgui.h"
14 #include "trackcanvas.h"
15 #include "transportque.h"
18 CTracking::CTracking(MWindow *mwindow, CWindow *cwindow)
21 this->cwindow = cwindow;
24 CTracking::~CTracking()
28 PlaybackEngine* CTracking::get_playback_engine()
30 return cwindow->playback_engine;
33 int CTracking::start_playback(double new_position)
35 mwindow->gui->cursor->playing_back = 1;
37 Tracking::start_playback(new_position);
41 int CTracking::stop_playback()
43 mwindow->gui->cursor->playing_back = 0;
46 Tracking::stop_playback();
50 #define SCROLL_THRESHOLD 0
53 int CTracking::update_scroll(double position)
55 int updated_scroll = 0;
57 if(mwindow->edl->session->view_follows_playback)
59 double seconds_per_pixel = (double)mwindow->edl->local_session->zoom_sample /
60 mwindow->edl->session->sample_rate;
61 double half_canvas = seconds_per_pixel *
62 mwindow->gui->canvas->get_w() / 2;
63 double midpoint = mwindow->edl->local_session->view_start *
67 if(get_playback_engine()->command->get_direction() == PLAY_FORWARD)
69 double left_boundary = midpoint + SCROLL_THRESHOLD * half_canvas;
70 double right_boundary = midpoint + half_canvas;
72 if(position > left_boundary &&
73 position < right_boundary)
75 int pixels = Units::to_int64((position - midpoint) *
76 mwindow->edl->session->sample_rate /
77 mwindow->edl->local_session->zoom_sample);
80 mwindow->move_right(pixels);
81 //printf("CTracking::update_scroll 1 %d\n", pixels);
88 double right_boundary = midpoint - SCROLL_THRESHOLD * half_canvas;
89 double left_boundary = midpoint - half_canvas;
91 if(position < right_boundary &&
92 position > left_boundary &&
93 mwindow->edl->local_session->view_start > 0)
95 int pixels = Units::to_int64((midpoint - position) *
96 mwindow->edl->session->sample_rate /
97 mwindow->edl->local_session->zoom_sample);
100 mwindow->move_left(pixels);
107 return updated_scroll;
110 void CTracking::update_tracker(double position)
112 int updated_scroll = 0;
113 // Update cwindow slider
114 //TRACE("CTracking::update_tracker 1");
115 cwindow->gui->lock_window("CTracking::update_tracker 1");
116 //TRACE("CTracking::update_tracker 2");
117 cwindow->gui->slider->update(position);
119 // This is going to boost the latency but we need to update the timebar
120 cwindow->gui->timebar->draw_range();
121 cwindow->gui->timebar->flash();
122 cwindow->gui->unlock_window();
123 //TRACE("CTracking::update_tracker 3");
125 // Update mwindow cursor
126 mwindow->gui->lock_window("CTracking::update_tracker 2");
127 //TRACE("CTracking::update_tracker 4");
129 mwindow->edl->local_session->selectionstart =
130 mwindow->edl->local_session->selectionend =
133 updated_scroll = update_scroll(position);
134 //TRACE("CTracking::update_tracker 5");
136 mwindow->gui->mainclock->update(position);
137 //TRACE("CTracking::update_tracker 5.5");
138 mwindow->gui->patchbay->update();
139 //TRACE("CTracking::update_tracker 6");
143 mwindow->gui->cursor->update();
144 mwindow->gui->zoombar->update();
147 mwindow->gui->canvas->flash();
148 mwindow->gui->flush();
150 mwindow->gui->unlock_window();
151 //TRACE("CTracking::update_tracker 7");
153 // Plugin GUI's hold lock on mwindow->gui here during user interface handlers.
154 mwindow->update_plugin_guis();
155 //TRACE("CTracking::update_tracker 8");
158 update_meters((int64_t)(position * mwindow->edl->session->sample_rate));
159 //TRACE("CTracking::update_tracker 9");
162 void CTracking::draw()