6 #include "cwindowgui.h"
8 #include "edlsession.h"
9 #include "localsession.h"
10 #include "mainclock.h"
11 #include "maincursor.h"
13 #include "mwindowgui.h"
15 #include "trackcanvas.h"
16 #include "transportque.h"
19 CTracking::CTracking(MWindow *mwindow, CWindow *cwindow)
22 this->cwindow = cwindow;
25 CTracking::~CTracking()
29 PlaybackEngine* CTracking::get_playback_engine()
31 return cwindow->playback_engine;
34 int CTracking::start_playback(double new_position)
36 mwindow->gui->cursor->playing_back = 1;
38 Tracking::start_playback(new_position);
42 int CTracking::stop_playback()
44 mwindow->gui->cursor->playing_back = 0;
47 Tracking::stop_playback();
51 #define SCROLL_THRESHOLD 0
54 int CTracking::update_scroll(double position)
56 int updated_scroll = 0;
58 if(mwindow->edl->session->view_follows_playback)
60 double seconds_per_pixel = (double)mwindow->edl->local_session->zoom_sample /
61 mwindow->edl->session->sample_rate;
62 double half_canvas = seconds_per_pixel *
63 mwindow->gui->canvas->get_w() / 2;
64 double midpoint = mwindow->edl->local_session->view_start *
68 if(get_playback_engine()->command->get_direction() == PLAY_FORWARD)
70 double left_boundary = midpoint + SCROLL_THRESHOLD * half_canvas;
71 double right_boundary = midpoint + half_canvas;
73 if(position > left_boundary &&
74 position < right_boundary)
76 int pixels = Units::to_int64((position - midpoint) *
77 mwindow->edl->session->sample_rate /
78 mwindow->edl->local_session->zoom_sample);
81 mwindow->move_right(pixels);
82 //printf("CTracking::update_scroll 1 %d\n", pixels);
89 double right_boundary = midpoint - SCROLL_THRESHOLD * half_canvas;
90 double left_boundary = midpoint - half_canvas;
92 if(position < right_boundary &&
93 position > left_boundary &&
94 mwindow->edl->local_session->view_start > 0)
96 int pixels = Units::to_int64((midpoint - position) *
97 mwindow->edl->session->sample_rate /
98 mwindow->edl->local_session->zoom_sample);
101 mwindow->move_left(pixels);
108 return updated_scroll;
111 void CTracking::update_tracker(double position)
113 int updated_scroll = 0;
114 // Update cwindow slider
115 cwindow->gui->lock_window("CTracking::update_tracker 1");
116 cwindow->gui->slider->update(position);
118 // This is going to boost the latency but we need to update the timebar
119 cwindow->gui->timebar->draw_range();
120 cwindow->gui->timebar->flash();
121 cwindow->gui->unlock_window();
123 // Update mwindow cursor
124 mwindow->gui->lock_window("CTracking::update_tracker 2");
126 mwindow->edl->local_session->set_selectionstart(position);
127 mwindow->edl->local_session->set_selectionend(position);
129 updated_scroll = update_scroll(position);
131 mwindow->gui->mainclock->update(position);
132 mwindow->gui->patchbay->update();
136 mwindow->gui->cursor->update();
137 mwindow->gui->zoombar->update_clocks(); // we just need to update clocks, not everything
140 mwindow->gui->canvas->flash();
141 mwindow->gui->flush();
143 mwindow->gui->unlock_window();
145 // Plugin GUI's hold lock on mwindow->gui here during user interface handlers.
146 mwindow->update_plugin_guis();
149 update_meters((int64_t)(position * mwindow->edl->session->sample_rate));
152 void CTracking::draw()