From: Good Guy Date: Mon, 5 Feb 2018 18:09:35 +0000 (-0700) Subject: repeat play, in/out <> shortcuts, append to proj wording, cleanup X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=60f8df69db9ddd8148bfc41a17bb0955b52a45e6;p=goodguy%2Fhistory.git repeat play, in/out <> shortcuts, append to proj wording, cleanup --- diff --git a/cinelerra-5.1/cinelerra/commonrender.C b/cinelerra-5.1/cinelerra/commonrender.C index 856858e5..95617379 100644 --- a/cinelerra-5.1/cinelerra/commonrender.C +++ b/cinelerra-5.1/cinelerra/commonrender.C @@ -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; diff --git a/cinelerra-5.1/cinelerra/ctimebar.C b/cinelerra-5.1/cinelerra/ctimebar.C index 9d786441..b22b4db7 100644 --- a/cinelerra-5.1/cinelerra/ctimebar.C +++ b/cinelerra-5.1/cinelerra/ctimebar.C @@ -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 + diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index 1c56a6d6..da38d010 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -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, diff --git a/cinelerra-5.1/cinelerra/cwindowgui.h b/cinelerra-5.1/cinelerra/cwindowgui.h index 8ab72ac2..8da0b3b0 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.h +++ b/cinelerra-5.1/cinelerra/cwindowgui.h @@ -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; diff --git a/cinelerra-5.1/cinelerra/editpanel.C b/cinelerra-5.1/cinelerra/editpanel.C index c056e2eb..9714c4be 100644 --- a/cinelerra-5.1/cinelerra/editpanel.C +++ b/cinelerra-5.1/cinelerra/editpanel.C @@ -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; } diff --git a/cinelerra-5.1/cinelerra/editpanel.h b/cinelerra-5.1/cinelerra/editpanel.h index 054f6930..c2b5de1e 100644 --- a/cinelerra-5.1/cinelerra/editpanel.h +++ b/cinelerra-5.1/cinelerra/editpanel.h @@ -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(); diff --git a/cinelerra-5.1/cinelerra/mtimebar.C b/cinelerra-5.1/cinelerra/mtimebar.C index 5fa6e4c8..94e7f2d1 100644 --- a/cinelerra-5.1/cinelerra/mtimebar.C +++ b/cinelerra-5.1/cinelerra/mtimebar.C @@ -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()) { diff --git a/cinelerra-5.1/cinelerra/mtimebar.h b/cinelerra-5.1/cinelerra/mtimebar.h index d2825f73..8f178844 100644 --- a/cinelerra-5.1/cinelerra/mtimebar.h +++ b/cinelerra-5.1/cinelerra/mtimebar.h @@ -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(); diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index d14f228c..53b5a193 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -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; vidxchange_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; vidxidx < 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 *filenames, int load_mode, int update_filename) diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h index 31c5be70..b42081bf 100644 --- a/cinelerra-5.1/cinelerra/mwindow.h +++ b/cinelerra-5.1/cinelerra/mwindow.h @@ -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(); diff --git a/cinelerra-5.1/cinelerra/mwindowgui.C b/cinelerra-5.1/cinelerra/mwindowgui.C index 613c0324..ec33eba7 100644 --- a/cinelerra-5.1/cinelerra/mwindowgui.C +++ b/cinelerra-5.1/cinelerra/mwindowgui.C @@ -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")) { diff --git a/cinelerra-5.1/cinelerra/mwindowgui.h b/cinelerra-5.1/cinelerra/mwindowgui.h index 4eb54cf0..a40e4446 100644 --- a/cinelerra-5.1/cinelerra/mwindowgui.h +++ b/cinelerra-5.1/cinelerra/mwindowgui.h @@ -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 diff --git a/cinelerra-5.1/cinelerra/new.C b/cinelerra-5.1/cinelerra/new.C index 605be868..1fa0f15e 100644 --- a/cinelerra-5.1/cinelerra/new.C +++ b/cinelerra-5.1/cinelerra/new.C @@ -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; diff --git a/cinelerra-5.1/cinelerra/playbackengine.C b/cinelerra-5.1/cinelerra/playbackengine.C index 1d3a4115..b0c9fe3e 100644 --- a/cinelerra-5.1/cinelerra/playbackengine.C +++ b/cinelerra-5.1/cinelerra/playbackengine.C @@ -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; } diff --git a/cinelerra-5.1/cinelerra/playbackengine.h b/cinelerra-5.1/cinelerra/playbackengine.h index 2fd07167..f4ce0157 100644 --- a/cinelerra-5.1/cinelerra/playbackengine.h +++ b/cinelerra-5.1/cinelerra/playbackengine.h @@ -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 diff --git a/cinelerra-5.1/cinelerra/playtransport.C b/cinelerra-5.1/cinelerra/playtransport.C index c7334213..966d299d 100644 --- a/cinelerra-5.1/cinelerra/playtransport.C +++ b/cinelerra-5.1/cinelerra/playtransport.C @@ -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) diff --git a/cinelerra-5.1/cinelerra/playtransport.h b/cinelerra-5.1/cinelerra/playtransport.h index 62d1973a..0a60e223 100644 --- a/cinelerra-5.1/cinelerra/playtransport.h +++ b/cinelerra-5.1/cinelerra/playtransport.h @@ -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; diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index f4dd1916..35c773b0 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -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; diff --git a/cinelerra-5.1/cinelerra/transportque.C b/cinelerra-5.1/cinelerra/transportque.C index a2a5160a..816e81a4 100644 --- a/cinelerra-5.1/cinelerra/transportque.C +++ b/cinelerra-5.1/cinelerra/transportque.C @@ -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(); diff --git a/cinelerra-5.1/cinelerra/transportque.h b/cinelerra-5.1/cinelerra/transportque.h index 7d0c1819..1f5f9c63 100644 --- a/cinelerra-5.1/cinelerra/transportque.h +++ b/cinelerra-5.1/cinelerra/transportque.h @@ -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; diff --git a/cinelerra-5.1/cinelerra/vtimebar.C b/cinelerra-5.1/cinelerra/vtimebar.C index d1aa168d..b61f25f6 100644 --- a/cinelerra-5.1/cinelerra/vtimebar.C +++ b/cinelerra-5.1/cinelerra/vtimebar.C @@ -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); diff --git a/cinelerra-5.1/cinelerra/vwindowgui.C b/cinelerra-5.1/cinelerra/vwindowgui.C index 931b0d3e..4458eb76 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.C +++ b/cinelerra-5.1/cinelerra/vwindowgui.C @@ -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()); diff --git a/cinelerra-5.1/cinelerra/vwindowgui.h b/cinelerra-5.1/cinelerra/vwindowgui.h index 5dcdc784..039067e9 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.h +++ b/cinelerra-5.1/cinelerra/vwindowgui.h @@ -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(); diff --git a/cinelerra-5.1/cinelerra/zwindow.C b/cinelerra-5.1/cinelerra/zwindow.C index 80234ca0..5743aa40 100644 --- a/cinelerra-5.1/cinelerra/zwindow.C +++ b/cinelerra-5.1/cinelerra/zwindow.C @@ -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() diff --git a/cinelerra-5.1/cinelerra/zwindow.h b/cinelerra-5.1/cinelerra/zwindow.h index 528d576d..ac8f04dc 100644 --- a/cinelerra-5.1/cinelerra/zwindow.h +++ b/cinelerra-5.1/cinelerra/zwindow.h @@ -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);