cposer/viewer btn1/2/3 fwd/rev/frm playback, misc fixes, leaks, cleanup
[goodguy/history.git] / cinelerra-5.1 / cinelerra / editpanel.C
index 8de70d83341aa62c585592fb4d6cc2d5a0e45fc8..379291413d0eb57561d359bb398aa7e68c4fca97 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()
@@ -339,50 +346,36 @@ void EditPanel::toggle_label()
 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();
+       if( have_mwindow_lock ) mwindow->gui->unlock_window();
 
-       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-
-       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");
-
-       mwindow->prev_label(shift_down);
-
-       if(!have_mwindow_lock)
+       if( snap )
+               mwindow->snap_left_label();
+       else
+               mwindow->prev_label(shift_down);
+       if( !have_mwindow_lock )
                mwindow->gui->unlock_window();
 }
 
 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();
+       if( have_mwindow_lock ) mwindow->gui->unlock_window();
 
-       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-
-       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");
-
-       mwindow->next_label(shift_down);
-
-       if(!have_mwindow_lock)
+       if( snap )
+               mwindow->snap_right_label();
+       else
+               mwindow->next_label(shift_down);
+       if( !have_mwindow_lock )
                mwindow->gui->unlock_window();
 }
 
@@ -391,50 +384,40 @@ void EditPanel::next_label()
 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();
+       if( have_mwindow_lock ) mwindow->gui->unlock_window();
 
-       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-
-       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");
 
-       mwindow->prev_edit_handle(shift_down);
+       if( snap )
+               mwindow->snap_left_edit();
+       else
+               mwindow->prev_edit_handle(shift_down);
 
-       if(!have_mwindow_lock)
+       if( !have_mwindow_lock )
                mwindow->gui->unlock_window();
 }
 
 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();
+       if( have_mwindow_lock ) mwindow->gui->unlock_window();
 
-       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-
-       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");
 
-       mwindow->next_edit_handle(shift_down);
+       if( snap )
+               mwindow->snap_right_edit();
+       else
+               mwindow->next_edit_handle(shift_down);
 
-       if(!have_mwindow_lock)
+       if( !have_mwindow_lock )
                mwindow->gui->unlock_window();
 }
 
@@ -626,14 +609,9 @@ void EditPanel::set_outpoint()
        mwindow->set_outpoint(1);
 }
 
-void EditPanel::clear_inpoint()
+void EditPanel::unset_inoutpoint()
 {
-       mwindow->delete_inpoint();
-}
-
-void EditPanel::clear_outpoint()
-{
-       mwindow->delete_outpoint();
+       mwindow->unset_inoutpoint(1);
 }
 
 
@@ -642,7 +620,7 @@ EditInPoint::EditInPoint(MWindow *mwindow, EditPanel *panel, int x, int y)
 {
        this->mwindow = mwindow;
        this->panel = panel;
-       set_tooltip(_("In point ( [ )"));
+       set_tooltip(_("In point ( [ or < )"));
 }
 EditInPoint::~EditInPoint()
 {
@@ -654,9 +632,14 @@ int EditInPoint::handle_event()
 }
 int EditInPoint::keypress_event()
 {
-       if(get_keypress() == '[')
+       int key = get_keypress();
+       if( key == '[' || key == '<' ) {
+                panel->set_inpoint();
+               return 1;
+       }
+       if(ctrl_down() && get_keypress() == 't')
        {
-               panel->set_inpoint();
+               panel->unset_inoutpoint();
                return 1;
        }
        return 0;
@@ -667,7 +650,7 @@ EditOutPoint::EditOutPoint(MWindow *mwindow, EditPanel *panel, int x, int y)
 {
        this->mwindow = mwindow;
        this->panel = panel;
-       set_tooltip(_("Out point ( ] )"));
+       set_tooltip(_("Out point ( ] or > )"));
 }
 EditOutPoint::~EditOutPoint()
 {
@@ -679,11 +662,16 @@ int EditOutPoint::handle_event()
 }
 int EditOutPoint::keypress_event()
 {
-       if(get_keypress() == ']')
-       {
+       int key = get_keypress();
+       if( key == ']' || key == '>' ) {
                panel->set_outpoint();
                return 1;
        }
+       if(ctrl_down() && get_keypress() == 't')
+       {
+               panel->unset_inoutpoint();
+               return 1;
+       }
        return 0;
 }
 
@@ -705,7 +693,7 @@ EditNextLabel::~EditNextLabel()
 }
 int EditNextLabel::keypress_event()
 {
-       if(get_keypress() == RIGHT && ctrl_down())
+       if( ctrl_down() && get_keypress() == (!alt_down() ? RIGHT : '>') )
                return handle_event();
        return 0;
 }
@@ -732,7 +720,7 @@ EditPrevLabel::~EditPrevLabel()
 }
 int EditPrevLabel::keypress_event()
 {
-       if(get_keypress() == LEFT && ctrl_down())
+       if( ctrl_down() && get_keypress() == (!alt_down() ? LEFT : '<') )
                return handle_event();
        return 0;
 }
@@ -761,7 +749,7 @@ EditNextEdit::~EditNextEdit()
 }
 int EditNextEdit::keypress_event()
 {
-       if(get_keypress() == RIGHT && alt_down())
+       if( alt_down() && get_keypress() == (!ctrl_down() ? RIGHT : '.') )
                return handle_event();
        return 0;
 }
@@ -788,7 +776,7 @@ EditPrevEdit::~EditPrevEdit()
 }
 int EditPrevEdit::keypress_event()
 {
-       if(get_keypress() == LEFT && alt_down())
+       if( alt_down() && get_keypress() == (!ctrl_down() ? LEFT : ',') )
                return handle_event();
        return 0;
 }
@@ -874,7 +862,7 @@ int EditToClip::handle_event()
 
 int EditToClip::keypress_event()
 {
-       if(get_keypress() == 'i')
+       if(get_keypress() == 'i' && !alt_down())
        {
                handle_event();
                return 1;
@@ -1186,7 +1174,7 @@ EditLabelbutton::~EditLabelbutton()
 }
 int EditLabelbutton::keypress_event()
 {
-       if(get_keypress() == 'l')
+       if(get_keypress() == 'l' && !alt_down())
                return handle_event();
        return 0;
 }