Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

ctracking.C

Go to the documentation of this file.
00001 #include "bcsignals.h"
00002 #include "cplayback.h"
00003 #include "ctimebar.h"
00004 #include "ctracking.h"
00005 #include "cwindow.h"
00006 #include "cwindowgui.h"
00007 #include "edl.h"
00008 #include "edlsession.h"
00009 #include "localsession.h"
00010 #include "mainclock.h"
00011 #include "maincursor.h"
00012 #include "mwindow.h"
00013 #include "mwindowgui.h"
00014 #include "patchbay.h"
00015 #include "trackcanvas.h"
00016 #include "transportque.h"
00017 #include "zoombar.h"
00018 
00019 CTracking::CTracking(MWindow *mwindow, CWindow *cwindow)
00020  : Tracking(mwindow)
00021 {
00022         this->cwindow = cwindow;
00023 }
00024 
00025 CTracking::~CTracking()
00026 {
00027 }
00028 
00029 PlaybackEngine* CTracking::get_playback_engine()
00030 {
00031         return cwindow->playback_engine;
00032 }
00033 
00034 int CTracking::start_playback(double new_position)
00035 {
00036         mwindow->gui->cursor->playing_back = 1;
00037 
00038         Tracking::start_playback(new_position);
00039         return 0;
00040 }
00041 
00042 int CTracking::stop_playback()
00043 {
00044         mwindow->gui->cursor->playing_back = 0;
00045 
00046 
00047         Tracking::stop_playback();
00048         return 0;
00049 }
00050 
00051 #define SCROLL_THRESHOLD 0
00052 
00053 
00054 int CTracking::update_scroll(double position)
00055 {
00056         int updated_scroll = 0;
00057 
00058         if(mwindow->edl->session->view_follows_playback)
00059         {
00060                 double seconds_per_pixel = (double)mwindow->edl->local_session->zoom_sample / 
00061                         mwindow->edl->session->sample_rate;
00062                 double half_canvas = seconds_per_pixel * 
00063                         mwindow->gui->canvas->get_w() / 2;
00064                 double midpoint = mwindow->edl->local_session->view_start * 
00065                         seconds_per_pixel +
00066                         half_canvas;
00067 
00068                 if(get_playback_engine()->command->get_direction() == PLAY_FORWARD)
00069                 {
00070                         double left_boundary = midpoint + SCROLL_THRESHOLD * half_canvas;
00071                         double right_boundary = midpoint + half_canvas;
00072 
00073                         if(position > left_boundary &&
00074                                 position < right_boundary)
00075                         {
00076                                 int pixels = Units::to_int64((position - midpoint) * 
00077                                         mwindow->edl->session->sample_rate /
00078                                         mwindow->edl->local_session->zoom_sample);
00079                                 if(pixels) 
00080                                 {
00081                                         mwindow->move_right(pixels);
00082 //printf("CTracking::update_scroll 1 %d\n", pixels);
00083                                         updated_scroll = 1;
00084                                 }
00085                         }
00086                 }
00087                 else
00088                 {
00089                         double right_boundary = midpoint - SCROLL_THRESHOLD * half_canvas;
00090                         double left_boundary = midpoint - half_canvas;
00091 
00092                         if(position < right_boundary &&
00093                                 position > left_boundary && 
00094                                 mwindow->edl->local_session->view_start > 0)
00095                         {
00096                                 int pixels = Units::to_int64((midpoint - position) * 
00097                                                 mwindow->edl->session->sample_rate /
00098                                                 mwindow->edl->local_session->zoom_sample);
00099                                 if(pixels) 
00100                                 {
00101                                         mwindow->move_left(pixels);
00102                                         updated_scroll = 1;
00103                                 }
00104                         }
00105                 }
00106         }
00107 
00108         return updated_scroll;
00109 }
00110 
00111 void CTracking::update_tracker(double position)
00112 {
00113         int updated_scroll = 0;
00114 // Update cwindow slider
00115         cwindow->gui->lock_window("CTracking::update_tracker 1");
00116         cwindow->gui->slider->update(position);
00117 
00118 // This is going to boost the latency but we need to update the timebar
00119         cwindow->gui->timebar->draw_range();
00120         cwindow->gui->timebar->flash();
00121         cwindow->gui->unlock_window();
00122 
00123 // Update mwindow cursor
00124         mwindow->gui->lock_window("CTracking::update_tracker 2");
00125 
00126         mwindow->edl->local_session->set_selectionstart(position);
00127         mwindow->edl->local_session->set_selectionend(position);
00128 
00129         updated_scroll = update_scroll(position);
00130 
00131         mwindow->gui->mainclock->update(position);
00132         mwindow->gui->patchbay->update();
00133 
00134         if(!updated_scroll)
00135         {
00136                 mwindow->gui->cursor->update();
00137                 mwindow->gui->zoombar->update();
00138 
00139 
00140                 mwindow->gui->canvas->flash();
00141                 mwindow->gui->flush();
00142         }
00143         mwindow->gui->unlock_window();
00144 
00145 // Plugin GUI's hold lock on mwindow->gui here during user interface handlers.
00146         mwindow->update_plugin_guis();
00147 
00148 
00149         update_meters((int64_t)(position * mwindow->edl->session->sample_rate));
00150 }
00151 
00152 void CTracking::draw()
00153 {
00154 }

Generated on Sun Jan 8 13:38:51 2006 for Cinelerra-svn by  doxygen 1.4.4