pluginclient cr=apply in option value textbox, add loop_mode for vwdw
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / playtransport.C
index 94b70dcdc139f9dc79b8aa1000481e43bc5213e6..8caf4678bb3493ff5b7e0326ab6d82c5bf5d8d3e 100644 (file)
@@ -30,6 +30,7 @@
 #include "preferences.h"
 #include "shuttle.h"
 #include "theme.h"
+#include "tracks.h"
 #include "transportque.h"
 #include "vframe.h"
 
@@ -132,7 +133,7 @@ int PlayTransport::get_w()
 
 int PlayTransport::is_stopped()
 {
-       return engine->command->command == STOP ? 1 : 0;
+       return engine->is_playing_back ? 0 : 1;
 }
 
 int PlayTransport::flip_vertical(int vertical, int &x, int &y)
@@ -210,7 +211,7 @@ int PlayTransport::do_keypress(int key)
        int loop_play = shft_key & ctrl_key;
        float speed = 0;
        int command = -1;
-       int curr_command = engine->command->command;
+       int curr_command = engine->is_playing_back ? engine->command->command : STOP;
        subwindow->unlock_window();
 
        result = 0;
@@ -315,7 +316,7 @@ void PlayTransport::handle_transport(int command, int wait_tracking,
        if( !edl ) return;
        using_inout = use_inout;
 
-       if( !is_vwindow() )
+       if( use_mixers() )
                mwindow->handle_mixers(edl, command, wait_tracking,
                                use_inout, toggle_audio, 0, speed);
        engine->next_command->toggle_audio = toggle_audio;
@@ -329,21 +330,14 @@ EDL* PlayTransport::get_edl()
        return mwindow->edl;
 }
 
-int PlayTransport::pause_transport()
+int PlayTransport::set_transport(int mode)
 {
-       if(active_button) active_button->set_mode(PLAY_MODE);
-       return 0;
-}
-
-
-int PlayTransport::reset_transport()
-{
-       fast_reverse->set_mode(PLAY_MODE);
-       reverse_play->set_mode(PLAY_MODE);
-       forward_play->set_mode(PLAY_MODE);
-       frame_reverse_play->set_mode(PLAY_MODE);
-       frame_forward_play->set_mode(PLAY_MODE);
-       fast_play->set_mode(PLAY_MODE);
+       fast_reverse->set_mode(mode);
+       reverse_play->set_mode(mode);
+       forward_play->set_mode(mode);
+       frame_reverse_play->set_mode(mode);
+       frame_forward_play->set_mode(mode);
+       fast_play->set_mode(mode);
        return 0;
 }
 
@@ -358,10 +352,29 @@ PTransportButton::~PTransportButton()
 {
 }
 
-int PTransportButton::set_mode(int mode)
+void PTransportButton::set_mode(int mode)
 {
        this->mode = mode;
-       return 0;
+}
+
+void PTransportButton::loop_mode(int dir)
+{
+       if( mode != LOOP_MODE ) return;
+       EDL *edl = transport->get_edl();
+       if( !edl ) return;
+       PlaybackEngine *engine = transport->engine;
+       if( !engine || engine->is_playing_back ) return;
+       double position = engine->get_tracking_position();
+       switch( dir ) {
+       case PLAY_FORWARD:
+               if( position >= edl->tracks->total_playable_length() )
+                       transport->goto_start();
+               break;
+       case PLAY_REVERSE:
+               if( position <= 0 )
+                       transport->goto_end();
+               break;
+       }
 }
 
 int PTransportButton::play_command(const char *lock_msg, int command)
@@ -398,6 +411,7 @@ FastReverseButton::FastReverseButton(MWindow *mwindow, PlayTransport *transport,
 }
 int FastReverseButton::handle_event()
 {
+       loop_mode(PLAY_REVERSE);
        return play_command("FastReverseButton::handle_event", FAST_REWIND);
 }
 
@@ -410,6 +424,7 @@ ReverseButton::ReverseButton(MWindow *mwindow, PlayTransport *transport, int x,
 }
 int ReverseButton::handle_event()
 {
+       loop_mode(PLAY_REVERSE);
        return play_command("ReverseButton::handle_event", NORMAL_REWIND);
 }
 
@@ -437,6 +452,7 @@ PlayButton::PlayButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
 }
 int PlayButton::handle_event()
 {
+       loop_mode(PLAY_FORWARD);
        return play_command("PlayButton::handle_event", NORMAL_FWD);
 }
 
@@ -466,6 +482,7 @@ FastPlayButton::FastPlayButton(MWindow *mwindow, PlayTransport *transport, int x
 }
 int FastPlayButton::handle_event()
 {
+       loop_mode(PLAY_FORWARD);
        return play_command("FastPlayButton::handle_event", FAST_FWD);
 }
 
@@ -502,11 +519,7 @@ void PlayTransport::change_position(double position)
        if( !get_edl() ) return;
        int command = engine->command->command;
 // stop transport
-       if( command != STOP && command != COMMAND_NONE &&
-           command != SINGLE_FRAME_FWD && command != SINGLE_FRAME_REWIND ) {
-               engine->transport_stop();
-               engine->interrupt_playback(0);
-       }
+       engine->stop_playback(0);
        mwindow->gui->lock_window("PlayTransport::change_position");
        mwindow->goto_position(position);
        mwindow->gui->unlock_window();