refresh frame fix, dblclk proxy viewer fix, vicon refresh fix for awdw resize, fix...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / ctimebar.C
index 8cdb4cbdabbc749a37f5bdd34ef5c58c87190af1..6929cc12104de8f652c1711c2b4969f7cd1277a3 100644 (file)
 #include "theme.h"
 
 
-CTimeBar::CTimeBar(MWindow *mwindow,
-               CWindowGUI *gui,
-               int x,
-               int y,
-               int w,
-               int h)
- : TimeBar(mwindow,
-               gui,
-               x,
-               y,
-               w,
-               h)
+CTimeBar::CTimeBar(MWindow *mwindow, CWindowGUI *gui,
+               int x, int y, int w, int h)
+ : TimeBar(mwindow, gui, x, y, w, h)
 {
        this->mwindow = mwindow;
        this->gui = gui;
@@ -73,17 +64,18 @@ void CTimeBar::draw_time()
 
 double CTimeBar::pixel_to_position(int pixel)
 {
-       double start = 0, length = 0;
+       double start = 0, end = get_edl_length();
        EDL *edl = get_edl();
-       if(edl)
-       {
-               start = edl->local_session->preview_start;
-               if(start >= 0)
-                       length = edl->local_session->preview_end - start;
+       if( edl ) {
+               double preview_start = edl->local_session->preview_start;
+               double preview_end = edl->local_session->preview_end;
+               if( preview_end >= 0 || preview_start > 0 )
+                       start = preview_start;
+               if( preview_end >= 0 && preview_end < end )
+                       end = preview_end;
        }
-       if(length <= 0)
-               length = get_edl_length();
-       return start + (double)pixel * length / get_w();
+       if( start > end ) start = end;
+       return start + (double)pixel * (end - start) / get_w();
 }
 
 
@@ -98,29 +90,22 @@ void CTimeBar::update_cursor()
 
 void CTimeBar::select_label(double position)
 {
-       EDL *edl = mwindow->edl;
-
-       gui->unlock_window();
-       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-       gui->lock_window();
+       gui->stop_transport("CTimeBar::select_label");
 
-       position = mwindow->edl->align_to_frame(position, 1);
+       EDL *edl = mwindow->edl;
+       position = edl->align_to_frame(position, 1);
 
-       if(shift_down())
-       {
-               if(position > edl->local_session->get_selectionend(1) / 2 +
-                       edl->local_session->get_selectionstart(1) / 2)
-               {
+       if( shift_down() ) {
+               if( position > edl->local_session->get_selectionend(1) / 2 +
+                       edl->local_session->get_selectionstart(1) / 2 ) {
 
                        edl->local_session->set_selectionend(position);
                }
-               else
-               {
+               else {
                        edl->local_session->set_selectionstart(position);
                }
        }
-       else
-       {
+       else {
                edl->local_session->set_selectionstart(position);
                edl->local_session->set_selectionend(position);
        }
@@ -133,19 +118,10 @@ void CTimeBar::select_label(double position)
        mwindow->gui->lock_window();
        mwindow->gui->hide_cursor(0);
        mwindow->gui->draw_cursor(1);
-       mwindow->gui->update(0,
-               1,      // 1 for incremental drawing.  2 for full refresh
-               1,
-               0,
-               1,
-               1,
-               0);
+       mwindow->gui->update(0, 1,      // 1 for incremental drawing.  2 for full refresh
+               1, 0, 1, 1, 0);
        mwindow->gui->unlock_window();
        mwindow->update_plugin_guis();
 //printf("CTimeBar::select_label 2\n");
 }
 
-
-
-
-