refresh frame fix, dblclk proxy viewer fix, vicon refresh fix for awdw resize, fix...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / timebar.C
index 8d8bfc7c6a58f7deeac606fba58980831e092370..e386bea54120c4ffb2e6d769aa3a2105ba29a769 100644 (file)
@@ -24,6 +24,7 @@
 #include "cplayback.h"
 #include "cursors.h"
 #include "cwindow.h"
+#include "cwindowgui.h"
 #include "edl.h"
 #include "edlsession.h"
 #include "filexml.h"
@@ -205,12 +206,12 @@ int64_t TimeBar::position_to_pixel(double position)
 double TimeBar::pixel_to_position(int pixel)
 {
        if( pane ) {
-               pixel += mwindow->edl->local_session->view_start[pane->number];
+               pixel += get_edl()->local_session->view_start[pane->number];
        }
 
        return (double)pixel *
-               mwindow->edl->local_session->zoom_sample /
-               mwindow->edl->session->sample_rate;
+               get_edl()->local_session->zoom_sample /
+               get_edl()->session->sample_rate;
 }
 
 void TimeBar::update_labels()
@@ -277,31 +278,33 @@ void TimeBar::update_labels()
 
 void TimeBar::update_highlights()
 {
+       EDL *edl = get_edl();
+       if( !edl ) return;
        for( int i = 0; i < labels.total; i++ ) {
                LabelGUI *label = labels.values[i];
-               if( mwindow->edl->equivalent(label->position,
-                               mwindow->edl->local_session->get_selectionstart(1)) ||
-                   mwindow->edl->equivalent(label->position,
-                               mwindow->edl->local_session->get_selectionend(1)) ) {
+               if( edl->equivalent(label->position,
+                               edl->local_session->get_selectionstart(1)) ||
+                   edl->equivalent(label->position,
+                               edl->local_session->get_selectionend(1)) ) {
                        if( !label->get_value() ) label->update(1);
                }
                else
                        if( label->get_value() ) label->update(0);
        }
 
-       if( mwindow->edl->equivalent(mwindow->edl->local_session->get_inpoint(),
-                       mwindow->edl->local_session->get_selectionstart(1)) ||
-               mwindow->edl->equivalent(mwindow->edl->local_session->get_inpoint(),
-                       mwindow->edl->local_session->get_selectionend(1)) ) {
+       if( edl->equivalent(edl->local_session->get_inpoint(),
+                       edl->local_session->get_selectionstart(1)) ||
+               edl->equivalent(edl->local_session->get_inpoint(),
+                       edl->local_session->get_selectionend(1)) ) {
                if( in_point ) in_point->update(1);
        }
        else
                if( in_point ) in_point->update(0);
 
-       if( mwindow->edl->equivalent(mwindow->edl->local_session->get_outpoint(),
-                       mwindow->edl->local_session->get_selectionstart(1)) ||
-               mwindow->edl->equivalent(mwindow->edl->local_session->get_outpoint(),
-                       mwindow->edl->local_session->get_selectionend(1)) ) {
+       if( edl->equivalent(edl->local_session->get_outpoint(),
+                       edl->local_session->get_selectionstart(1)) ||
+               edl->equivalent(edl->local_session->get_outpoint(),
+                       edl->local_session->get_selectionend(1)) ) {
                if( out_point ) out_point->update(1);
        }
        else
@@ -393,7 +396,7 @@ void TimeBar::update(int flush)
 //printf("TimeBar::update %d %d\n", __LINE__, x);
                double position = pixel_to_position(x);
 
-               position = get_edl()->align_to_frame(position, 0);
+               position = mwindow->edl->align_to_frame(position, 0);
                pixel = position_to_pixel(position);
                update_clock(position);
        }
@@ -692,7 +695,7 @@ int TimeBar::button_press_event()
                        stop_playback();
 
 // Select region between two labels
-                       if( get_double_click() ) {
+                       if( !is_vwindow() && get_double_click() ) {
                                int x = get_relative_cursor_x();
                                double position = pixel_to_position(x);
 // Test labels
@@ -815,14 +818,14 @@ void TimeBar::handle_mwindow_drag()
 int TimeBar::select_region(double position)
 {
        Label *start = 0, *end = 0, *current;
-       for( current = mwindow->edl->labels->first; current; current = NEXT ) {
+       for( current = get_edl()->labels->first; current; current = NEXT ) {
                if( current->position > position ) {
                        end = current;
                        break;
                }
        }
 
-       for( current = mwindow->edl->labels->last ; current; current = PREVIOUS ) {
+       for( current = get_edl()->labels->last ; current; current = PREVIOUS ) {
                if( current->position <= position ) {
                        start = current;
                        break;
@@ -832,28 +835,32 @@ int TimeBar::select_region(double position)
 // Select region
        if( end != start ) {
                if( !start )
-                       mwindow->edl->local_session->set_selectionstart(0);
+                       get_edl()->local_session->set_selectionstart(0);
                else
-                       mwindow->edl->local_session->set_selectionstart(start->position);
+                       get_edl()->local_session->set_selectionstart(start->position);
 
                if( !end )
-                       mwindow->edl->local_session->set_selectionend(mwindow->edl->tracks->total_length());
+                       get_edl()->local_session->set_selectionend(get_edl()->tracks->total_length());
                else
-                       mwindow->edl->local_session->set_selectionend(end->position);
+                       get_edl()->local_session->set_selectionend(end->position);
        }
        else
        if( end || start ) {
-               mwindow->edl->local_session->set_selectionstart(start->position);
-               mwindow->edl->local_session->set_selectionend(start->position);
+               get_edl()->local_session->set_selectionstart(start->position);
+               get_edl()->local_session->set_selectionend(start->position);
        }
 
 // Que the CWindow
+       mwindow->cwindow->gui->lock_window("TimeBar::select_region");
        mwindow->cwindow->update(1, 0, 0);
+       mwindow->cwindow->gui->unlock_window();
+       mwindow->gui->lock_window("TimeBar::select_region");
        mwindow->gui->hide_cursor(0);
        mwindow->gui->draw_cursor(1);
        mwindow->gui->flash_canvas(0);
        mwindow->gui->activate_timeline();
        mwindow->gui->zoombar->update();
+       mwindow->gui->unlock_window();
        update_highlights();
        return 0;
 }