repeat play, in/out <> shortcuts, append to proj wording, cleanup
authorGood Guy <good1.2guy@gmail.com>
Mon, 5 Feb 2018 18:09:35 +0000 (11:09 -0700)
committerGood Guy <good1.2guy@gmail.com>
Mon, 5 Feb 2018 18:09:35 +0000 (11:09 -0700)
25 files changed:
cinelerra-5.1/cinelerra/commonrender.C
cinelerra-5.1/cinelerra/ctimebar.C
cinelerra-5.1/cinelerra/cwindowgui.C
cinelerra-5.1/cinelerra/cwindowgui.h
cinelerra-5.1/cinelerra/editpanel.C
cinelerra-5.1/cinelerra/editpanel.h
cinelerra-5.1/cinelerra/mtimebar.C
cinelerra-5.1/cinelerra/mtimebar.h
cinelerra-5.1/cinelerra/mwindow.C
cinelerra-5.1/cinelerra/mwindow.h
cinelerra-5.1/cinelerra/mwindowgui.C
cinelerra-5.1/cinelerra/mwindowgui.h
cinelerra-5.1/cinelerra/new.C
cinelerra-5.1/cinelerra/playbackengine.C
cinelerra-5.1/cinelerra/playbackengine.h
cinelerra-5.1/cinelerra/playtransport.C
cinelerra-5.1/cinelerra/playtransport.h
cinelerra-5.1/cinelerra/trackcanvas.C
cinelerra-5.1/cinelerra/transportque.C
cinelerra-5.1/cinelerra/transportque.h
cinelerra-5.1/cinelerra/vtimebar.C
cinelerra-5.1/cinelerra/vwindowgui.C
cinelerra-5.1/cinelerra/vwindowgui.h
cinelerra-5.1/cinelerra/zwindow.C
cinelerra-5.1/cinelerra/zwindow.h

index 856858e58a84a9e1b0fe3c74870bf96a7a18748a..9561737946fab04d1edd9e4ab343874d6bd12db9 100644 (file)
@@ -290,10 +290,6 @@ double CommonRender::fromunits(int64_t position)
 
 int CommonRender::advance_position(int64_t current_render_length)
 {
-       int64_t loop_end = tounits(renderengine->get_edl()->local_session->loop_end, 1);
-       int64_t loop_start = tounits(renderengine->get_edl()->local_session->loop_start, 0);
-       int64_t start_position = tounits(renderengine->command->start_position, 0);
-       int64_t end_position = tounits(renderengine->command->end_position, 1);
        int direction = renderengine->command->get_direction();
 
 // advance the playback position
@@ -302,24 +298,31 @@ int CommonRender::advance_position(int64_t current_render_length)
        else
                current_position += current_render_length;
 
+       int64_t start_position, end_position;
+       int play_loop = renderengine->command->play_loop;
+       int loop_playback = renderengine->get_edl()->local_session->loop_playback;
+       if( play_loop || !loop_playback ) {
+               start_position = tounits(renderengine->command->start_position, 0);
+               end_position = tounits(renderengine->command->end_position, 1);
+       }
+       else {
+               start_position = tounits(renderengine->get_edl()->local_session->loop_start, 0);
+               end_position = tounits(renderengine->get_edl()->local_session->loop_end, 1);
+               play_loop = 1;
+       }
 // test loop again
-       if(renderengine->get_edl()->local_session->loop_playback &&
-               !renderengine->command->infinite)
-       {
-               if(direction == PLAY_REVERSE)
-               {
-                       if(current_position <= loop_start)
-                               current_position = loop_end;
+       if( play_loop && !renderengine->command->infinite ) {
+               if( direction == PLAY_REVERSE ) {
+                       if( current_position <= start_position )
+                               current_position = end_position - (start_position - current_position);
                }
-               else
-               {
-                       if(current_position >= loop_end)
-                               current_position = loop_start + (current_position - loop_end);
+               else {
+                       if( current_position >= end_position )
+                               current_position = start_position + (current_position - end_position);
                }
        }
-       else
+       else {
 // test end of file again
-       {
                if( (direction == PLAY_FORWARD && current_position >= end_position) ||
                        (direction == PLAY_REVERSE && current_position <= start_position) )
                        done = 1;
index 9d786441daa96a2ecb0c88bc0268b7af34f05a4d..b22b4db7ffcf06bfeac8f0cba4eb319c4119e0c5 100644 (file)
@@ -88,13 +88,10 @@ 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 +
index 1c56a6d641e3b70f3f737906fe8c6d794d4a7884..da38d010ef2d36baea86effe871926a2d64d371f 100644 (file)
@@ -473,58 +473,34 @@ int CWindowGUI::keypress_event()
                        lock_window("CWindowGUI::keypress_event 4");
                        break;
                case LEFT:
-                       if(!ctrl_down())
-                       {
-                               if (alt_down())
-                               {
-                                       int shift_down = this->shift_down();
-                                       unlock_window();
-                                       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-
-                                       mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
+                       if( !ctrl_down() ) {
+                               int alt_down = this->alt_down();
+                               int shift_down = this->shift_down();
+                               unlock_window();
+                               stop_transport(0);
+                               mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
+                               if( alt_down )
                                        mwindow->prev_edit_handle(shift_down);
-                                       mwindow->gui->unlock_window();
-
-                                       lock_window("CWindowGUI::keypress_event 1");
-                               }
                                else
-                               {
-                                       unlock_window();
-
-                                       mwindow->gui->lock_window("CWindowGUI::keypress_event 3");
                                        mwindow->move_left();
-                                       mwindow->gui->unlock_window();
-
-                                       lock_window("CWindowGUI::keypress_event 2");
-                               }
+                               mwindow->gui->unlock_window();
+                               lock_window("CWindowGUI::keypress_event 2");
                                result = 1;
                        }
                        break;
                case RIGHT:
-                       if(!ctrl_down())
-                       {
-                               if (alt_down())
-                               {
-                                       int shift_down = this->shift_down();
-                                       unlock_window();
-                                       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-
-                                       mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
+                       if( !ctrl_down() ) {
+                               int alt_down = this->alt_down();
+                               int shift_down = this->shift_down();
+                               unlock_window();
+                               stop_transport(0);
+                               mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
+                               if( alt_down )
                                        mwindow->next_edit_handle(shift_down);
-                                       mwindow->gui->unlock_window();
-
-                                       lock_window("CWindowGUI::keypress_event 2");
-                               }
                                else
-                               {
-                                       unlock_window();
-
-                                       mwindow->gui->lock_window("CWindowGUI::keypress_event 4");
                                        mwindow->move_right();
-                                       mwindow->gui->unlock_window();
-
-                                       lock_window("CWindowGUI::keypress_event 3");
-                               }
+                               mwindow->gui->unlock_window();
+                               lock_window("CWindowGUI::keypress_event 2");
                                result = 1;
                        }
                        break;
@@ -676,6 +652,13 @@ void CWindowGUI::update_meters()
        }
 }
 
+void CWindowGUI::stop_transport(const char *lock_msg)
+{
+       if( lock_msg ) unlock_window();
+       mwindow->stop_transport();
+       if( lock_msg ) lock_window(lock_msg);
+}
+
 
 CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow)
  : EditPanel(mwindow,
index 8ab72ac2c2a0bde800a7e0f442425ec86f32085d..8da0b3b0db221d64c22b5513d3d95f7e574c574e 100644 (file)
@@ -85,6 +85,7 @@ public:
        void keyboard_zoomin();
        void keyboard_zoomout();
        void update_meters();
+       void stop_transport(const char *lock_msg);
 
        MWindow *mwindow;
        CWindow *cwindow;
index c056e2ebbec836635550ebefa9f774a918bed480..9714c4beafa65ac072a8bdd3aca29281693f1f55 100644 (file)
@@ -329,6 +329,13 @@ SET_TRACE
 SET_TRACE
 }
 
+void EditPanel::stop_transport(const char *lock_msg)
+{
+       int have_subwindow_lock = subwindow->get_window_lock();
+       if( have_subwindow_lock ) subwindow->unlock_window();
+       mwindow->stop_transport();
+       if( have_subwindow_lock ) subwindow->lock_window(lock_msg);
+}
 
 
 void EditPanel::toggle_label()
@@ -340,29 +347,17 @@ void EditPanel::prev_label()
 {
        int shift_down = subwindow->shift_down();
        int snap = subwindow->ctrl_down() && subwindow->alt_down();
-
        int have_mwindow_lock = mwindow->gui->get_window_lock();
-       int have_subwindow_lock =
-                subwindow->get_top_level() == mwindow->gui->get_top_level() ?
-                        0 : subwindow->get_window_lock();
-       if(have_mwindow_lock)
-               mwindow->gui->unlock_window();
-       if(have_subwindow_lock)
-               subwindow->unlock_window();
-
-       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
+       if( have_mwindow_lock ) mwindow->gui->unlock_window();
 
-       if(have_subwindow_lock)
-               subwindow->lock_window("EditPanel::prev_label 1");
+       stop_transport("EditPanel::prev_label 1");
 
        mwindow->gui->lock_window("EditPanel::prev_label 2");
-
        if( snap )
                mwindow->snap_left_label();
        else
                mwindow->prev_label(shift_down);
-
-       if(!have_mwindow_lock)
+       if( !have_mwindow_lock )
                mwindow->gui->unlock_window();
 }
 
@@ -370,29 +365,17 @@ void EditPanel::next_label()
 {
        int shift_down = subwindow->shift_down();
        int snap = subwindow->ctrl_down() && subwindow->alt_down();
-
        int have_mwindow_lock = mwindow->gui->get_window_lock();
-       int have_subwindow_lock =
-                subwindow->get_top_level() == mwindow->gui->get_top_level() ?
-                        0 : subwindow->get_window_lock();
-       if(have_mwindow_lock)
-               mwindow->gui->unlock_window();
-       if(have_subwindow_lock)
-               subwindow->unlock_window();
-
-       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
+       if( have_mwindow_lock ) mwindow->gui->unlock_window();
 
-       if(have_subwindow_lock)
-               subwindow->lock_window("EditPanel::next_label 1");
+       stop_transport("EditPanel::next_label 1");
 
        mwindow->gui->lock_window("EditPanel::next_label 2");
-
        if( snap )
                mwindow->snap_right_label();
        else
                mwindow->next_label(shift_down);
-
-       if(!have_mwindow_lock)
+       if( !have_mwindow_lock )
                mwindow->gui->unlock_window();
 }
 
@@ -402,20 +385,10 @@ void EditPanel::prev_edit()
 {
        int shift_down = subwindow->shift_down();
        int snap = subwindow->ctrl_down() && subwindow->alt_down();
-
        int have_mwindow_lock = mwindow->gui->get_window_lock();
-       int have_subwindow_lock =
-                subwindow->get_top_level() == mwindow->gui->get_top_level() ?
-                        0 : subwindow->get_window_lock();
-       if(have_mwindow_lock)
-               mwindow->gui->unlock_window();
-       if(have_subwindow_lock)
-               subwindow->unlock_window();
-
-       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
+       if( have_mwindow_lock ) mwindow->gui->unlock_window();
 
-       if(have_subwindow_lock)
-               subwindow->lock_window("EditPanel::prev_edit 1");
+       stop_transport("EditPanel::prev_edit 1");
 
        mwindow->gui->lock_window("EditPanel::prev_edit 2");
 
@@ -424,7 +397,7 @@ void EditPanel::prev_edit()
        else
                mwindow->prev_edit_handle(shift_down);
 
-       if(!have_mwindow_lock)
+       if( !have_mwindow_lock )
                mwindow->gui->unlock_window();
 }
 
@@ -432,20 +405,10 @@ void EditPanel::next_edit()
 {
        int shift_down = subwindow->shift_down();
        int snap = subwindow->ctrl_down() && subwindow->alt_down();
-
        int have_mwindow_lock = mwindow->gui->get_window_lock();
-       int have_subwindow_lock =
-                subwindow->get_top_level() == mwindow->gui->get_top_level() ?
-                        0 : subwindow->get_window_lock();
-       if(have_mwindow_lock)
-               mwindow->gui->unlock_window();
-       if(have_subwindow_lock)
-               subwindow->unlock_window();
-
-       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
+       if( have_mwindow_lock ) mwindow->gui->unlock_window();
 
-       if(have_subwindow_lock)
-               subwindow->lock_window("EditPanel::next_edit 1");
+       stop_transport("EditPanel::next_edit 1");
 
        mwindow->gui->lock_window("EditPanel::next_edit 2");
 
@@ -454,7 +417,7 @@ void EditPanel::next_edit()
        else
                mwindow->next_edit_handle(shift_down);
 
-       if(!have_mwindow_lock)
+       if( !have_mwindow_lock )
                mwindow->gui->unlock_window();
 }
 
@@ -669,9 +632,9 @@ int EditInPoint::handle_event()
 }
 int EditInPoint::keypress_event()
 {
-       if(get_keypress() == '[')
-       {
-               panel->set_inpoint();
+       int key = get_keypress();
+       if( key == '[' || key == '<' ) {
+                panel->set_inpoint();
                return 1;
        }
        if(ctrl_down() && get_keypress() == 't')
@@ -699,8 +662,8 @@ int EditOutPoint::handle_event()
 }
 int EditOutPoint::keypress_event()
 {
-       if(get_keypress() == ']')
-       {
+       int key = get_keypress();
+       if( key == ']' || key == '>' ) {
                panel->set_outpoint();
                return 1;
        }
index 054f6930b8d1cdd10e793daccdc59a16d7a9c286..c2b5de1e36b29f5fb355a087f650255ff68e9134 100644 (file)
@@ -432,6 +432,7 @@ public:
        static int calculate_h(MWindow *mwindow);
        void update();
        void create_buttons();
+       void stop_transport(const char *lock_msg);
        void reposition_buttons(int x, int y);
        void create_objects();
        int get_w();
index 5fa6e4c845fdc5c063b4e980ffdb61f3d551f62b..94e7f2d1c2bac9f4aee689ce49234c9e9c81b4b8 100644 (file)
@@ -96,11 +96,9 @@ int64_t MTimeBar::position_to_pixel(double position)
 }
 
 
-void MTimeBar::stop_playback()
+void MTimeBar::stop_transport()
 {
-       gui->unlock_window();
-       gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-       gui->lock_window();
+       gui->stop_transport("MTimeBar::stop_transport");
 }
 
 #define TEXT_MARGIN 4
@@ -455,13 +453,10 @@ void MTimeBar::draw_range()
 
 void MTimeBar::select_label(double position)
 {
-       EDL *edl = mwindow->edl;
-
-       gui->unlock_window();
-       gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-       gui->lock_window();
+       stop_transport();
 
-       position = mwindow->edl->align_to_frame(position, 1);
+       EDL *edl = mwindow->edl;
+       position = edl->align_to_frame(position, 1);
 
        if(shift_down())
        {
index d2825f739e4c70c0e02d9df839acbf3d7a2c87c8..8f17884402609ceb19bb26d2bfb0d43645a58170 100644 (file)
@@ -78,7 +78,7 @@ public:
        void create_objects();
        void draw_time();
        void draw_range();
-       void stop_playback();
+       void stop_transport();
        int resize_event();
        int resize_event(int x, int y, int w, int h);
        int button_press_event();
index d14f228c14754e29d1f26826bbd824636d5f3d9f..53b5a1937b5bfca4ff1b8bc3b07264e509f26771 100644 (file)
@@ -1217,7 +1217,7 @@ void MWindow::update_mixer_tracks()
 }
 
 void MWindow::queue_mixers(EDL *edl, int command, int wait_tracking,
-               int use_inout, int update_refresh, int toggle_audio)
+               int use_inout, int update_refresh, int toggle_audio, int loop_play)
 {
        zwindows_lock->lock("MWindow::queue_mixers");
        for( int vidx=0; vidx<zwindows.size(); ++vidx ) {
@@ -1249,14 +1249,14 @@ void MWindow::queue_mixers(EDL *edl, int command, int wait_tracking,
                }
                zwindow->change_source(mixer_edl);
                zwindow->issue_command(command,
-                       wait_tracking, use_inout, update_refresh, toggle_audio);
+                       wait_tracking, use_inout, update_refresh, toggle_audio, loop_play);
        }
        zwindows_lock->unlock();
 }
 
 void MWindow::refresh_mixers()
 {
-       queue_mixers(edl,CURRENT_FRAME,0,0,1,0);
+       queue_mixers(edl,CURRENT_FRAME,0,0,1,0,0);
 }
 
 void MWindow::stop_mixers()
@@ -1264,7 +1264,7 @@ void MWindow::stop_mixers()
        for( int vidx=0; vidx<zwindows.size(); ++vidx ) {
                ZWindow *zwindow = zwindows[vidx];
                if( zwindow->idx < 0 ) continue;
-               zwindow->issue_command(STOP, 0, 0, 0, 0);
+               zwindow->issue_command(STOP, 0, 0, 0, 0, 0);
        }
 }
 
@@ -1723,6 +1723,11 @@ void MWindow::stop_playback(int wait)
        }
 }
 
+void MWindow::stop_transport()
+{
+       gui->stop_transport(gui->get_window_lock() ? "MWindow::stop_transport" : 0);
+}
+
 int MWindow::load_filenames(ArrayList<char*> *filenames,
        int load_mode,
        int update_filename)
index 31c5be709d439ce210db37cf4291392a7536488a..b42081bf513f4ad1a1c44c23895639d1206f2377 100644 (file)
@@ -204,9 +204,10 @@ public:
        static int plugin_exists(char *plugin_path);
        void dump_plugindb(FILE *fp);
        void stop_playback(int wait);
+       void stop_transport();
 
        void queue_mixers(EDL *edl, int command, int wait_tracking,
-               int use_inout, int update_refresh, int toggle_audio);
+               int use_inout, int update_refresh, int toggle_audio, int loop_play);
        void create_mixers();
        void refresh_mixers();
        void stop_mixers();
index 613c0324a8c5033b5c23aba53b09efb643597a19..ec33eba7b24fe9e4998bc968fe48be937d5f2784 100644 (file)
@@ -1170,9 +1170,7 @@ int MWindowGUI::keypress_event()
 
        case 'k': case 'K':
                if( alt_down() ) break;
-               unlock_window();
-               mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-               lock_window("MWindowGUI::keypress_event 1");
+               stop_transport("MWindowGUI::keypress_event 1");
                mwindow->nearest_plugin_keyframe(shift_down(),
                        !ctrl_down() ? PLAY_FORWARD : PLAY_REVERSE);
                result = 1;
@@ -1188,9 +1186,7 @@ int MWindowGUI::keypress_event()
        case LEFT:
                if( !ctrl_down() ) {
                        if( alt_down() ) {
-                               unlock_window();
-                               mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-                               lock_window("MWindowGUI::keypress_event 1");
+                               stop_transport("MWindowGUI::keypress_event 1");
                                mwindow->prev_edit_handle(shift_down());
                        }
                        else
@@ -1202,9 +1198,7 @@ int MWindowGUI::keypress_event()
        case RIGHT:
                if( !ctrl_down() ) {
                        if( alt_down() ) {
-                               unlock_window();
-                               mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-                               lock_window("MWindowGUI::keypress_event 2");
+                               stop_transport("MWindowGUI::keypress_event 2");
                                mwindow->next_edit_handle(shift_down());
                        }
                        else
@@ -2263,6 +2257,15 @@ void MWindowGUI::update_mixers(Track *track, int v)
        }
 }
 
+void MWindowGUI::stop_transport(const char *lock_msg)
+{
+       if( !mbuttons->transport->is_stopped() ) {
+               if( lock_msg ) unlock_window();
+               mbuttons->transport->handle_transport(STOP, 1, 0, 0);
+               if( lock_msg ) lock_window(lock_msg);
+       }
+}
+
 PaneButton::PaneButton(MWindow *mwindow, int x, int y)
  : BC_Button(x, y, mwindow->theme->get_image_set("pane"))
 {
index 4eb54cf0a41c02e6a63fe483155bfff32160f2d1..a40e44460cafbf5ea1bfb5bc76c595bddac60f05 100644 (file)
@@ -129,6 +129,7 @@ public:
        void set_editing_mode(int flush);
        void set_meter_format(int mode, int min, int max);
        void update_mixers(Track *track, int v);
+       void stop_transport(const char *lock_msg);
 
        int translation_event();
        int resize_event(int w, int h);          // handle a resize event
index 605be8684e3022ba5da3b42ca2120f49ec8e82a3..1fa0f15e6d03e55c960c2079fa0d1334713c4cb9 100644 (file)
@@ -259,7 +259,9 @@ void NewWindow::create_objects()
        lock_window("NewWindow::create_objects");
        mwindow->theme->draw_new_bg(this);
 
-       add_subwindow(new BC_Title(x, y, _("Parameters for the new project:")));
+       add_subwindow( new BC_Title(x, y, new_thread->load_mode == LOADMODE_REPLACE ?
+                       _("Parameters for the new project:") :
+                       _("Parameters for additional tracks:") ) );
        y += 20;
 
        format_presets = new NewPresets(mwindow,
@@ -347,7 +349,7 @@ void NewWindow::create_objects()
 //     y += canvas_h_text->get_h() + 5;
 
        x1 = x;
-       add_subwindow(new BC_Title(x1, y, _("Canvas size:")));
+       add_subwindow(new BC_Title(x1, y, _("Track size:")));
        x1 += 115;
        add_subwindow(output_w_text = new NewOutputW(this, x1, y));
        x1 += output_w_text->get_w() + 2;
index 1d3a4115cef058b279ff5f1790b6d30d2ed64064..b0c9fe3e1258bc81eaece7a2b73c7b9a0062cb81 100644 (file)
@@ -293,12 +293,22 @@ double PlaybackEngine::get_tracking_position()
                else
 // Interpolate
                {
-                       double loop_start = command->get_edl()->local_session->loop_start;
-                       double loop_end = command->get_edl()->local_session->loop_end;
+                       double loop_start, loop_end;
+                       int play_loop = command->play_loop ? 1 : 0;
+                       EDL *edl = command->get_edl();
+                       int loop_playback = edl->local_session->loop_playback ? 1 : 0;
+                       if( play_loop || !loop_playback ) {
+                               loop_start = command->start_position;
+                               loop_end = command->end_position;
+                       }
+                       else {
+                               loop_start = edl->local_session->loop_start;
+                               loop_end = edl->local_session->loop_end;
+                               play_loop = 1;
+                       }
                        double loop_size = loop_end - loop_start;
 
-                       if(command->get_direction() == PLAY_FORWARD)
-                       {
+                       if( command->get_direction() == PLAY_FORWARD ) {
 // Interpolate
                                result = tracking_position +
                                        command->get_speed() *
@@ -307,13 +317,11 @@ double PlaybackEngine::get_tracking_position()
 
 // Compensate for loop
 //printf("PlaybackEngine::get_tracking_position 1 %d\n", command->get_edl()->local_session->loop_playback);
-                               if(command->get_edl()->local_session->loop_playback)
-                               {
-                                       while(result > loop_end) result -= loop_size;
+                               if( play_loop && loop_size > 0 ) {
+                                       while( result > loop_end ) result -= loop_size;
                                }
                        }
-                       else
-                       {
+                       else {
 // Interpolate
                                result = tracking_position -
                                        command->get_speed() *
@@ -321,9 +329,8 @@ double PlaybackEngine::get_tracking_position()
                                        1000.0;
 
 // Compensate for loop
-                               if(command->get_edl()->local_session->loop_playback)
-                               {
-                                       while(result < loop_start) result += loop_size;
+                               if( play_loop && loop_size > 0 ) {
+                                       while( result < loop_start ) result += loop_size;
                                }
                        }
 
@@ -427,9 +434,9 @@ void PlaybackEngine::stop_playback(int wait)
 
 
 void PlaybackEngine::issue_command(EDL *edl, int command, int wait_tracking,
-               int use_inout, int update_refresh, int toggle_audio)
+               int use_inout, int update_refresh, int toggle_audio, int loop_play)
 {
-//printf("PlayTransport::handle_transport 1 %d\n", command);
+//printf("PlaybackEngine::issue_command 1 %d\n", command);
 // Stop requires transferring the output buffer to a refresh buffer.
        int do_stop = 0, resume = 0;
        int prev_command = this->command->command;
@@ -470,7 +477,7 @@ void PlaybackEngine::issue_command(EDL *edl, int command, int wait_tracking,
                case SINGLE_FRAME_REWIND:
 // Start from scratch
                        que->send_command(command, CHANGE_NONE, edl,
-                               1, resume, use_inout, toggle_audio,
+                               1, resume, use_inout, toggle_audio, loop_play,
                                mwindow->preferences->forward_render_displacement);
                        break;
                }
index 2fd071677bb52b19157781f6c1c04b459c4429df..f4ce015726e97587694bb513c9b5103fcc3b3cb7 100644 (file)
@@ -83,7 +83,7 @@ public:
        void run();
        void stop_playback(int wait);
        void issue_command(EDL *edl, int command, int wait_tracking,
-               int use_inout, int update_refresh, int toggle_audio);
+               int use_inout, int update_refresh, int toggle_audio, int loop_play);
        void refresh_frame(int change_type, EDL *edl);
 
 // Maintain caches through console changes
index c7334213e7f3c13e68463cfa668faba41041c460..966d299d9f621aba207e8d1f537f5436bf932659 100644 (file)
@@ -129,6 +129,11 @@ int PlayTransport::get_w()
        return end_button->get_x() + end_button->get_w() - rewind_button->get_x();
 }
 
+int PlayTransport::is_stopped()
+{
+       return engine->command->command == STOP ? 1 : 0;
+}
+
 int PlayTransport::flip_vertical(int vertical, int &x, int &y)
 {
        if(vertical)
@@ -195,10 +200,13 @@ int PlayTransport::do_keypress(int key)
                goto_end();
                return result;
        }
-
-       int toggle_audio = subwindow->shift_down() ? 1 : 0;
-       int use_inout = subwindow->ctrl_down() ? 1 : 0;
+// as in play_command
+       int ctrl_key = subwindow->ctrl_down() ? 1 : 0;
+       int shft_key = subwindow->shift_down() ? 1 : 0;
        int alt_key = subwindow->alt_down() ? 1 : 0;
+       int use_inout = ctrl_key;
+       int toggle_audio = shft_key & ~ctrl_key;
+       int loop_play = shft_key & ctrl_key;
        int command = -1, prev_command = engine->command->command;
        using_inout = use_inout;
        subwindow->unlock_window();
@@ -256,7 +264,7 @@ int PlayTransport::do_keypress(int key)
                break;
        }
        if( command >= 0 ) {
-               handle_transport(command, 0, use_inout, 1, toggle_audio);
+               handle_transport(command, 0, use_inout, 1, toggle_audio, loop_play);
                result = 1;
        }
 
@@ -277,14 +285,14 @@ void PlayTransport::goto_end()
 
 
 
-void PlayTransport::handle_transport(int command,
-       int wait_tracking, int use_inout, int update_refresh, int toggle_audio)
+void PlayTransport::handle_transport(int command, int wait_tracking, int use_inout,
+               int update_refresh, int toggle_audio, int loop_play)
 {
        EDL *edl = get_edl();
        if( !edl ) return;
        if( !is_vwindow() )
-               mwindow->queue_mixers(edl, command, wait_tracking, use_inout, update_refresh, toggle_audio);
-       engine->issue_command(edl, command, wait_tracking, use_inout, update_refresh, toggle_audio);
+               mwindow->queue_mixers(edl, command, wait_tracking, use_inout, update_refresh, toggle_audio, 0);
+       engine->issue_command(edl, command, wait_tracking, use_inout, update_refresh, toggle_audio, loop_play);
 }
 
 EDL* PlayTransport::get_edl()
@@ -327,6 +335,19 @@ int PTransportButton::set_mode(int mode)
        return 0;
 }
 
+int PTransportButton::play_command(const char *lock_msg, int command)
+{
+       int ctrl_key = transport->subwindow->ctrl_down() ? 1 : 0;
+       int shft_key = transport->subwindow->shift_down() ? 1 : 0;
+       int use_inout = ctrl_key;
+       int toggle_audio = shft_key & ~ctrl_key;
+       int loop_play = shft_key & ctrl_key;
+       unlock_window();
+       transport->handle_transport(command, 0, use_inout, 0, toggle_audio, loop_play);
+       lock_window(lock_msg);
+       return 1;
+}
+
 
 RewindButton::RewindButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
  : PTransportButton(mwindow, transport, x, y, mwindow->theme->get_image_set("rewind"))
@@ -348,10 +369,7 @@ FastReverseButton::FastReverseButton(MWindow *mwindow, PlayTransport *transport,
 }
 int FastReverseButton::handle_event()
 {
-       unlock_window();
-       transport->handle_transport(FAST_REWIND, 0, ctrl_down());
-       lock_window("FastReverseButton::handle_event");
-       return 1;
+       return play_command("FastReverseButton::handle_event", FAST_REWIND);
 }
 
 // Reverse playback normal speed
@@ -363,10 +381,7 @@ ReverseButton::ReverseButton(MWindow *mwindow, PlayTransport *transport, int x,
 }
 int ReverseButton::handle_event()
 {
-       unlock_window();
-       transport->handle_transport(NORMAL_REWIND, 0, ctrl_down());
-       lock_window("ReverseButton::handle_event");
-       return 1;
+       return play_command("ReverseButton::handle_event", NORMAL_REWIND);
 }
 
 // Reverse playback one frame
@@ -393,10 +408,7 @@ PlayButton::PlayButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
 }
 int PlayButton::handle_event()
 {
-       unlock_window();
-       transport->handle_transport(NORMAL_FWD, 0, ctrl_down());
-       lock_window("PlayButton::handle_event");
-       return 1;
+       return play_command("PlayButton::handle_event", NORMAL_FWD);
 }
 
 
@@ -425,10 +437,7 @@ FastPlayButton::FastPlayButton(MWindow *mwindow, PlayTransport *transport, int x
 }
 int FastPlayButton::handle_event()
 {
-       unlock_window();
-       transport->handle_transport(FAST_FWD, 0, ctrl_down());
-       lock_window("FastPlayButton::handle_event");
-       return 1;
+       return play_command("FastPlayButton::handle_event", FAST_FWD);
 }
 
 EndButton::EndButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
index 62d1973aff2e440da366473f27d86e3a0399a3dc..0a60e2231a3617c2a12d702400cff6ac72a52e95 100644 (file)
@@ -58,11 +58,14 @@ public:
 // update_refresh - causes a frame advance to be issued after STOP to update
 // the refresh frame.
 // toggle_audio - reverses audio playback enable in RenderEngine::get_duty
+// loop_play - sets play_loop and plays btwn start/end position (in a loop)
        void handle_transport(int command, int wait_tracking=0,
-               int use_inout=0, int update_refresh=1, int toggle_audio=0);
+               int use_inout=0, int update_refresh=1, int toggle_audio=0,
+               int loop_play=0);
        int pause_transport();
        int reset_transport();
        int get_w();
+       int is_stopped();
 // Get the EDL to play back with default to mwindow->edl
        virtual EDL* get_edl();
        void change_position(double position);
@@ -98,6 +101,7 @@ public:
        PTransportButton(MWindow *mwindow, PlayTransport *transport, int x, int y, VFrame **data);
        virtual ~PTransportButton();
        virtual int set_mode(int mode);
+       int play_command(const char *lock_msg, int command);
 
        int mode;
        MWindow *mwindow;
index f4dd1916b643c8a6e1f89ec2d193f6b41d128713..35c773b084501bf451c3da5b05dcde58b60efcc2 100644 (file)
@@ -4822,11 +4822,8 @@ int TrackCanvas::button_press_event()
                        activate();
                }
 
-               if( get_buttonpress() == LEFT_BUTTON &&
-                   gui->mbuttons->transport->engine->command->command != STOP ) {
-                       gui->unlock_window();
-                       gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-                       gui->lock_window("TrackCanvas::button_press_event");
+               if( get_buttonpress() == LEFT_BUTTON ) {
+                       gui->stop_transport("TrackCanvas::button_press_event");
                }
 
                int update_overlay = 0, update_cursor = 0, rerender = 0;
index a2a5160a1dade23ebeb0116df585d8379da7b5ed..816e81a41d558f8268d8d08f59492e0f144ea5d1 100644 (file)
@@ -53,6 +53,7 @@ void TransportCommand::reset()
        realtime = 0;
        resume = 0;
        audio_toggle = 0;
+       play_loop = 0;
        displacement = 0;
 // Don't reset the change type for commands which don't perform the change
        if(command != STOP) change_type = 0;
@@ -88,6 +89,7 @@ void TransportCommand::copy_from(TransportCommand *command)
        this->realtime = command->realtime;
        this->resume = command->resume;
        this->audio_toggle = command->audio_toggle;
+       this->play_loop = command->play_loop;
        this->displacement = command->displacement;
 }
 
@@ -163,37 +165,33 @@ float TransportCommand::get_speed()
 
 // Assume starting without pause
 void TransportCommand::set_playback_range(EDL *edl,
-       int use_inout, int toggle_audio, int use_displacement)
+       int use_inout, int toggle_audio, int loop_play, int use_displacement)
 {
        if(!edl) edl = this->edl;
-
        double length = edl->tracks->total_playable_length();
        double frame_period = 1.0 / edl->session->frame_rate;
-       double start = edl->local_session->get_selectionstart(1);
-       double end = edl->local_session->get_selectionend(1);
 
        displacement = 0;
-       if( use_inout ) {
-               if( edl->local_session->inpoint_valid() )
-                       start_position = edl->local_session->get_inpoint();
-               if( edl->local_session->outpoint_valid() )
-                       end_position = edl->local_session->get_outpoint();
-       }
-       else if( !EQUIV(start, end) ) {
-               start_position = start;
-               end_position = end;
-       }
-       else {
-// starting play at or past end, play to end of media (for mixers)
-               if( start >= length )
+       audio_toggle = toggle_audio;
+       play_loop = loop_play;
+
+       start_position = use_inout && edl->local_session->inpoint_valid() ?
+               edl->local_session->get_inpoint() :
+               !loop_play ? edl->local_session->get_selectionstart(1) : 0;
+       end_position = use_inout && edl->local_session->outpoint_valid() ?
+               edl->local_session->get_outpoint() :
+               !loop_play ? edl->local_session->get_selectionend(1) : length;
+
+       if( !use_inout && EQUIV(start_position, end_position) ) {
+// starting play at or past end_position, play to end_position of media (for mixers)
+               if( start_position >= length )
                        length = edl->tracks->total_length();
                switch( command ) {
                case SLOW_FWD:
                case FAST_FWD:
                case NORMAL_FWD: {
-                       start_position = start;
                        end_position = length;
-// this prevents a crash if start position is after the loop when playing forwards
+// this prevents a crash if start_position position is after the loop when playing forwards
                        if( edl->local_session->loop_playback &&
                            start_position > edl->local_session->loop_end ) {
                                start_position = edl->local_session->loop_start;
@@ -203,9 +201,8 @@ void TransportCommand::set_playback_range(EDL *edl,
                case SLOW_REWIND:
                case FAST_REWIND:
                case NORMAL_REWIND:
-                       end_position = end;
                        start_position = 0;
-// this prevents a crash if start position is before the loop when playing backwards
+// this prevents a crash if start_position position is before the loop when playing backwards
                        if( edl->local_session->loop_playback &&
                            end_position <= edl->local_session->loop_start ) {
                                        end_position = edl->local_session->loop_end;
@@ -214,12 +211,10 @@ void TransportCommand::set_playback_range(EDL *edl,
 
                case CURRENT_FRAME:
                case SINGLE_FRAME_FWD:
-                       start_position = start;
                        end_position = start_position + frame_period;
                        break;
 
                case SINGLE_FRAME_REWIND:
-                       end_position = end;
                        start_position = end_position - frame_period;
                        break;
                }
@@ -232,8 +227,11 @@ void TransportCommand::set_playback_range(EDL *edl,
                }
        }
 
-       playbackstart = get_direction() == PLAY_FORWARD ? start_position : end_position;
-       audio_toggle = toggle_audio;
+       if( end_position < start_position )
+               end_position = start_position;
+
+       playbackstart = get_direction() == PLAY_FORWARD ?
+               start_position : end_position;
 }
 
 void TransportCommand::playback_range_adjust_inout()
@@ -287,8 +285,8 @@ TransportQue::~TransportQue()
 }
 
 int TransportQue::send_command(int command, int change_type,
-               EDL *new_edl, int realtime, int resume,
-               int use_inout, int toggle_audio, int use_displacement)
+               EDL *new_edl, int realtime, int resume, int use_inout,
+               int toggle_audio, int loop_play, int use_displacement)
 {
        input_lock->lock("TransportQue::send_command 1");
        this->command.command = command;
@@ -315,8 +313,8 @@ int TransportQue::send_command(int command, int change_type,
                }
 
 // Set playback range
-               this->command.set_playback_range(new_edl,
-                       use_inout, toggle_audio, use_displacement);
+               this->command.set_playback_range(new_edl, use_inout,
+                               toggle_audio, loop_play, use_displacement);
        }
 
        input_lock->unlock();
index 7d0c181912f6b7dbc0a9fd929443c92d926d2a12..1f5f9c63a700417df6e3fd213db7dd5feb6ba716 100644 (file)
@@ -45,8 +45,8 @@ public:
        void copy_from(TransportCommand *command);
        TransportCommand& operator=(TransportCommand &command);
 // Get the range to play back from the EDL
-       void set_playback_range(EDL *edl=0,
-               int use_inout=0, int toggle_audio=0, int use_displacement=0);
+       void set_playback_range(EDL *edl=0, int use_inout=0,
+               int toggle_audio=0, int loop_play=0, int use_displacement=0);
 
 // Adjust playback range with in/out points for rendering
        void playback_range_adjust_inout();
@@ -77,7 +77,8 @@ public:
        int resume;
 // reverse audio duty
        int audio_toggle;
-
+// playback loop
+       int play_loop;
 private:
 // Copied to render engines
        EDL *edl;
@@ -91,14 +92,10 @@ public:
 
        int send_command(int command,
 // The change type is ORed to accumulate changes.
-               int change_type,
-               EDL *new_edl,
-               int realtime,
+               int change_type, EDL *new_edl, int realtime,
 // Persistent starting point
-               int resume = 0,
-               int use_inout = 0,
-               int toggle_audio = 0,
-               int use_displacement = 0);
+               int resume = 0, int use_inout = 0, int toggle_audio = 0,
+               int loop_play = 0, int use_displacement = 0);
        void update_change_type(int change_type);
 
        TransportCommand command;
index d1aa168d21bf09769862e52f497d72ae95fa7ede..b61f25f63f1710fe226bdf5855161ba3b4aa7cec 100644 (file)
@@ -68,12 +68,8 @@ 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);
 
index 931b0d3e1a18c101b576b360ab4fd89ba594f790..4458eb764c80ba1bf608fd1e25f80f5284a1c9c4 100644 (file)
@@ -352,22 +352,26 @@ int VWindowGUI::keypress_event()
        return result;
 }
 
+void VWindowGUI::stop_transport(const char *lock_msg)
+{
+       if( !transport->is_stopped() ) {
+               if( lock_msg ) unlock_window();
+               transport->handle_transport(STOP, 1, 0, 0);
+               if( lock_msg ) lock_window(lock_msg);
+       }
+}
+
 int VWindowGUI::button_press_event()
 {
        if( get_buttonpress() == LEFT_BUTTON && canvas->get_canvas() &&
            canvas->get_canvas()->get_cursor_over_window() ) {
-               int command = STOP;
                PlaybackEngine *playback_engine = vwindow->playback_engine;
                if( !playback_engine->is_playing_back && vwindow->get_edl() != 0 ) {
                        double length = vwindow->get_edl()->tracks->total_playable_length();
                        double position = playback_engine->get_tracking_position();
                        if( position >= length ) transport->goto_start();
-                       command = NORMAL_FWD;
                }
-               unlock_window();
-               transport->handle_transport(command, 1);
-               lock_window("VWindowGUI::button_press_event");
-               return 1;
+               return transport->forward_play->handle_event();
        }
        if(canvas->get_canvas())
                return canvas->button_press_event_base(canvas->get_canvas());
index 5dcdc78471636b5734c061d61f890d0d7ab353d4..039067e9769379441f421cba23f4fc391ebb2e7c 100644 (file)
@@ -56,6 +56,7 @@ public:
        int resize_event(int w, int h);
        int translation_event();
        int close_event();
+       void stop_transport(const char *lock_msg);
        int keypress_event();
        int button_press_event();
        int cursor_leave_event();
index 80234ca0a77d96098f59a5a31ff96a4cd815538b..5743aa40ab577c0bf5b1dc8140d3e783ce31ddbe 100644 (file)
@@ -229,10 +229,10 @@ void ZWindow::stop_playback(int wait)
 }
 
 void ZWindow::issue_command(int command, int wait_tracking,
-               int use_inout, int update_refresh, int toggle_audio)
+               int use_inout, int update_refresh, int toggle_audio, int loop_play)
 {
        zgui->playback_engine->issue_command(edl, command,
-                       wait_tracking, use_inout, update_refresh, toggle_audio);
+                       wait_tracking, use_inout, update_refresh, toggle_audio, loop_play);
 }
 
 void ZWindow::update_mixer_ids()
index 528d576dd0f7c8b7b19c122e484fcae86e2dfd08..ac8f04dc44ee95a38250d4419b1b0b96deba584b 100644 (file)
@@ -71,8 +71,8 @@ public:
        void handle_close_event(int result);
        void change_source(EDL *edl);
        void stop_playback(int wait);
-       void issue_command(int command, int wait_tracking,
-               int use_inout, int update_refresh, int toggle_audio);
+       void issue_command(int command, int wait_tracking, int use_inout,
+                       int update_refresh, int toggle_audio, int loop_play);
        void update_mixer_ids();
        void set_title(const char *tp);
        void reposition(int x, int y, int w, int h);