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
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;
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 +
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;
}
}
+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,
void keyboard_zoomin();
void keyboard_zoomout();
void update_meters();
+ void stop_transport(const char *lock_msg);
MWindow *mwindow;
CWindow *cwindow;
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()
{
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();
}
{
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();
}
{
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");
else
mwindow->prev_edit_handle(shift_down);
- if(!have_mwindow_lock)
+ if( !have_mwindow_lock )
mwindow->gui->unlock_window();
}
{
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");
else
mwindow->next_edit_handle(shift_down);
- if(!have_mwindow_lock)
+ if( !have_mwindow_lock )
mwindow->gui->unlock_window();
}
}
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')
}
int EditOutPoint::keypress_event()
{
- if(get_keypress() == ']')
- {
+ int key = get_keypress();
+ if( key == ']' || key == '>' ) {
panel->set_outpoint();
return 1;
}
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();
}
-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
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())
{
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();
}
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 ) {
}
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()
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);
}
}
}
}
+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)
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();
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;
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
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
}
}
+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"))
{
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
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,
// 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;
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() *
// 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() *
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;
}
}
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;
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;
}
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
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)
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();
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;
}
-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()
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"))
}
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
}
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
}
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);
}
}
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)
// 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);
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;
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;
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;
this->realtime = command->realtime;
this->resume = command->resume;
this->audio_toggle = command->audio_toggle;
+ this->play_loop = command->play_loop;
this->displacement = command->displacement;
}
// 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;
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;
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;
}
}
}
- 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()
}
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;
}
// 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();
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();
int resume;
// reverse audio duty
int audio_toggle;
-
+// playback loop
+ int play_loop;
private:
// Copied to render engines
EDL *edl;
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;
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);
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());
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();
}
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()
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);