Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mwindowmove.C
index 5abe4e6c20b15cf77c96a46d198f0856b19a085f..3bad75ef0e9ea905780c891d27e2f00eab105869 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * CINELERRA
  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2003-2016 Cinelerra CV contributors
  *
  * 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
@@ -28,6 +29,7 @@
 #include "edits.h"
 #include "edl.h"
 #include "edlsession.h"
+#include "gwindowgui.h"
 #include "keyframe.h"
 #include "labels.h"
 #include "localsession.h"
@@ -259,7 +261,7 @@ void MWindow::change_currentautorange(int autogrouptype, int increment, int chan
                        break;
                case AUTOGROUPTYPE_X:
                case AUTOGROUPTYPE_Y:
-                       val = floor(val + 5);
+                       val = floor(val + 50);
                        break;
                }
        }
@@ -278,7 +280,7 @@ void MWindow::change_currentautorange(int autogrouptype, int increment, int chan
                        break;
                case AUTOGROUPTYPE_X:
                case AUTOGROUPTYPE_Y:
-                       val = floor(val-5);
+                       val = floor(val-50);
                        break;
                }
        }
@@ -296,6 +298,18 @@ void MWindow::change_currentautorange(int autogrouptype, int increment, int chan
        }
 }
 
+void MWindow::update_autorange(int type, int increment, int use_max)
+{
+       gui->lock_window("MWindow::update_autorange");
+       int group = Automation::autogrouptype(type, 0);
+       change_currentautorange(group, increment, use_max);
+       int color = GWindowGUI::auto_colors[type];
+       gui->zoombar->update_autozoom(group, color);
+       gui->draw_overlays(0);
+       gui->update_patchbay();
+       gui->flash_canvas(1);
+       gui->unlock_window();
+}
 
 void MWindow::expand_autos(int changeall, int domin, int domax)
 {
@@ -356,17 +370,13 @@ void MWindow::zoom_amp(int64_t zoom_amp)
 void MWindow::zoom_atrack(int64_t zoom)
 {
        int64_t old_zoom = edl->local_session->zoom_atrack;
-// scale waveforms
-       edl->local_session->zoom_y = (int64_t)((float)edl->local_session->zoom_y *
-                       zoom / old_zoom);
-       CLAMP(edl->local_session->zoom_y, MIN_AMP_ZOOM, MAX_AMP_ZOOM);
+       CLAMP(zoom, MIN_TRACK_ZOOM, MAX_TRACK_ZOOM);
+       edl->local_session->zoom_atrack = zoom;
 
-// scale tracks
        edl->local_session->zoom_atrack = zoom;
        for( Track *track= edl->tracks->first; track; track=track->next ) {
                if( track->data_type != TRACK_AUDIO ) continue;
-               track->data_h = track->data_h * zoom / old_zoom;
-               bclamp(track->data_h, MIN_TRACK_ZOOM, MAX_TRACK_ZOOM);
+               track->data_h = zoom;
        }
 // shift row position
        for( int i=0; i<TOTAL_PANES; ++i ) edl->local_session->track_start[i] =
@@ -378,12 +388,12 @@ void MWindow::zoom_atrack(int64_t zoom)
 void MWindow::zoom_vtrack(int64_t zoom)
 {
        int64_t old_zoom = edl->local_session->zoom_vtrack;
-// scale tracks
+       CLAMP(zoom, MIN_TRACK_ZOOM, MAX_TRACK_ZOOM);
        edl->local_session->zoom_vtrack = zoom;
+
        for( Track *track= edl->tracks->first; track; track=track->next ) {
                if( track->data_type != TRACK_VIDEO ) continue;
-               track->data_h = track->data_h * zoom / old_zoom;
-               bclamp(track->data_h, MIN_TRACK_ZOOM, MAX_TRACK_ZOOM);
+               track->data_h = zoom;
        }
 // shift row position
        for( int i=0; i<TOTAL_PANES; ++i ) edl->local_session->track_start[i] =
@@ -660,7 +670,7 @@ int MWindow::nearest_plugin_keyframe(int shift_down, int dir)
        double position = dir == PLAY_FORWARD ? end : start;
        double new_position = dir == PLAY_FORWARD ? start : end;
        for( Track *track=edl->tracks->first; track; track=track->next ) {
-               if( !track->record ) continue;
+               if( !track->is_armed() ) continue;
                for( int i=0; i<track->plugin_set.size(); ++i ) {
                        PluginSet *plugin_set = track->plugin_set[i];
                        int64_t pos = track->to_units(position, 0);
@@ -698,7 +708,7 @@ int MWindow::nearest_auto_keyframe(int shift_down, int dir)
        double position = dir == PLAY_FORWARD ? end : start;
        double new_position = dir == PLAY_FORWARD ? start : end;
        for( Track *track=edl->tracks->first; track; track=track->next ) {
-               if( !track->record ) continue;
+               if( !track->is_armed() ) continue;
                int64_t pos = track->to_units(position, 0);
                for( int i=0; i<AUTOMATION_TOTAL; ++i ) {
                        Autos *autos = track->automation->autos[i];
@@ -760,21 +770,37 @@ int MWindow::find_selection(double position, int scroll_display)
 
 double MWindow::get_position()
 {
-        return edl->local_session->get_selectionstart(1);
+       return edl->local_session->get_selectionstart(1);
 }
 
 void MWindow::set_position(double position)
 {
-        if( position != get_position() ) {
-                if( position < 0 ) position = 0;
-                edl->local_session->set_selectionstart(position);
-                edl->local_session->set_selectionend(position);
-                gui->lock_window();
-                find_cursor();
-                gui->update(1, NORMAL_DRAW, 1, 1, 1, 1, 0);
-                gui->unlock_window();
-                cwindow->update(1, 0, 0, 0, 0);
-        }
+       if( position != get_position() ) {
+               if( position < 0 ) position = 0;
+               edl->local_session->set_selectionstart(position);
+               edl->local_session->set_selectionend(position);
+               gui->lock_window();
+               find_cursor();
+               gui->update(1, NORMAL_DRAW, 1, 1, 1, 1, 0);
+               gui->unlock_window();
+               cwindow->update(1, 0, 0, 0, 0);
+       }
+}
+
+
+double MWindow::get_timecode_offset()
+{
+       return edl->session->timecode_offset;
+}
+
+void MWindow::set_timecode_offset(double offset)
+{
+       edl->session->time_format = TIME_TIMECODE;
+       edl->session->timecode_offset = offset;
+       gui->lock_window();
+       gui->update(1, NORMAL_DRAW, 1, 1, 1, 1, 0);
+       gui->unlock_window();
+       cwindow->update(1, 0, 0, 0, 0);
 }