5 #include "cwindowgui.h"
7 #include "edlsession.h"
8 #include "localsession.h"
11 #include "mwindowgui.h"
13 #include "trackcanvas.h"
14 #include "transportque.h"
17 CTracking::CTracking(MWindow *mwindow, CWindow *cwindow)
20 this->cwindow = cwindow;
23 CTracking::~CTracking()
27 PlaybackEngine* CTracking::get_playback_engine()
29 return cwindow->playback_engine;
32 int CTracking::start_playback(double new_position)
34 mwindow->gui->cursor->playing_back = 1;
36 Tracking::start_playback(new_position);
40 int CTracking::stop_playback()
42 mwindow->gui->cursor->playing_back = 0;
45 Tracking::stop_playback();
49 #define SCROLL_THRESHOLD 0
52 int CTracking::update_scroll(double position)
54 int updated_scroll = 0;
56 if(mwindow->edl->session->view_follows_playback)
58 double seconds_per_pixel = (double)mwindow->edl->local_session->zoom_sample /
59 mwindow->edl->session->sample_rate;
60 double half_canvas = seconds_per_pixel *
61 mwindow->gui->canvas->get_w() / 2;
62 double midpoint = mwindow->edl->local_session->view_start *
66 if(get_playback_engine()->command->get_direction() == PLAY_FORWARD)
68 double left_boundary = midpoint + SCROLL_THRESHOLD * half_canvas;
69 double right_boundary = midpoint + half_canvas;
71 if(position > left_boundary &&
72 position < right_boundary)
74 int pixels = Units::to_int64((position - midpoint) *
75 mwindow->edl->session->sample_rate /
76 mwindow->edl->local_session->zoom_sample);
79 mwindow->move_right(pixels);
80 //printf("CTracking::update_scroll 1 %d\n", pixels);
87 double right_boundary = midpoint - SCROLL_THRESHOLD * half_canvas;
88 double left_boundary = midpoint - half_canvas;
90 if(position < right_boundary &&
91 position > left_boundary &&
92 mwindow->edl->local_session->view_start > 0)
94 int pixels = Units::to_int64((midpoint - position) *
95 mwindow->edl->session->sample_rate /
96 mwindow->edl->local_session->zoom_sample);
99 mwindow->move_left(pixels);
106 return updated_scroll;
109 void CTracking::update_tracker(double position)
111 int updated_scroll = 0;
112 // Update cwindow slider
113 cwindow->gui->lock_window();
114 cwindow->gui->slider->update(position);
116 // This is going to boost the latency but we need to update the timebar
117 cwindow->gui->timebar->draw_range();
118 cwindow->gui->timebar->flash();
119 cwindow->gui->unlock_window();
121 // Update mwindow cursor
122 mwindow->gui->lock_window();
124 mwindow->edl->local_session->selectionstart =
125 mwindow->edl->local_session->selectionend =
128 updated_scroll = update_scroll(position);
130 mwindow->gui->mainclock->update(position);
131 mwindow->gui->patchbay->update();
135 mwindow->gui->cursor->update();
136 mwindow->gui->zoombar->update();
139 mwindow->gui->canvas->flash();
140 mwindow->gui->flush();
142 mwindow->gui->unlock_window();
144 // Plugin GUI's hold lock on mwindow->gui here during user interface handlers.
145 mwindow->update_plugin_guis();
148 update_meters((int64_t)(position * mwindow->edl->session->sample_rate));
151 void CTracking::draw()