search fixes, preset fixes, ladspa icon logging, igor pref theme, drag btn rollover
[goodguy/history.git] / cinelerra-5.1 / cinelerra / playtransport.C
index 85fe95a446a9252cd6d5bd935b8cfffc99c6cb0b..6fc55d63d376f12fefd1d68dff011764b8344e2f 100644 (file)
@@ -193,12 +193,13 @@ int PlayTransport::keypress_event()
 
        int toggle_audio = subwindow->shift_down() ? 1 : 0;
        int use_inout = subwindow->ctrl_down() ? 1 : 0;
+       int alt_key = subwindow->alt_down() ? 1 : 0;
        int command = -1, prev_command = engine->command->command;
        using_inout = use_inout;
        subwindow->unlock_window();
 
+       result = 0;
        switch( key ) {
-       case 'k':
        case KPINS:     command = STOP;                 break;
        case KPPLUS:    command = FAST_REWIND;          break;
        case KP6:       command = NORMAL_REWIND;        break;
@@ -216,14 +217,43 @@ int PlayTransport::keypress_event()
                case STOP:
                        command = NORMAL_FWD;
                        break;
+               default:
+                       command = STOP;
+                       break;
                }
                break;
-       default:
-               result = 0;
+       case 'u': case 'U':
+               if( alt_key ) command = SINGLE_FRAME_REWIND;
+               break;
+       case 'i': case 'I':
+               if( alt_key ) command = SLOW_REWIND;
+               break;
+       case 'o': case 'O':
+               if( alt_key ) command = NORMAL_REWIND;
+               break;
+       case 'p': case 'P':
+               if( alt_key ) command = FAST_REWIND;
+               break;
+       case 'j': case 'J':
+               if( alt_key ) command = SINGLE_FRAME_FWD;
+               break;
+       case 'k': case 'K':
+               if( alt_key ) command = SLOW_FWD;
+               break;
+       case 'l': case 'L':
+               if( alt_key ) command = NORMAL_FWD;
+               break;
+       case ':': case ';':
+               if( alt_key ) command = FAST_FWD;
+               break;
+       case 'm': case 'M':
+               if( alt_key ) command = STOP;
                break;
        }
-       if( command >= 0 )
+       if( command >= 0 ) {
                handle_transport(command, 0, use_inout, 1, toggle_audio);
+               result = 1;
+       }
 
        subwindow->lock_window("PlayTransport::keypress_event 5");
        return result;
@@ -252,8 +282,12 @@ void PlayTransport::handle_transport(int command,
        int resume = 0;
 //printf("PlayTransport::handle_transport 1 %d\n", command);
        int prev_command = engine->command->command;
-       int prev_direction = engine->command->get_direction();
        int prev_single_frame = engine->command->single_frame();
+       int prev_audio = engine->command->audio_toggle ?
+                !prev_single_frame : prev_single_frame;
+       int cur_single_frame = TransportCommand::single_frame(command);
+       int cur_audio = toggle_audio ?
+                !cur_single_frame : cur_single_frame;
 
 // Dispatch command
        switch(command) {
@@ -265,15 +299,17 @@ void PlayTransport::handle_transport(int command,
        case SLOW_FWD:
        case NORMAL_FWD:
        case FAST_FWD:
-               if( prev_command == command && !prev_single_frame ) {
-// Same direction pressed twice.  Stop
+               if( !prev_single_frame &&
+                   prev_command == command &&
+                   cur_audio == prev_audio ) {
+// Same direction pressed twice and no change in audio state,  Stop
                        do_stop = 1;
                        break;
                }
 // Resume or change direction
                switch( prev_command ) {
                default:
-                       engine->que->send_command(STOP, CHANGE_NONE, 0, 0, 0, 0);
+                       engine->que->send_command(STOP, CHANGE_NONE, 0, 0);
                        engine->interrupt_playback(wait_tracking);
                        resume = 1;
 // fall through
@@ -283,36 +319,23 @@ void PlayTransport::handle_transport(int command,
                case SINGLE_FRAME_REWIND:
 // Start from scratch
                        engine->que->send_command(command, CHANGE_NONE, get_edl(),
-                               1, resume, use_inout, toggle_audio);
+                               1, resume, use_inout, toggle_audio,
+                               mwindow->preferences->forward_render_displacement);
                        break;
                }
                break;
 
 // Commands that stop
        case STOP:
-               do_stop = 1;
-               break;
-
        case REWIND:
        case GOTO_END:
-               engine->que->send_command(STOP, CHANGE_NONE, 0, 0, 0, 0);
-                       engine->interrupt_playback(wait_tracking);
-                       break;
+               do_stop = 1;
+               break;
        }
 
        if( do_stop ) {
-               engine->que->send_command(STOP, CHANGE_NONE, 0, 0, 0, 0);
+               engine->que->send_command(STOP, CHANGE_NONE, 0, 0);
                engine->interrupt_playback(wait_tracking);
-// This is necessary to get an OpenGL output buffer
-// printf("PlayTransport::handle_transport 2 update_refresh=%d prev_command=%d prev_direction=%d\n",
-// update_refresh, prev_command, prev_direction);
-               if( !prev_single_frame && update_refresh &&
-                   prev_command != STOP && prev_command != COMMAND_NONE ) {
-                       int command = (prev_direction == PLAY_FORWARD) ?
-                                       SINGLE_FRAME_REWIND : SINGLE_FRAME_FWD;
-                       engine->que->send_command(command,
-                               CHANGE_NONE, get_edl(), 1, 0, 0);
-               }
        }
 }
 
@@ -497,7 +520,7 @@ void PlayTransport::change_position(double position)
 // stop transport
        if( prev_command != STOP && prev_command != COMMAND_NONE &&
            prev_command != SINGLE_FRAME_FWD && prev_command != SINGLE_FRAME_REWIND ) {
-               engine->que->send_command(STOP, CHANGE_NONE, 0, 0, 0, 0);
+               engine->que->send_command(STOP, CHANGE_NONE, 0, 0);
                engine->interrupt_playback(0);
        }
        mwindow->gui->lock_window("PlayTransport::change_position");
@@ -512,7 +535,7 @@ void PlayTransport::change_position(double position)
        case NORMAL_FWD:
        case FAST_FWD:
                engine->que->send_command(prev_command, CHANGE_NONE,
-                               get_edl(), 1, 1, using_inout);
+                               get_edl(), 1, 1, using_inout, 0);
        }
 }