fix shf-f1/f2 toggle timeline update
[goodguy/history.git] / cinelerra-5.1 / cinelerra / vtimebar.C
index a62e347c0e7152c7cf2e497a674c73349f35ca1f..2855f161437a55767a2db45bc6ef228f851db896 100644 (file)
@@ -2,21 +2,21 @@
 /*
  * CINELERRA
  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- * 
+ *
  */
 
 #include "edl.h"
 #include "vwindowgui.h"
 
 
-VTimeBar::VTimeBar(MWindow *mwindow, 
+VTimeBar::VTimeBar(MWindow *mwindow,
                VWindowGUI *gui,
                int x,
                int y,
-               int w, 
+               int w,
                int h)
- : TimeBar(mwindow, 
+ : TimeBar(mwindow,
                gui,
-               x, 
+               x,
                y,
                w,
                h)
@@ -68,18 +68,14 @@ void VTimeBar::draw_time()
 void VTimeBar::select_label(double position)
 {
        EDL *edl = get_edl();
-
-       if(edl)
-       {
-               unlock_window();
-               gui->transport->handle_transport(STOP, 1, 0, 0);
-               lock_window();
+       if( edl ) {
+               gui->stop_transport("VTimeBar::select_label");
 
                position = mwindow->edl->align_to_frame(position, 1);
 
                if(shift_down())
                {
-                       if(position > edl->local_session->get_selectionend(1) / 2 + 
+                       if(position > edl->local_session->get_selectionend(1) / 2 +
                                edl->local_session->get_selectionstart(1) / 2)
                        {
 
@@ -97,8 +93,8 @@ void VTimeBar::select_label(double position)
                }
 
 // Que the CWindow
-               gui->vwindow->update_position(CHANGE_NONE, 
-                       0, 
+               gui->vwindow->update_position(CHANGE_NONE,
+                       0,
                        1,
                        0);
                update(1);
@@ -107,19 +103,21 @@ void VTimeBar::select_label(double position)
 
 double VTimeBar::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();
 }
 
+
 void VTimeBar::update_cursor()
 {
        int rx = get_relative_cursor_x();
@@ -128,4 +126,8 @@ void VTimeBar::update_cursor()
        update(1);
 }
 
+double VTimeBar::test_highlight()
+{
+       return gui->edit_panel->get_position();
+}