From 0c7b0aebb5e9f85f4eb7abb69b800d8d37b30b0f Mon Sep 17 00:00:00 2001 From: Good Guy Date: Mon, 4 Feb 2019 10:51:08 -0700 Subject: [PATCH] fix editpanel wdw lock issues, use undo bracketing to avoid stop playback deadlocks --- cinelerra-5.1/cinelerra/cwindowgui.C | 89 ++- cinelerra-5.1/cinelerra/cwindowgui.h | 36 +- cinelerra-5.1/cinelerra/editpanel.C | 901 ++++++++----------------- cinelerra-5.1/cinelerra/editpanel.h | 112 +-- cinelerra-5.1/cinelerra/editpanel.inc | 8 +- cinelerra-5.1/cinelerra/mbuttons.C | 127 +++- cinelerra-5.1/cinelerra/mbuttons.h | 26 +- cinelerra-5.1/cinelerra/mwindow.C | 71 +- cinelerra-5.1/cinelerra/mwindow.h | 22 +- cinelerra-5.1/cinelerra/mwindowedit.C | 347 ++++------ cinelerra-5.1/cinelerra/mwindowmove.C | 23 +- cinelerra-5.1/cinelerra/vtimebar.C | 3 +- cinelerra-5.1/cinelerra/vwindowgui.C | 208 +++--- cinelerra-5.1/cinelerra/vwindowgui.h | 34 +- cinelerra-5.1/guicast/bctrace.C | 11 +- cinelerra-5.1/guicast/bctrace.inc | 5 +- cinelerra-5.1/guicast/condition.C | 6 + cinelerra-5.1/guicast/mutex.C | 6 +- cinelerra-5.1/thirdparty/downloads.txt | 2 + 19 files changed, 923 insertions(+), 1114 deletions(-) diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index e800cbbe..610d4e7c 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -779,8 +779,6 @@ CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow) 1, // use_keyframe 0, // use_splice 0, // use_overwrite - 1, // use_lift - 1, // use_extract 1, // use_copy 1, // use_paste 1, // use_undo @@ -798,51 +796,70 @@ CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow) this->cwindow = cwindow; } -#define CWrapper(fn) void CWindowEditing::fn() { \ - mwindow->gui->lock_window("CWrapper::" #fn); \ - EditPanel::fn(); \ - mwindow->gui->unlock_window(); \ -} +#define relock_cm(s) \ + cwindow->gui->unlock_window(); \ + mwindow->gui->lock_window("CWindowEditing::" s) +#define relock_mc(s) \ + mwindow->gui->unlock_window(); \ + cwindow->gui->lock_window("CWindowEditing::" s) +#define panel_fn(fn, args, s) \ + CWindowEditing::fn args { relock_cm(#fn); s; relock_mc(#fn); } -CWrapper(copy_selection) -CWrapper(splice_selection) -CWrapper(overwrite_selection) -CWrapper(set_inpoint) -CWrapper(set_outpoint) -CWrapper(unset_inoutpoint) -CWrapper(toggle_label) +// transmit lock to mwindow, and run mbutton->edit_panel->s +#define panel_btn(fn, args, s) \ + panel_fn(panel_##fn, args, mwindow->gui->mbuttons->edit_panel->panel_##s) -#define CWrapper_cut(fn) void CWindowEditing::fn(int cut) { \ - mwindow->gui->lock_window("CWrapper::" #fn); \ - EditPanel::fn(cut); \ - mwindow->gui->unlock_window(); \ +double CWindowEditing::get_position() +{ + relock_cm("get_position"); + double ret = mwindow->edl->local_session->get_selectionstart(1); + relock_mc("get_position"); + return ret; +} + +void CWindowEditing::set_position(double position) +{ + relock_cm("set_position"); + set_position(position); + relock_mc("set_position"); } -CWrapper_cut(prev_label) -CWrapper_cut(next_label) -CWrapper_cut(prev_edit) -CWrapper_cut(next_edit) -void CWindowEditing::to_clip() +void CWindowEditing::set_click_to_play(int v) { - mwindow->to_clip(mwindow->edl, _("composer window: "), 0); + relock_cm("set_click_to_play"); + mwindow->edl->session->cwindow_click2play = v; + click2play->update(v); + relock_mc("set_click_to_play"); } +void panel_btn(stop_transport,(), stop_transport()) +void panel_btn(toggle_label,(), toggle_label()) +void panel_btn(next_label,(int cut), next_label(cut)) +void panel_btn(prev_label,(int cut), prev_label(cut)) +void panel_btn(next_edit,(int cut), next_edit(cut)) +void panel_btn(prev_edit,(int cut), prev_edit(cut)) +void panel_fn(panel_copy_selection,(), mwindow->copy()) +void CWindowEditing::panel_overwrite_selection() {} // not used +void CWindowEditing::panel_splice_selection() {} // not used +void panel_btn(set_inpoint,(), set_inpoint()) +void panel_btn(set_outpoint,(), set_outpoint()) +void panel_btn(unset_inoutpoint,(), unset_inoutpoint()) +void panel_fn(panel_to_clip,(), mwindow->to_clip(mwindow->edl, _("main window: "), 0)) +void panel_btn(cut,(), cut()) +void panel_btn(paste,(), paste()) +void panel_btn(fit_selection,(), fit_selection()) +void panel_btn(fit_autos,(int all), fit_autos(all)) +void panel_btn(set_editing_mode,(int mode), set_editing_mode(mode)) +void panel_btn(set_auto_keyframes,(int v), set_auto_keyframes(v)) +void panel_btn(set_labels_follow_edits,(int v), set_labels_follow_edits(v)) + CWindowMeters::CWindowMeters(MWindow *mwindow, - CWindowGUI *gui, - int x, - int y, - int h) - : MeterPanel(mwindow, - gui, - x, - y, - -1, - h, + CWindowGUI *gui, int x, int y, int h) + : MeterPanel(mwindow, gui, x, y, -1, h, mwindow->edl->session->audio_channels, mwindow->edl->session->cwindow_meter, - 0, - 0) + 0, 0) { this->mwindow = mwindow; this->gui = gui; diff --git a/cinelerra-5.1/cinelerra/cwindowgui.h b/cinelerra-5.1/cinelerra/cwindowgui.h index 45734e42..0e120c8b 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.h +++ b/cinelerra-5.1/cinelerra/cwindowgui.h @@ -162,18 +162,30 @@ public: CWindowEditing(MWindow *mwindow, CWindow *cwindow); virtual ~CWindowEditing() {} - void copy_selection(); - void splice_selection(); - void overwrite_selection(); - void set_inpoint(); - void set_outpoint(); - void unset_inoutpoint(); - void to_clip(); - void toggle_label(); - void prev_label(int cut); - void next_label(int cut); - void prev_edit(int cut); - void next_edit(int cut); + double get_position(); + void set_position(double position); + void set_click_to_play(int v); + + void panel_stop_transport(); + void panel_toggle_label(); + void panel_next_label(int cut); + void panel_prev_label(int cut); + void panel_prev_edit(int cut); + void panel_next_edit(int cut); + void panel_copy_selection(); + void panel_overwrite_selection(); + void panel_splice_selection(); + void panel_set_inpoint(); + void panel_set_outpoint(); + void panel_unset_inoutpoint(); + void panel_to_clip(); + void panel_cut(); + void panel_paste(); + void panel_fit_selection(); + void panel_fit_autos(int all); + void panel_set_editing_mode(int mode); + void panel_set_auto_keyframes(int v); + void panel_set_labels_follow_edits(int v); MWindow *mwindow; CWindow *cwindow; diff --git a/cinelerra-5.1/cinelerra/editpanel.C b/cinelerra-5.1/cinelerra/editpanel.C index 26e5b7d0..4e80555e 100644 --- a/cinelerra-5.1/cinelerra/editpanel.C +++ b/cinelerra-5.1/cinelerra/editpanel.C @@ -59,8 +59,6 @@ EditPanel::EditPanel(MWindow *mwindow, int use_keyframe, int use_splice, // Extra buttons int use_overwrite, - int use_lift, - int use_extract, int use_copy, int use_paste, int use_undo, @@ -80,8 +78,6 @@ EditPanel::EditPanel(MWindow *mwindow, this->use_keyframe = use_keyframe; this->use_splice = use_splice; this->use_overwrite = use_overwrite; - this->use_lift = 0; - this->use_extract = 0; this->use_copy = use_copy; this->use_paste = use_paste; this->use_undo = use_undo; @@ -105,8 +101,6 @@ EditPanel::EditPanel(MWindow *mwindow, this->outpoint = 0; this->splice = 0; this->overwrite = 0; - this->lift = 0; - this->extract = 0; this->clip = 0; this->cut = 0; this->commercial = 0; @@ -202,7 +196,7 @@ void EditPanel::create_buttons() } if( use_locklabels ) { - locklabels = new LockLabelsButton(mwindow, x1, y1); + locklabels = new LockLabelsButton(mwindow, this, x1, y1); subwindow->add_subwindow(locklabels); x1 += locklabels->get_w(); } @@ -230,18 +224,6 @@ void EditPanel::create_buttons() x1 += overwrite->get_w(); } - if( use_lift ) { - lift = new EditLift(mwindow, this, x1, y1); - subwindow->add_subwindow(lift); - x1 += lift->get_w(); - } - - if( use_extract ) { - extract = new EditExtract(mwindow, this, x1, y1); - subwindow->add_subwindow(extract); - x1 += extract->get_w(); - } - if( use_toclip ) { clip = new EditToClip(mwindow, this, x1, y1); subwindow->add_subwindow(clip); @@ -335,117 +317,6 @@ void EditPanel::create_buttons() } } -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() -{ - mwindow->toggle_label(is_mwindow()); -} - -void EditPanel::prev_label(int cut) -{ - int shift_down = subwindow->shift_down(); - int have_mwindow_lock = mwindow->gui->get_window_lock(); - if( have_mwindow_lock ) mwindow->gui->unlock_window(); - - stop_transport("EditPanel::prev_label 1"); - - mwindow->gui->lock_window("EditPanel::prev_label 2"); - if( cut ) - mwindow->cut_left_label(); - else - mwindow->prev_label(shift_down); - if( !have_mwindow_lock ) - mwindow->gui->unlock_window(); -} - -void EditPanel::next_label(int cut) -{ - int shift_down = subwindow->shift_down(); - int have_mwindow_lock = mwindow->gui->get_window_lock(); - if( have_mwindow_lock ) mwindow->gui->unlock_window(); - - stop_transport("EditPanel::next_label 1"); - - mwindow->gui->lock_window("EditPanel::next_label 2"); - if( cut ) - mwindow->cut_right_label(); - else - mwindow->next_label(shift_down); - if( !have_mwindow_lock ) - mwindow->gui->unlock_window(); -} - - - -void EditPanel::prev_edit(int cut) -{ - int shift_down = subwindow->shift_down(); - int have_mwindow_lock = mwindow->gui->get_window_lock(); - if( have_mwindow_lock ) mwindow->gui->unlock_window(); - - stop_transport("EditPanel::prev_edit 1"); - - mwindow->gui->lock_window("EditPanel::prev_edit 2"); - - if( cut ) - mwindow->cut_left_edit(); - else - mwindow->prev_edit_handle(shift_down); - - if( !have_mwindow_lock ) - mwindow->gui->unlock_window(); -} - -void EditPanel::next_edit(int cut) -{ - int shift_down = subwindow->shift_down(); - int have_mwindow_lock = mwindow->gui->get_window_lock(); - if( have_mwindow_lock ) mwindow->gui->unlock_window(); - - stop_transport("EditPanel::next_edit 1"); - - mwindow->gui->lock_window("EditPanel::next_edit 2"); - - if( cut ) - mwindow->cut_right_edit(); - else - mwindow->next_edit_handle(shift_down); - - if( !have_mwindow_lock ) - mwindow->gui->unlock_window(); -} - - -double EditPanel::get_position() -{ - EDL *edl = mwindow->edl; - return !edl ? 0 : edl->local_session->get_selectionstart(1); -} - -void EditPanel::set_position(double position) -{ - EDL *edl = mwindow->edl; - if( !edl ) return; - if( position != get_position() ) { - if( position < 0 ) position = 0; - edl->local_session->set_selectionstart(position); - edl->local_session->set_selectionend(position); - mwindow->gui->lock_window(); - mwindow->find_cursor(); - mwindow->gui->update(1, NORMAL_DRAW, 1, 1, 1, 1, 0); - mwindow->gui->unlock_window(); - mwindow->cwindow->update(1, 0, 0, 0, 0); - } -} - void EditPanel::reposition_buttons(int x, int y) { this->x = x; @@ -485,14 +356,6 @@ void EditPanel::reposition_buttons(int x, int y) overwrite->reposition_window(x1, y1); x1 += overwrite->get_w(); } - if( use_lift ) { - lift->reposition_window(x1, y1); - x1 += lift->get_w(); - } - if( use_extract ) { - extract->reposition_window(x1, y1); - x1 += extract->get_w(); - } if( use_toclip ) { clip->reposition_window(x1, y1); x1 += clip->get_w(); @@ -558,8 +421,6 @@ void EditPanel::reposition_buttons(int x, int y) } } - - void EditPanel::create_objects() { create_buttons(); @@ -570,103 +431,31 @@ int EditPanel::get_w() return x1 - x; } - -void EditPanel::copy_selection() -{ - mwindow->copy(); -} - -void EditPanel::splice_selection() -{ -} - -void EditPanel::overwrite_selection() -{ -} - -void EditPanel::set_inpoint() -{ - mwindow->set_inpoint(1); -} - -void EditPanel::set_outpoint() -{ - mwindow->set_outpoint(1); -} - -void EditPanel::unset_inoutpoint() -{ - mwindow->unset_inoutpoint(1); -} - - -EditInPoint::EditInPoint(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("inbutton")) +// toggle_label +EditLabelbutton::EditLabelbutton(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Button(x, y, mwindow->theme->get_image_set("labelbutton")) { this->mwindow = mwindow; this->panel = panel; - set_tooltip(_("In point ( [ or < )")); -} -EditInPoint::~EditInPoint() -{ -} -int EditInPoint::handle_event() -{ - panel->set_inpoint(); - return 1; -} -int EditInPoint::keypress_event() -{ - int key = get_keypress(); - if( ctrl_down() ) { - if( key == 't' ) { - panel->unset_inoutpoint(); - return 1; - } - } - else if( !alt_down() ) { - if( key == '[' || key == '<' ) { - panel->set_inpoint(); - return 1; - } - } - return 0; + set_tooltip(_("Toggle label at current position ( l )")); } -EditOutPoint::EditOutPoint(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("outbutton")) +EditLabelbutton::~EditLabelbutton() { - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Out point ( ] or > )")); } -EditOutPoint::~EditOutPoint() +int EditLabelbutton::keypress_event() { + if( get_keypress() == 'l' && !alt_down() ) + return handle_event(); + return 0; } -int EditOutPoint::handle_event() +int EditLabelbutton::handle_event() { - panel->set_outpoint(); + panel->panel_toggle_label(); return 1; } -int EditOutPoint::keypress_event() -{ - int key = get_keypress(); - if( ctrl_down() ) { - if( key == 't' ) { - panel->unset_inoutpoint(); - return 1; - } - } - else if( !alt_down() ) { - if( key == ']' || key == '>' ) { - panel->set_outpoint(); - return 1; - } - } - return 0; -} - +//next_label EditNextLabel::EditNextLabel(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Button(x, y, mwindow->theme->get_image_set("nextlabel")) @@ -683,11 +472,11 @@ int EditNextLabel::keypress_event() if( ctrl_down() ) { int key = get_keypress(); if( (key == RIGHT || key == '.') && !alt_down() ) { - panel->next_label(0); + panel->panel_next_label(0); return 1; } if( key == '>' && alt_down() ) { - panel->next_label(1); + panel->panel_next_label(1); return 1; } } @@ -696,10 +485,11 @@ int EditNextLabel::keypress_event() int EditNextLabel::handle_event() { int cut = ctrl_down() && alt_down(); - panel->next_label(cut); + panel->panel_next_label(cut); return 1; } +//prev_label EditPrevLabel::EditPrevLabel(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Button(x, y, mwindow->theme->get_image_set("prevlabel")) @@ -716,11 +506,11 @@ int EditPrevLabel::keypress_event() if( ctrl_down() ) { int key = get_keypress(); if( (key == LEFT || key == ',') && !alt_down() ) { - panel->prev_label(0); + panel->panel_prev_label(0); return 1; } if( key == '<' && alt_down() ) { - panel->prev_label(1); + panel->panel_prev_label(1); return 1; } } @@ -729,95 +519,106 @@ int EditPrevLabel::keypress_event() int EditPrevLabel::handle_event() { int cut = ctrl_down() && alt_down(); - panel->prev_label(cut); + panel->panel_prev_label(cut); return 1; } - - -EditNextEdit::EditNextEdit(MWindow *mwindow, +//prev_edit +EditPrevEdit::EditPrevEdit(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("nextedit")) + : BC_Button(x, y, mwindow->theme->get_image_set("prevedit")) { this->mwindow = mwindow; this->panel = panel; - set_tooltip(_("Next edit ( alt -> )")); + set_tooltip(_("Previous edit (alt <- )")); } -EditNextEdit::~EditNextEdit() +EditPrevEdit::~EditPrevEdit() { } -int EditNextEdit::keypress_event() +int EditPrevEdit::keypress_event() { if( alt_down() ) { int key = get_keypress(); - if( (key == RIGHT || key == '.') && !ctrl_down() ) { - panel->next_edit(0); + if( (key == LEFT || key == ',') && !ctrl_down() ) { + panel->panel_prev_edit(0); return 1; } - if( key == '.' && ctrl_down() ) { - panel->next_edit(1); + if( key == ',' && ctrl_down() ) { + panel->panel_prev_edit(1); return 1; } } return 0; } -int EditNextEdit::handle_event() +int EditPrevEdit::handle_event() { int cut = ctrl_down() && alt_down(); - panel->next_edit(cut); + panel->panel_prev_edit(cut); return 1; } -EditPrevEdit::EditPrevEdit(MWindow *mwindow, +//next_edit +EditNextEdit::EditNextEdit(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("prevedit")) + : BC_Button(x, y, mwindow->theme->get_image_set("nextedit")) { this->mwindow = mwindow; this->panel = panel; - set_tooltip(_("Previous edit (alt <- )")); + set_tooltip(_("Next edit ( alt -> )")); } -EditPrevEdit::~EditPrevEdit() +EditNextEdit::~EditNextEdit() { } -int EditPrevEdit::keypress_event() +int EditNextEdit::keypress_event() { if( alt_down() ) { int key = get_keypress(); - if( (key == LEFT || key == ',') && !ctrl_down() ) { - panel->prev_edit(0); + if( (key == RIGHT || key == '.') && !ctrl_down() ) { + panel->panel_next_edit(0); return 1; } - if( key == ',' && ctrl_down() ) { - panel->prev_edit(1); + if( key == '.' && ctrl_down() ) { + panel->panel_next_edit(1); return 1; } } return 0; } -int EditPrevEdit::handle_event() +int EditNextEdit::handle_event() { int cut = ctrl_down() && alt_down(); - panel->prev_edit(cut); + panel->panel_next_edit(cut); return 1; } - - -EditLift::EditLift(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->lift_data) +//copy_selection +EditCopy::EditCopy(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Button(x, y, mwindow->theme->get_image_set("copy")) { this->mwindow = mwindow; this->panel = panel; - set_tooltip(_("Lift")); + set_tooltip(_("Copy ( c )")); +} +EditCopy::~EditCopy() +{ } -EditLift::~EditLift() + +int EditCopy::keypress_event() { + if( alt_down() ) return 0; + if( (get_keypress() == 'c' && !ctrl_down()) || + (panel->is_vwindow() && get_keypress() == 'C') ) { + return handle_event(); + } + return 0; } -int EditLift::handle_event() +int EditCopy::handle_event() { + panel->panel_copy_selection(); return 1; } +//overwrite_selection EditOverwrite::EditOverwrite(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Button(x, y, mwindow->theme->overwrite_data) { @@ -830,7 +631,7 @@ EditOverwrite::~EditOverwrite() } int EditOverwrite::handle_event() { - panel->overwrite_selection(); + panel->panel_overwrite_selection(); return 1; } int EditOverwrite::keypress_event() @@ -844,77 +645,77 @@ int EditOverwrite::keypress_event() return 0; } -EditExtract::EditExtract(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->extract_data) -{ - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Extract")); -} -EditExtract::~EditExtract() -{ -} -int EditExtract::handle_event() -{ -// mwindow->extract_selection(); - return 1; -} - -EditToClip::EditToClip(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("toclip")) +//set_inpoint +//unset_inoutpoint +EditInPoint::EditInPoint(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Button(x, y, mwindow->theme->get_image_set("inbutton")) { this->mwindow = mwindow; this->panel = panel; - set_tooltip(_("To clip ( i )")); + set_tooltip(_("In point ( [ or < )")); } -EditToClip::~EditToClip() +EditInPoint::~EditInPoint() { } -int EditToClip::handle_event() +int EditInPoint::handle_event() { - panel->to_clip(); + panel->panel_set_inpoint(); return 1; } - -int EditToClip::keypress_event() +int EditInPoint::keypress_event() { - if( alt_down() ) return 0; - if( get_keypress() == 'i' || - (panel->is_vwindow() && get_keypress() == 'I') ) { - handle_event(); - return 1; + int key = get_keypress(); + if( ctrl_down() ) { + if( key == 't' ) { + panel->panel_unset_inoutpoint(); + return 1; + } + } + else if( !alt_down() ) { + if( key == '[' || key == '<' ) { + panel->panel_set_inpoint(); + return 1; + } } return 0; } -EditManualGoto::EditManualGoto(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("goto")) +//set_outpoint +//unset_inoutpoint +EditOutPoint::EditOutPoint(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Button(x, y, mwindow->theme->get_image_set("outbutton")) { this->mwindow = mwindow; this->panel = panel; - mangoto = new ManualGoto(mwindow, panel); - set_tooltip(_("Manual goto ( g )")); + set_tooltip(_("Out point ( ] or > )")); } -EditManualGoto::~EditManualGoto() +EditOutPoint::~EditOutPoint() { - delete mangoto; } -int EditManualGoto::handle_event() +int EditOutPoint::handle_event() { - mangoto->start(); + panel->panel_set_outpoint(); return 1; } - -int EditManualGoto::keypress_event() +int EditOutPoint::keypress_event() { - if( get_keypress() == 'g' ) { - handle_event(); - return 1; + int key = get_keypress(); + if( ctrl_down() ) { + if( key == 't' ) { + panel->panel_unset_inoutpoint(); + return 1; + } + } + else if( !alt_down() ) { + if( key == ']' || key == '>' ) { + panel->panel_set_outpoint(); + return 1; + } } return 0; } - +//splice_selection EditSplice::EditSplice(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Button(x, y, mwindow->theme->splice_data) { @@ -927,7 +728,7 @@ EditSplice::~EditSplice() } int EditSplice::handle_event() { - panel->splice_selection(); + panel->panel_splice_selection(); return 1; } int EditSplice::keypress_event() @@ -941,179 +742,61 @@ int EditSplice::keypress_event() return 0; } -EditCut::EditCut(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("cut")) +//to_clip +EditToClip::EditToClip(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Button(x, y, mwindow->theme->get_image_set("toclip")) { this->mwindow = mwindow; this->panel = panel; - set_tooltip(_("Split | Cut ( x )")); -} -EditCut::~EditCut() -{ + set_tooltip(_("To clip ( i )")); } -int EditCut::keypress_event() +EditToClip::~EditToClip() { - if( ctrl_down() || shift_down() || alt_down() ) - return 0; - if( get_keypress() == 'x' ) - return handle_event(); - return 0; } - -int EditCut::handle_event() +int EditToClip::handle_event() { - int have_mwindow_lock = mwindow->gui->get_window_lock(); - if( !have_mwindow_lock ) - mwindow->gui->lock_window("EditCut::handle_event"); - - mwindow->cut(); - - if( !have_mwindow_lock ) - mwindow->gui->unlock_window(); + panel->panel_to_clip(); return 1; } -EditClick2Play::EditClick2Play(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Toggle(x, y, mwindow->theme->get_image_set("playpatch_data"), - !panel->is_vwindow() ? - mwindow->edl->session->cwindow_click2play : - mwindow->edl->session->vwindow_click2play) -{ - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Click to play (p)")); -} -int EditClick2Play::handle_event() -{ - int value = get_value(); - if( panel->is_vwindow() ) { - mwindow->edl->session->vwindow_click2play = value; - mwindow->update_vwindow(); - } - else - mwindow->edl->session->cwindow_click2play = value; - return 1; -} -int EditClick2Play::keypress_event() +int EditToClip::keypress_event() { - int key = get_keypress(); - if( key == 'p' && !ctrl_down() && !shift_down() && !alt_down() ) { - int value = get_value() ? 0 : 1; - update(value); - if( panel->is_vwindow() ) { - mwindow->edl->session->vwindow_click2play = value; - mwindow->update_vwindow(); - } - else - mwindow->edl->session->cwindow_click2play = value; + if( alt_down() ) return 0; + if( get_keypress() == 'i' || + (panel->is_vwindow() && get_keypress() == 'I') ) { + handle_event(); return 1; } return 0; } - -EditCommercial::EditCommercial(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("commercial")) +//cut +EditCut::EditCut(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Button(x, y, mwindow->theme->get_image_set("cut")) { this->mwindow = mwindow; this->panel = panel; - set_tooltip(_("Commercial ( shift A )")); + set_tooltip(_("Split | Cut ( x )")); } -EditCommercial::~EditCommercial() +EditCut::~EditCut() { } -int EditCommercial::keypress_event() +int EditCut::keypress_event() { - if( ctrl_down() || !shift_down() || alt_down() ) + if( ctrl_down() || shift_down() || alt_down() ) return 0; - if( get_keypress() == 'A' ) - return handle_event(); - return 0; -} - -int EditCommercial::handle_event() -{ - int have_mwindow_lock = mwindow->gui->get_window_lock(); - if( have_mwindow_lock ) - mwindow->gui->unlock_window(); - mwindow->commit_commercial(); - if( !mwindow->put_commercial() ) { - mwindow->gui->lock_window("EditCommercial::handle_event 1"); - mwindow->cut(); - if( !have_mwindow_lock ) - mwindow->gui->unlock_window(); - mwindow->activate_commercial(); - return 1; - } - mwindow->undo_commercial(); - if( have_mwindow_lock ) - mwindow->gui->lock_window("EditCommercial::handle_event 2"); - return 1; -} - -EditCopy::EditCopy(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("copy")) -{ - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Copy ( c )")); -} -EditCopy::~EditCopy() -{ -} - -int EditCopy::keypress_event() -{ - if( alt_down() ) return 0; - if( (get_keypress() == 'c' && !ctrl_down()) || - (panel->is_vwindow() && get_keypress() == 'C') ) { + if( get_keypress() == 'x' ) return handle_event(); - } return 0; } -int EditCopy::handle_event() -{ - panel->copy_selection(); - return 1; -} - -EditAppend::EditAppend(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->append_data) -{ - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Append to end of track")); -} -EditAppend::~EditAppend() -{ -} - - -int EditAppend::handle_event() -{ - return 1; -} - -EditInsert::EditInsert(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->insert_data) -{ - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Insert before beginning of track")); -} -EditInsert::~EditInsert() -{ -} - - -int EditInsert::handle_event() +int EditCut::handle_event() { - + panel->panel_cut(); return 1; } - +//paste EditPaste::EditPaste(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Button(x, y, mwindow->theme->get_image_set("paste")) { @@ -1133,130 +816,11 @@ int EditPaste::keypress_event() } int EditPaste::handle_event() { - int have_mwindow_lock = mwindow->gui->get_window_lock(); - if( !have_mwindow_lock ) - mwindow->gui->lock_window("EditPaste::handle_event"); - - mwindow->paste(); - - if( !have_mwindow_lock ) - mwindow->gui->unlock_window(); - return 1; -} - - - -EditTransition::EditTransition(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->transition_data) -{ - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Set transition")); -} -EditTransition::~EditTransition() -{ -} -int EditTransition::handle_event() -{ - return 1; -} - -EditPresentation::EditPresentation(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->presentation_data) -{ - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Set presentation up to current position")); -} -EditPresentation::~EditPresentation() -{ -} -int EditPresentation::handle_event() -{ + panel->panel_paste(); return 1; } -EditUndo::EditUndo(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("undo")) -{ - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Undo ( z )")); -} -EditUndo::~EditUndo() -{ -} -int EditUndo::keypress_event() -{ - if( ctrl_down() || shift_down() || alt_down() ) - return 0; - if( get_keypress() == 'z' ) - return handle_event(); - return 0; -} -int EditUndo::handle_event() -{ - mwindow->undo_entry(panel->subwindow); - return 1; -} - -EditRedo::EditRedo(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("redo")) -{ - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Redo ( shift Z )")); -} -EditRedo::~EditRedo() -{ -} -int EditRedo::keypress_event() -{ - if( ctrl_down() || !shift_down() || alt_down() ) - return 0; - if( get_keypress() == 'Z' ) - return handle_event(); - return 0; -} -int EditRedo::handle_event() -{ - mwindow->redo_entry(panel->subwindow); - return 1; -}; - - - - - -EditLabelbutton::EditLabelbutton(MWindow *mwindow, EditPanel *panel, int x, int y) - : BC_Button(x, y, mwindow->theme->get_image_set("labelbutton")) -{ - this->mwindow = mwindow; - this->panel = panel; - set_tooltip(_("Toggle label at current position ( l )")); -} - -EditLabelbutton::~EditLabelbutton() -{ -} -int EditLabelbutton::keypress_event() -{ - if( get_keypress() == 'l' && !alt_down() ) - return handle_event(); - return 0; -} -int EditLabelbutton::handle_event() -{ - panel->toggle_label(); - return 1; -} - - - - - - - +//fit_selection EditFit::EditFit(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Button(x, y, mwindow->theme->get_image_set("fit")) { @@ -1277,18 +841,11 @@ int EditFit::keypress_event() } int EditFit::handle_event() { - mwindow->fit_selection(); + panel->panel_fit_selection(); return 1; } - - - - - - - - +//fit_autos EditFitAutos::EditFitAutos(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Button(x, y, mwindow->theme->get_image_set("fitautos")) { @@ -1301,34 +858,19 @@ EditFitAutos::~EditFitAutos() } int EditFitAutos::keypress_event() { - if( !ctrl_down() && alt_down() && get_keypress() == 'f' ) { - mwindow->fit_autos(1); - return 1; - } - if( ctrl_down() && alt_down() && get_keypress() == 'f' ) { - mwindow->fit_autos(0); + if( get_keypress() == 'f' && alt_down() ) { + panel->panel_fit_autos(!ctrl_down() ? 1 : 0); return 1; } return 0; } int EditFitAutos::handle_event() { - mwindow->fit_autos(1); + panel->panel_fit_autos(1); return 1; } - - - - - - - - - - - - +//set_editing_mode ArrowButton::ArrowButton(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Toggle(x, y, mwindow->theme->get_image_set("arrow"), @@ -1344,13 +886,11 @@ int ArrowButton::handle_event() { update(1); panel->ibeam->update(0); - mwindow->set_editing_mode(EDITING_ARROW, - !panel->is_mwindow(), panel->is_mwindow()); + panel->panel_set_editing_mode(EDITING_ARROW); // Nothing after this return 1; } - IBeamButton::IBeamButton(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Toggle(x, y, mwindow->theme->get_image_set("ibeam"), @@ -1366,12 +906,12 @@ int IBeamButton::handle_event() { update(1); panel->arrow->update(0); - mwindow->set_editing_mode(EDITING_IBEAM, - !panel->is_mwindow(), panel->is_mwindow()); + panel->panel_set_editing_mode(EDITING_IBEAM); // Nothing after this return 1; } +//set_auto_keyframes KeyFrameButton::KeyFrameButton(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Toggle(x, y, mwindow->theme->get_image_set("autokeyframe"), @@ -1385,8 +925,7 @@ KeyFrameButton::KeyFrameButton(MWindow *mwindow, EditPanel *panel, int x, int y) int KeyFrameButton::handle_event() { - mwindow->set_auto_keyframes(get_value(), - !panel->is_mwindow(), panel->is_mwindow()); + panel->panel_set_auto_keyframes(get_value()); return 1; } @@ -1396,26 +935,174 @@ int KeyFrameButton::keypress_event() if( key == 'j' && !ctrl_down() && !shift_down() && !alt_down() ) { int value = get_value() ? 0 : 1; update(value); - mwindow->set_auto_keyframes(value, - !panel->is_mwindow(), panel->is_mwindow()); + panel->panel_set_auto_keyframes(value); return 1; } return 0; } -LockLabelsButton::LockLabelsButton(MWindow *mwindow, int x, int y) +//set_labels_follow_edits +LockLabelsButton::LockLabelsButton(MWindow *mwindow, EditPanel *panel, int x, int y) : BC_Toggle(x, y, mwindow->theme->get_image_set("locklabels"), mwindow->edl->session->labels_follow_edits, "", 0, 0, 0) { this->mwindow = mwindow; + this->panel = panel; set_tooltip(_("Lock labels from moving with edits")); } int LockLabelsButton::handle_event() { - mwindow->set_labels_follow_edits(get_value()); + panel->panel_set_labels_follow_edits(get_value()); + return 1; +} + + + +EditManualGoto::EditManualGoto(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Button(x, y, mwindow->theme->get_image_set("goto")) +{ + this->mwindow = mwindow; + this->panel = panel; + mangoto = new ManualGoto(mwindow, panel); + set_tooltip(_("Manual goto ( g )")); +} +EditManualGoto::~EditManualGoto() +{ + delete mangoto; +} +int EditManualGoto::handle_event() +{ + mangoto->start(); + return 1; +} + +int EditManualGoto::keypress_event() +{ + if( get_keypress() == 'g' ) { + handle_event(); + return 1; + } + return 0; +} + + +EditClick2Play::EditClick2Play(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Toggle(x, y, mwindow->theme->get_image_set("playpatch_data"), + !panel->is_vwindow() ? + mwindow->edl->session->cwindow_click2play : + mwindow->edl->session->vwindow_click2play) +{ + this->mwindow = mwindow; + this->panel = panel; + set_tooltip(_("Click to play (p)")); +} +int EditClick2Play::handle_event() +{ + int value = get_value(); + panel->set_click_to_play(value); + return 1; +} +int EditClick2Play::keypress_event() +{ + int key = get_keypress(); + if( key == 'p' && !ctrl_down() && !shift_down() && !alt_down() ) { + int value = get_value() ? 0 : 1; + update(value); + panel->set_click_to_play(value); + return 1; + } + return 0; +} + + +EditCommercial::EditCommercial(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Button(x, y, mwindow->theme->get_image_set("commercial")) +{ + this->mwindow = mwindow; + this->panel = panel; + set_tooltip(_("Commercial ( shift A )")); +} +EditCommercial::~EditCommercial() +{ +} +int EditCommercial::keypress_event() +{ + if( ctrl_down() || !shift_down() || alt_down() ) + return 0; + if( get_keypress() == 'A' ) + return handle_event(); + return 0; +} + +int EditCommercial::handle_event() +{ + int have_mwindow_lock = mwindow->gui->get_window_lock(); + if( have_mwindow_lock ) + mwindow->gui->unlock_window(); + mwindow->commit_commercial(); + if( !mwindow->put_commercial() ) { + mwindow->gui->lock_window("EditCommercial::handle_event 1"); + mwindow->cut(); + if( !have_mwindow_lock ) + mwindow->gui->unlock_window(); + mwindow->activate_commercial(); + return 1; + } + mwindow->undo_commercial(); + if( have_mwindow_lock ) + mwindow->gui->lock_window("EditCommercial::handle_event 2"); + return 1; +} + + +EditUndo::EditUndo(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Button(x, y, mwindow->theme->get_image_set("undo")) +{ + this->mwindow = mwindow; + this->panel = panel; + set_tooltip(_("Undo ( z )")); +} +EditUndo::~EditUndo() +{ +} +int EditUndo::keypress_event() +{ + if( ctrl_down() || shift_down() || alt_down() ) + return 0; + if( get_keypress() == 'z' ) + return handle_event(); + return 0; +} +int EditUndo::handle_event() +{ + mwindow->undo_entry(panel->subwindow); + return 1; +} + +EditRedo::EditRedo(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Button(x, y, mwindow->theme->get_image_set("redo")) +{ + this->mwindow = mwindow; + this->panel = panel; + set_tooltip(_("Redo ( shift Z )")); +} +EditRedo::~EditRedo() +{ +} +int EditRedo::keypress_event() +{ + if( ctrl_down() || !shift_down() || alt_down() ) + return 0; + if( get_keypress() == 'Z' ) + return handle_event(); + return 0; +} +int EditRedo::handle_event() +{ + mwindow->redo_entry(panel->subwindow); return 1; } diff --git a/cinelerra-5.1/cinelerra/editpanel.h b/cinelerra-5.1/cinelerra/editpanel.h index 67ce8a1e..9b5fe1a4 100644 --- a/cinelerra-5.1/cinelerra/editpanel.h +++ b/cinelerra-5.1/cinelerra/editpanel.h @@ -97,26 +97,6 @@ public: EditPanel *panel; }; -class EditLift : public BC_Button -{ -public: - EditLift(MWindow *mwindow, EditPanel *panel, int x, int y); - ~EditLift(); - int handle_event(); - MWindow *mwindow; - EditPanel *panel; -}; - -class EditExtract : public BC_Button -{ -public: - EditExtract(MWindow *mwindow, EditPanel *panel, int x, int y); - ~EditExtract(); - int handle_event(); - MWindow *mwindow; - EditPanel *panel; -}; - class EditToClip : public BC_Button { public: @@ -192,30 +172,6 @@ public: EditPanel *panel; }; -class EditAppend : public BC_Button -{ -public: - EditAppend(MWindow *mwindow, EditPanel *panel, int x, int y); - ~EditAppend(); - - int handle_event(); - - MWindow *mwindow; - EditPanel *panel; -}; - -class EditInsert : public BC_Button -{ -public: - EditInsert(MWindow *mwindow, EditPanel *panel, int x, int y); - ~EditInsert(); - - int handle_event(); - - MWindow *mwindow; - EditPanel *panel; -}; - class EditPaste : public BC_Button { public: @@ -229,26 +185,6 @@ public: EditPanel *panel; }; -class EditTransition : public BC_Button -{ -public: - EditTransition(MWindow *mwindow, EditPanel *panel, int x, int y); - ~EditTransition(); - int handle_event(); - MWindow *mwindow; - EditPanel *panel; -}; - -class EditPresentation : public BC_Button -{ -public: - EditPresentation(MWindow *mwindow, EditPanel *panel, int x, int y); - ~EditPresentation(); - int handle_event(); - MWindow *mwindow; - EditPanel *panel; -}; - class EditUndo : public BC_Button { public: @@ -389,9 +325,10 @@ public: class LockLabelsButton : public BC_Toggle { public: - LockLabelsButton(MWindow *mwindow, int x, int y); + LockLabelsButton(MWindow *mwindow, EditPanel *panel, int x, int y); int handle_event(); MWindow *mwindow; + EditPanel *panel; }; @@ -405,8 +342,6 @@ public: int use_keyframe, int use_splice, // Extra buttons int use_overwrite, - int use_lift, - int use_extract, int use_copy, // Use copy when in EDITING_ARROW int use_paste, int use_undo, @@ -430,20 +365,31 @@ public: void reposition_buttons(int x, int y); void create_objects(); int get_w(); - virtual void copy_selection(); - virtual void splice_selection(); - virtual void overwrite_selection(); - virtual void set_inpoint(); - virtual void set_outpoint(); - virtual void unset_inoutpoint(); - virtual void to_clip() = 0; - virtual void toggle_label(); - virtual void prev_label(int cut); - virtual void next_label(int cut); - virtual void prev_edit(int cut); - virtual void next_edit(int cut); - virtual double get_position(); - virtual void set_position(double position); + + virtual double get_position() = 0; + virtual void set_position(double position) = 0; + virtual void set_click_to_play(int v) = 0; + + virtual void panel_stop_transport() = 0; + virtual void panel_toggle_label() = 0; + virtual void panel_next_label(int cut) = 0; + virtual void panel_prev_label(int cut) = 0; + virtual void panel_prev_edit(int cut) = 0; + virtual void panel_next_edit(int cut) = 0; + virtual void panel_copy_selection() = 0; + virtual void panel_overwrite_selection() = 0; + virtual void panel_splice_selection() = 0; + virtual void panel_set_inpoint() = 0; + virtual void panel_set_outpoint() = 0; + virtual void panel_unset_inoutpoint() = 0; + virtual void panel_to_clip() = 0; + virtual void panel_cut() = 0; + virtual void panel_paste() = 0; + virtual void panel_fit_selection() = 0; + virtual void panel_fit_autos(int all) = 0; + virtual void panel_set_editing_mode(int mode) = 0; + virtual void panel_set_auto_keyframes(int v) = 0; + virtual void panel_set_labels_follow_edits(int v) = 0; MWindow *mwindow; BC_WindowBase *subwindow; @@ -456,8 +402,6 @@ public: int use_keyframe; int use_splice; int use_overwrite; - int use_lift; - int use_extract; int use_paste; int use_undo; int use_fit; @@ -479,8 +423,6 @@ public: // EditDelOutPoint *deloutpoint; EditSplice *splice; EditOverwrite *overwrite; - EditLift *lift; - EditExtract *extract; EditToClip *clip; EditCut *cut; EditCommercial *commercial; diff --git a/cinelerra-5.1/cinelerra/editpanel.inc b/cinelerra-5.1/cinelerra/editpanel.inc index 4c613a33..8b0c4147 100644 --- a/cinelerra-5.1/cinelerra/editpanel.inc +++ b/cinelerra-5.1/cinelerra/editpanel.inc @@ -26,25 +26,20 @@ #define CWINDOW_ID 1 #define VWINDOW_ID 2 +class EditPanel; class EditInPoint; class EditOutPoint; class EditDelInPoint; class EditDelOutPoint; class EditSplice; class EditOverwrite; -class EditLift; -class EditExtract; class EditToClip; class EditManualGoto; class EditCut; class EditCommercial; class EditClick2Play; class EditCopy; -class EditAppend; -class EditInsert; class EditPaste; -class EditTransition; -class EditPresentation; class EditUndo; class EditRedo; class EditLabelbutton; @@ -58,6 +53,5 @@ class ArrowButton; class IBeamButton; class KeyFrameButton; class LockLabelsButton; -class EditPanel; #endif diff --git a/cinelerra-5.1/cinelerra/mbuttons.C b/cinelerra-5.1/cinelerra/mbuttons.C index 3e650cb6..de1bd7a3 100644 --- a/cinelerra-5.1/cinelerra/mbuttons.C +++ b/cinelerra-5.1/cinelerra/mbuttons.C @@ -131,8 +131,6 @@ MainEditing::MainEditing(MWindow *mwindow, MButtons *mbuttons, int x, int y) 1, // use_keyframe 0, // use_splice 0, // use_overwrite - 1, // use_lift - 1, // use_extract 1, // use_copy 1, // use_paste 1, // use_undo @@ -150,7 +148,95 @@ MainEditing::MainEditing(MWindow *mwindow, MButtons *mbuttons, int x, int y) this->mbuttons = mbuttons; } -void MainEditing::to_clip() +double MainEditing::get_position() +{ + return mwindow->get_position(); +} + +void MainEditing::set_position(double position) +{ + mwindow->set_position(position); +} + +void MainEditing::set_click_to_play(int v) +{ +// not used +} + +void MainEditing::panel_stop_transport() +{ + mwindow->gui->stop_transport("MainEditing::stop_transport"); +} + +void MainEditing::panel_toggle_label() +{ + mwindow->toggle_label(); +} + +void MainEditing::panel_next_label(int cut) +{ + int shift_down = mwindow->gui->shift_down(); + panel_stop_transport(); + if( cut ) + mwindow->cut_right_label(); + else + mwindow->next_label(shift_down); +} + +void MainEditing::panel_prev_label(int cut) +{ + int shift_down = mwindow->gui->shift_down(); + panel_stop_transport(); + if( cut ) + mwindow->cut_left_label(); + else + mwindow->prev_label(shift_down); +} + +void MainEditing::panel_prev_edit(int cut) +{ + int shift_down = subwindow->shift_down(); + panel_stop_transport(); + if( cut ) + mwindow->cut_left_edit(); + else + mwindow->prev_edit_handle(shift_down); +} + +void MainEditing::panel_next_edit(int cut) +{ + int shift_down = subwindow->shift_down(); + panel_stop_transport(); + if( cut ) + mwindow->cut_right_edit(); + else + mwindow->next_edit_handle(shift_down); +} + +void MainEditing::panel_copy_selection() +{ + mwindow->copy(); +} + +void MainEditing::panel_overwrite_selection() {} // not used +void MainEditing::panel_splice_selection() {} // not used + +void MainEditing::panel_set_inpoint() +{ + mwindow->set_inpoint(); +} + +void MainEditing::panel_set_outpoint() +{ + mwindow->set_outpoint(); +} + +void MainEditing::panel_unset_inoutpoint() +{ + mwindow->unset_inoutpoint(); +} + +void MainEditing::panel_to_clip() { MWindowGUI *gui = mwindow->gui; gui->unlock_window(); @@ -159,3 +245,38 @@ void MainEditing::to_clip() } +void MainEditing::panel_cut() +{ + mwindow->cut(); +} + +void MainEditing::panel_paste() +{ + mwindow->paste(); +} + +void MainEditing::panel_fit_selection() +{ + mwindow->fit_selection(); +} + +void MainEditing::panel_fit_autos(int all) +{ + mwindow->fit_autos(all); +} + +void MainEditing::panel_set_editing_mode(int mode) +{ + mwindow->set_editing_mode(mode); +} + +void MainEditing::panel_set_auto_keyframes(int v) +{ + mwindow->set_auto_keyframes(v); +} + +void MainEditing::panel_set_labels_follow_edits(int v) +{ + mwindow->set_labels_follow_edits(v); +} + diff --git a/cinelerra-5.1/cinelerra/mbuttons.h b/cinelerra-5.1/cinelerra/mbuttons.h index bc8f8a64..0e8771f3 100644 --- a/cinelerra-5.1/cinelerra/mbuttons.h +++ b/cinelerra-5.1/cinelerra/mbuttons.h @@ -81,7 +81,31 @@ class MainEditing : public EditPanel public: MainEditing(MWindow *mwindow, MButtons *mbuttons, int x, int y); virtual ~MainEditing() {} - void to_clip(); + + double get_position(); + void set_position(double position); + void set_click_to_play(int v); + + void panel_stop_transport(); + void panel_toggle_label(); + void panel_next_label(int cut); + void panel_prev_label(int cut); + void panel_prev_edit(int cut); + void panel_next_edit(int cut); + void panel_copy_selection(); + void panel_overwrite_selection(); + void panel_splice_selection(); + void panel_set_inpoint(); + void panel_set_outpoint(); + void panel_unset_inoutpoint(); + void panel_to_clip(); + void panel_cut(); + void panel_paste(); + void panel_fit_selection(); + void panel_fit_autos(int all); + void panel_set_editing_mode(int mode); + void panel_set_auto_keyframes(int v); + void panel_set_labels_follow_edits(int v); MWindow *mwindow; MButtons *mbuttons; diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index af743cc7..f62df89b 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -199,6 +199,7 @@ MWindow::MWindow() playback_3d = 0; splash_window = 0; undo = 0; + undo_command = COMMAND_NONE; defaults = 0; assets = 0; //commercials = 0; @@ -1366,7 +1367,7 @@ void MWindow::create_mixers() { if( !session->drag_assets->size() && !session->drag_clips->size() ) return; - undo->update_undo_before(); + undo_before(); select_zwindow(0); ArrayListnew_mixers; @@ -1390,7 +1391,7 @@ void MWindow::create_mixers() refresh_mixers(); save_backup(); - undo->update_undo_after(_("create mixers"), LOAD_ALL); + undo_after(_("create mixers"), LOAD_ALL); restart_brender(); gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0); sync_parameters(CHANGE_ALL); @@ -1814,6 +1815,28 @@ void MWindow::stop_transport() gui->stop_transport(gui->get_window_lock() ? "MWindow::stop_transport" : 0); } +void MWindow::undo_before(const char *description, void *creator) +{ + if( cwindow->playback_engine->is_playing_back ) { + undo_command = cwindow->playback_engine->command->command; + cwindow->playback_engine->que->send_command(STOP, CHANGE_NONE, 0, 0); + gui->unlock_window(); + cwindow->playback_engine->interrupt_playback(1); + gui->lock_window(description); + } + undo->update_undo_before(description, creator); +} + +void MWindow::undo_after(const char *description, uint32_t load_flags, int changes_made) +{ + if( undo_command != COMMAND_NONE ) { + cwindow->playback_engine->que->send_command(undo_command, CHANGE_NONE, edl, 1, 0); + undo_command = COMMAND_NONE; + } + + undo->update_undo_after(description, load_flags, changes_made); +} + void MWindow::beep(double freq, double secs, double gain) { if( !proxy_beep ) proxy_beep = new ProxyBeep(this); @@ -1840,7 +1863,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); gui->lock_window("MWindow::load_filenames 0"); if(debug) printf("MWindow::load_filenames %d\n", __LINE__); - undo->update_undo_before(); + undo_before(); if(debug) printf("MWindow::load_filenames %d\n", __LINE__); @@ -2239,7 +2262,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); // need to update undo before project, since mwindow is unlocked & a new load // can begin here. Should really prevent loading until we're done. if(debug) printf("MWindow::load_filenames %d\n", __LINE__); - undo->update_undo_after(_("load"), LOAD_ALL); + undo_after(_("load"), LOAD_ALL); for(int i = 0; i < new_edls.size(); i++) { @@ -2353,7 +2376,7 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) edl->Garbage::add_user(); save_backup(); - undo->update_undo_before(_("proxy"), this); + undo_before(_("proxy"), this); ProxyRender proxy_render(this, asset); // revert project to original size from current size @@ -2466,7 +2489,7 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) edl->set_proxy(new_scale, new_use_scaler, &proxy_render.orig_idxbls, &proxy_render.orig_proxies); - undo->update_undo_after(_("proxy"), LOAD_ALL); + undo_after(_("proxy"), LOAD_ALL); edl->Garbage::remove_user(); restart_brender(); @@ -2975,18 +2998,15 @@ void MWindow::set_screens(int value) screens = value; } -void MWindow::set_auto_keyframes(int value, int lock_mwindow, int lock_cwindow) +void MWindow::set_auto_keyframes(int value) { - if(lock_mwindow) gui->lock_window("MWindow::set_auto_keyframes"); edl->session->auto_keyframes = value; gui->mbuttons->edit_panel->keyframe->update(value); gui->flush(); - if(lock_mwindow) gui->unlock_window(); - - if(lock_cwindow) cwindow->gui->lock_window("MWindow::set_auto_keyframes"); + cwindow->gui->lock_window("MWindow::set_auto_keyframes"); cwindow->gui->edit_panel->keyframe->update(value); cwindow->gui->flush(); - if(lock_cwindow) cwindow->gui->unlock_window(); + cwindow->gui->unlock_window(); } void MWindow::set_auto_visibility(Autos *autos, int value) @@ -3013,20 +3033,17 @@ void MWindow::set_keyframe_type(int mode) gui->unlock_window(); } -int MWindow::set_editing_mode(int new_editing_mode, int lock_mwindow, int lock_cwindow) +int MWindow::set_editing_mode(int new_editing_mode) { - if(lock_mwindow) gui->lock_window("MWindow::set_editing_mode"); edl->session->editing_mode = new_editing_mode; gui->mbuttons->edit_panel->editing_mode = edl->session->editing_mode; gui->mbuttons->edit_panel->update(); gui->set_editing_mode(1); - if(lock_mwindow) gui->unlock_window(); - - if(lock_cwindow) cwindow->gui->lock_window("MWindow::set_editing_mode"); + cwindow->gui->lock_window("MWindow::set_editing_mode"); cwindow->gui->edit_panel->update(); cwindow->gui->edit_panel->editing_mode = edl->session->editing_mode; - if(lock_cwindow) cwindow->gui->unlock_window(); + cwindow->gui->unlock_window(); return 0; } @@ -3034,9 +3051,9 @@ void MWindow::toggle_editing_mode() { int mode = edl->session->editing_mode; if( mode == EDITING_ARROW ) - set_editing_mode(EDITING_IBEAM, 0, 1); + set_editing_mode(EDITING_IBEAM); else - set_editing_mode(EDITING_ARROW, 0, 1); + set_editing_mode(EDITING_ARROW); } void MWindow::toggle_camera_xyz() @@ -3055,12 +3072,10 @@ void MWindow::toggle_projector_xyz() void MWindow::set_labels_follow_edits(int value) { - gui->lock_window("MWindow::set_labels_follow_edits"); edl->session->labels_follow_edits = value; gui->mbuttons->edit_panel->locklabels->update(value); gui->mainmenu->labels_follow_edits->set_checked(value); gui->flush(); - gui->unlock_window(); } void MWindow::sync_parameters(int change_type) @@ -3796,8 +3811,8 @@ void MWindow::load_backup() void MWindow::save_undo_data() { - undo->update_undo_before(); - undo->update_undo_after(_("perpetual session"), LOAD_ALL); + undo_before(); + undo_after(_("perpetual session"), LOAD_ALL); char perpetual_path[BCTEXTLEN]; snprintf(perpetual_path, sizeof(perpetual_path), "%s/%s", File::get_config_path(), PERPETUAL_FILE); @@ -4131,11 +4146,11 @@ void MWindow::remove_assets_from_project(int push_undo, int redraw, } //printf("MWindow::rebuild_indices 1 %s\n", indexable->path); - if(push_undo) undo->update_undo_before(); + if(push_undo) undo_before(); if(drag_assets) edl->remove_from_project(drag_assets); if(drag_clips) edl->remove_from_project(drag_clips); if(redraw) save_backup(); - if(push_undo) undo->update_undo_after(_("remove assets"), LOAD_ALL); + if(push_undo) undo_after(_("remove assets"), LOAD_ALL); if(redraw) { restart_brender(); @@ -4518,7 +4533,7 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra session->auto_keyframes = 0; int result = file->open_file(preferences, asset, 1, 0); if( !result && delete_tracks > 0 ) - undo->update_undo_before(); + undo_before(); int video_layers = asset->get_video_layers(); if( !result && asset->video_data && vstream < video_layers ) { // try to get asset up to date, may fail @@ -4614,7 +4629,7 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra session->auto_keyframes = old_auto_keyframes; if( !result && delete_tracks > 0 ) { save_backup(); - undo->update_undo_after(_("select asset"), LOAD_ALL); + undo_after(_("select asset"), LOAD_ALL); } resync_guis(); return result; diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h index 7950659b..0a9dfb95 100644 --- a/cinelerra-5.1/cinelerra/mwindow.h +++ b/cinelerra-5.1/cinelerra/mwindow.h @@ -103,8 +103,6 @@ #define FONT_SEARCHPATH "fonts" -// All entry points for commands except for window locking should be here. -// This allows scriptability. class MWindow : public Thread { @@ -188,7 +186,7 @@ public: int edit_labels, int edit_autos, int edit_plugins); void selected_edits_to_clipboard(int packed); // Fit selected autos to the vertical display range - void fit_autos(int doall); + void fit_autos(int all); void change_currentautorange(int autogrouptype, int increment, int changemax); void expand_autos(int changeall, int domin, int domax); void shrink_autos(int changeall, int domin, int domax); @@ -210,6 +208,8 @@ public: void dump_plugindb(FILE *fp); void stop_playback(int wait); void stop_transport(); + void undo_before(const char *description = "", void *creator = 0); + void undo_after(const char *description, uint32_t load_flags, int changes_made = 1); void queue_mixers(EDL *edl, int command, int wait_tracking, int use_inout, int update_refresh, int toggle_audio, int loop_play); @@ -261,6 +261,8 @@ public: int find_selection(double position, int scroll_display = 0); void toggle_camera_xyz(); void toggle_projector_xyz(); + double get_position(); + void set_position(double position); // seek to labels // shift_down must be passed by the caller because different windows call @@ -473,16 +475,16 @@ public: void set_automation_mode(int mode); void set_keyframe_type(int mode); - void set_auto_keyframes(int value, int lock_mwindow, int lock_cwindow); + void set_auto_keyframes(int value); void set_auto_visibility(Autos *autos, int value); void set_labels_follow_edits(int value); // Update the editing mode - int set_editing_mode(int new_editing_mode, int lock_mwindow, int lock_cwindow); + int set_editing_mode(int new_editing_mode); void toggle_editing_mode(); - void set_inpoint(int is_mwindow); - void set_outpoint(int is_mwindow); - void unset_inoutpoint(int is_mwindow); + void set_inpoint(); + void set_outpoint(); + void unset_inoutpoint(); void toggle_loop_playback(); void trim_selection(); // Synchronize EDL settings with all playback engines depending on current @@ -490,7 +492,7 @@ public: void sync_parameters(int change_type = CHANGE_PARAMS); void save_clip(EDL *new_edl, const char *txt); void to_clip(EDL *edl, const char *txt, int all); - int toggle_label(int is_mwindow); + int toggle_label(); void undo_entry(BC_WindowBase *calling_window_gui); void redo_entry(BC_WindowBase *calling_window_gui); void save_undo_data(); @@ -551,6 +553,8 @@ public: // Main undo stack MainUndo *undo; + int undo_command; + BC_Hash *defaults; Assets *assets; // CICaches for drawing timeline only diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index 7249f67a..17e74a90 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -83,10 +83,10 @@ void MWindow::add_audio_track_entry(int above, Track *dst) { - undo->update_undo_before(); + undo_before(); add_audio_track(above, dst); save_backup(); - undo->update_undo_after(_("add track"), LOAD_ALL); + undo_after(_("add track"), LOAD_ALL); restart_brender(); gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0); @@ -103,9 +103,9 @@ void MWindow::add_audio_track_entry(int above, Track *dst) void MWindow::add_video_track_entry(Track *dst) { - undo->update_undo_before(); + undo_before(); add_video_track(1, dst); - undo->update_undo_after(_("add track"), LOAD_ALL); + undo_after(_("add track"), LOAD_ALL); restart_brender(); @@ -123,9 +123,9 @@ void MWindow::add_video_track_entry(Track *dst) void MWindow::add_subttl_track_entry(Track *dst) { - undo->update_undo_before(); + undo_before(); add_subttl_track(1, dst); - undo->update_undo_after(_("add track"), LOAD_ALL); + undo_after(_("add track"), LOAD_ALL); restart_brender(); @@ -175,7 +175,7 @@ void MWindow::asset_to_all() { int w, h; - undo->update_undo_before(); + undo_before(); // Get w and h w = indexable->get_w(); @@ -229,7 +229,7 @@ void MWindow::asset_to_all() save_backup(); - undo->update_undo_after(_("asset to all"), LOAD_ALL); + undo_after(_("asset to all"), LOAD_ALL); restart_brender(); gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0); sync_parameters(CHANGE_ALL); @@ -243,7 +243,7 @@ void MWindow::asset_to_size() if( indexable->have_video() ) { int w, h; - undo->update_undo_before(); + undo_before(); // Get w and h w = indexable->get_w(); @@ -269,7 +269,7 @@ void MWindow::asset_to_size() save_backup(); - undo->update_undo_after(_("asset to size"), LOAD_ALL); + undo_after(_("asset to size"), LOAD_ALL); restart_brender(); sync_parameters(CHANGE_ALL); } @@ -282,14 +282,14 @@ void MWindow::asset_to_rate() session->drag_assets->get(0)->have_video() ) { double new_framerate = session->drag_assets->get(0)->get_frame_rate(); double old_framerate = edl->session->frame_rate; - undo->update_undo_before(); + undo_before(); edl->session->frame_rate = new_framerate; edl->resample(old_framerate, new_framerate, TRACK_VIDEO); save_backup(); - undo->update_undo_after(_("asset to rate"), LOAD_ALL); + undo_after(_("asset to rate"), LOAD_ALL); restart_brender(); gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0); sync_parameters(CHANGE_ALL); @@ -299,12 +299,12 @@ void MWindow::asset_to_rate() void MWindow::clear_entry() { - undo->update_undo_before(); + undo_before(); clear(1); edl->optimize(); save_backup(); - undo->update_undo_after(_("clear"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("clear"), LOAD_EDITS | LOAD_TIMEBAR); restart_brender(); update_plugin_guis(); @@ -345,7 +345,7 @@ void MWindow::update_gui(int changed_edl) void MWindow::set_automation_mode(int mode) { - undo->update_undo_before(); + undo_before(); speed_before(); edl->tracks->set_automation_mode( edl->local_session->get_selectionstart(), @@ -355,7 +355,7 @@ void MWindow::set_automation_mode(int mode) save_backup(); char string[BCSTRLEN]; sprintf(string,"set %s", FloatAuto::curve_name(mode)); - undo->update_undo_after(string, + undo_after(string, !changed_edl ? LOAD_AUTOMATION : LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR); update_gui(changed_edl); @@ -363,13 +363,13 @@ void MWindow::set_automation_mode(int mode) void MWindow::clear_automation() { - undo->update_undo_before(); + undo_before(); speed_before(); edl->tracks->clear_automation(edl->local_session->get_selectionstart(), edl->local_session->get_selectionend()); int changed_edl = speed_after(1); save_backup(); - undo->update_undo_after(_("clear keyframes"), + undo_after(_("clear keyframes"), !changed_edl ? LOAD_AUTOMATION : LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR); update_gui(changed_edl); @@ -377,12 +377,12 @@ void MWindow::clear_automation() int MWindow::clear_default_keyframe() { - undo->update_undo_before(); + undo_before(); speed_before(); edl->tracks->clear_default_keyframe(); int changed_edl = speed_after(1); save_backup(); - undo->update_undo_after(_("clear default keyframe"), + undo_after(_("clear default keyframe"), !changed_edl ? LOAD_AUTOMATION : LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR); update_gui(changed_edl); @@ -391,10 +391,10 @@ int MWindow::clear_default_keyframe() void MWindow::clear_labels() { - undo->update_undo_before(); + undo_before(); clear_labels(edl->local_session->get_selectionstart(), edl->local_session->get_selectionend()); - undo->update_undo_after(_("clear labels"), LOAD_TIMEBAR); + undo_after(_("clear labels"), LOAD_TIMEBAR); gui->update_timebar(1); cwindow->update(0, 0, 0, 0, 1); @@ -409,11 +409,11 @@ int MWindow::clear_labels(double start, double end) void MWindow::concatenate_tracks() { - undo->update_undo_before(); + undo_before(); edl->tracks->concatenate_tracks(edl->session->plugins_follow_edits, edl->session->autos_follow_edits); save_backup(); - undo->update_undo_after(_("concatenate tracks"), LOAD_EDITS); + undo_after(_("concatenate tracks"), LOAD_EDITS); restart_brender(); gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0); @@ -473,7 +473,7 @@ int MWindow::copy_default_keyframe() void MWindow::crop_video() { - undo->update_undo_before(); + undo_before(); // Clamp EDL crop region if( edl->session->crop_x1 > edl->session->crop_x2 ) { edl->session->crop_x1 ^= edl->session->crop_x2; @@ -510,7 +510,7 @@ void MWindow::crop_video() edl->session->output_h); } - undo->update_undo_after(_("crop"), LOAD_ALL); + undo_after(_("crop"), LOAD_ALL); restart_brender(); cwindow->refresh_frame(CHANGE_ALL); @@ -529,11 +529,11 @@ void MWindow::cut() void MWindow::blade(double position) { - undo->update_undo_before(); + undo_before(); edl->blade(position); edl->optimize(); save_backup(); - undo->update_undo_after(_("blade"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("blade"), LOAD_EDITS | LOAD_TIMEBAR); restart_brender(); update_plugin_guis(); gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0); @@ -544,7 +544,7 @@ void MWindow::blade(double position) void MWindow::cut(double start, double end, double new_position) { - undo->update_undo_before(); + undo_before(); copy(start, end); edl->clear(start, end, edl->session->labels_follow_edits, @@ -553,7 +553,7 @@ void MWindow::cut(double start, double end, double new_position) edl->optimize(); save_backup(); - undo->update_undo_after(_("split | cut"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("split | cut"), LOAD_EDITS | LOAD_TIMEBAR); if( new_position >= 0 ) { edl->local_session->set_selectionstart(new_position); edl->local_session->set_selectionend(new_position); @@ -604,14 +604,14 @@ void MWindow::cut_right_label() int MWindow::cut_automation() { - undo->update_undo_before(); + undo_before(); speed_before(); copy_automation(); edl->tracks->clear_automation(edl->local_session->get_selectionstart(), edl->local_session->get_selectionend()); int changed_edl = speed_after(1); save_backup(); - undo->update_undo_after(_("cut keyframes"), + undo_after(_("cut keyframes"), !changed_edl ? LOAD_AUTOMATION : LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR); update_gui(changed_edl); @@ -621,13 +621,13 @@ int MWindow::cut_automation() int MWindow::cut_default_keyframe() { - undo->update_undo_before(); + undo_before(); speed_before(); copy_default_keyframe(); edl->tracks->clear_default_keyframe(); int changed_edl = speed_after(1); save_backup(); - undo->update_undo_after(_("cut default keyframe"), + undo_after(_("cut default keyframe"), !changed_edl ? LOAD_AUTOMATION : LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR); update_gui(changed_edl); @@ -643,9 +643,9 @@ void MWindow::delete_track() void MWindow::delete_tracks() { - undo->update_undo_before(); + undo_before(); edl->tracks->delete_tracks(); - undo->update_undo_after(_("delete tracks"), LOAD_ALL); + undo_after(_("delete tracks"), LOAD_ALL); save_backup(); restart_brender(); @@ -657,9 +657,9 @@ void MWindow::delete_tracks() void MWindow::delete_track(Track *track) { - undo->update_undo_before(); + undo_before(); edl->tracks->delete_track(track); - undo->update_undo_after(_("delete track"), LOAD_ALL); + undo_after(_("delete track"), LOAD_ALL); restart_brender(); update_plugin_states(); @@ -717,7 +717,7 @@ void MWindow::insert_effects_canvas(double start, Track *dest_track = session->track_highlighted; if( !dest_track ) return; - undo->update_undo_before(); + undo_before(); for( int i=0; idrag_pluginservers->total; ++i ) { PluginServer *plugin = session->drag_pluginservers->values[i]; @@ -727,7 +727,7 @@ void MWindow::insert_effects_canvas(double start, } save_backup(); - undo->update_undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES); + undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES); restart_brender(); sync_parameters(CHANGE_EDL); // GUI updated in TrackCanvas, after current_operations are reset @@ -737,7 +737,7 @@ void MWindow::insert_effects_cwindow(Track *dest_track) { if( !dest_track ) return; - undo->update_undo_before(); + undo_before(); double start = 0; double length = dest_track->get_length(); @@ -756,7 +756,7 @@ void MWindow::insert_effects_cwindow(Track *dest_track) } save_backup(); - undo->update_undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES); + undo_after(_("insert effect"), LOAD_EDITS | LOAD_PATCHES); restart_brender(); sync_parameters(CHANGE_EDL); gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0); @@ -824,7 +824,7 @@ void MWindow::insert_effect(char *title, int MWindow::modify_edithandles() { - undo->update_undo_before(); + undo_before(); int handle_mode = edl->session->edit_handle_mode[session->drag_button]; edl->modify_edithandles(session->drag_start, session->drag_position, session->drag_handle, handle_mode, @@ -839,7 +839,7 @@ int MWindow::modify_edithandles() int MWindow::modify_pluginhandles() { - undo->update_undo_before(); + undo_before(); edl->modify_pluginhandles(session->drag_start, session->drag_position, @@ -875,7 +875,7 @@ void MWindow::finish_modify_handles() edl->local_session->set_selectionstart(position); edl->local_session->set_selectionend(position); } - undo->update_undo_after(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR); save_backup(); restart_brender(); @@ -889,11 +889,11 @@ void MWindow::finish_modify_handles() void MWindow::match_output_size(Track *track) { - undo->update_undo_before(); + undo_before(); track->track_w = edl->session->output_w; track->track_h = edl->session->output_h; save_backup(); - undo->update_undo_after(_("match output size"), LOAD_ALL); + undo_after(_("match output size"), LOAD_ALL); restart_brender(); sync_parameters(CHANGE_EDL); @@ -1095,13 +1095,13 @@ void MWindow::delete_edit(Edit *edit, const char *msg, int collapse) void MWindow::delete_edits(ArrayList *edits, const char *msg, int collapse) { if( !edits->size() ) return; - undo->update_undo_before(); + undo_before(); if( edl->session->labels_follow_edits ) edl->delete_edit_labels(edits, collapse); edl->delete_edits(edits, collapse); edl->optimize(); save_backup(); - undo->update_undo_after(msg, LOAD_EDITS); + undo_after(msg, LOAD_EDITS); restart_brender(); cwindow->refresh_frame(CHANGE_EDL); @@ -1130,7 +1130,7 @@ void MWindow::cut_selected_edits(int collapse, int packed) void MWindow::move_edits(ArrayList *edits, Track *track, double position, int mode) { - undo->update_undo_before(); + undo_before(); // lockout timebar labels update // labels can be deleted with tooltip repeater running cwindow->gui->lock_window("Tracks::move_edits"); @@ -1142,7 +1142,7 @@ void MWindow::move_edits(ArrayList *edits, cwindow->gui->unlock_window(); save_backup(); - undo->update_undo_after(_("move edit"), LOAD_ALL); + undo_after(_("move edit"), LOAD_ALL); restart_brender(); cwindow->refresh_frame(CHANGE_EDL); @@ -1291,11 +1291,11 @@ void MWindow::paste_clipboard(Track *first_track, double position, int overwrite EDL *clip = new EDL(); clip->create_objects(); if( !clip->load_xml(&file, LOAD_ALL) ) { - undo->update_undo_before(); + undo_before(); paste_edits(clip, first_track, position, overwrite, edit_edits, edit_labels, edit_autos, edit_plugins); save_backup(); - undo->update_undo_after(_("paste clip"), LOAD_ALL); + undo_after(_("paste clip"), LOAD_ALL); restart_brender(); cwindow->refresh_frame(CHANGE_EDL); @@ -1307,7 +1307,7 @@ void MWindow::paste_clipboard(Track *first_track, double position, int overwrite void MWindow::move_group(EDL *group, Track *first_track, double position, int overwrite) { - undo->update_undo_before(); + undo_before(); // lockout timebar labels update // labels can be deleted with tooltip repeater running cwindow->gui->lock_window("Tracks::move_group"); @@ -1327,7 +1327,7 @@ void MWindow::move_group(EDL *group, Track *first_track, double position, int ov // edl->tracks->clear_selected_edits(); save_backup(); - undo->update_undo_after(_("move group"), LOAD_ALL); + undo_after(_("move group"), LOAD_ALL); restart_brender(); cwindow->refresh_frame(CHANGE_EDL); @@ -1337,10 +1337,10 @@ void MWindow::move_group(EDL *group, Track *first_track, double position, int ov void MWindow::move_effect(Plugin *plugin, Track *track, int64_t position) { - undo->update_undo_before(); + undo_before(); edl->tracks->move_effect(plugin, track, position); save_backup(); - undo->update_undo_after(_("paste effect"), LOAD_ALL); + undo_after(_("paste effect"), LOAD_ALL); restart_brender(); cwindow->refresh_frame(CHANGE_EDL); @@ -1350,10 +1350,10 @@ void MWindow::move_effect(Plugin *plugin, Track *track, int64_t position) void MWindow::move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position) { - undo->update_undo_before(); + undo_before(); edl->tracks->move_effect(plugin, plugin_set, position); save_backup(); - undo->update_undo_after(_("move effect"), LOAD_ALL); + undo_after(_("move effect"), LOAD_ALL); restart_brender(); cwindow->refresh_frame(CHANGE_EDL); @@ -1364,11 +1364,11 @@ void MWindow::move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t positio void MWindow::move_plugins_up(PluginSet *plugin_set) { - undo->update_undo_before(); + undo_before(); plugin_set->track->move_plugins_up(plugin_set); save_backup(); - undo->update_undo_after(_("move effect up"), LOAD_ALL); + undo_after(_("move effect up"), LOAD_ALL); restart_brender(); gui->update(1, NORMAL_DRAW, 0, 0, 0, 0, 0); sync_parameters(CHANGE_EDL); @@ -1376,12 +1376,12 @@ void MWindow::move_plugins_up(PluginSet *plugin_set) void MWindow::move_plugins_down(PluginSet *plugin_set) { - undo->update_undo_before(); + undo_before(); plugin_set->track->move_plugins_down(plugin_set); save_backup(); - undo->update_undo_after(_("move effect down"), LOAD_ALL); + undo_after(_("move effect down"), LOAD_ALL); restart_brender(); gui->update(1, NORMAL_DRAW, 0, 0, 0, 0, 0); sync_parameters(CHANGE_EDL); @@ -1389,10 +1389,10 @@ void MWindow::move_plugins_down(PluginSet *plugin_set) void MWindow::move_track_down(Track *track) { - undo->update_undo_before(); + undo_before(); edl->tracks->move_track_down(track); save_backup(); - undo->update_undo_after(_("move track down"), LOAD_ALL); + undo_after(_("move track down"), LOAD_ALL); restart_brender(); gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0); @@ -1402,10 +1402,10 @@ void MWindow::move_track_down(Track *track) void MWindow::move_tracks_down() { - undo->update_undo_before(); + undo_before(); edl->tracks->move_tracks_down(); save_backup(); - undo->update_undo_after(_("move tracks down"), LOAD_ALL); + undo_after(_("move tracks down"), LOAD_ALL); restart_brender(); gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0); @@ -1415,10 +1415,10 @@ void MWindow::move_tracks_down() void MWindow::move_track_up(Track *track) { - undo->update_undo_before(); + undo_before(); edl->tracks->move_track_up(track); save_backup(); - undo->update_undo_after(_("move track up"), LOAD_ALL); + undo_after(_("move track up"), LOAD_ALL); restart_brender(); gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0); sync_parameters(CHANGE_EDL); @@ -1427,10 +1427,10 @@ void MWindow::move_track_up(Track *track) void MWindow::move_tracks_up() { - undo->update_undo_before(); + undo_before(); edl->tracks->move_tracks_up(); save_backup(); - undo->update_undo_after(_("move tracks up"), LOAD_ALL); + undo_after(_("move tracks up"), LOAD_ALL); restart_brender(); gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0); sync_parameters(CHANGE_EDL); @@ -1442,7 +1442,7 @@ void MWindow::mute_selection() double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); if( start != end ) { - undo->update_undo_before(); + undo_before(); edl->clear(start, end, 0, edl->session->plugins_follow_edits, edl->session->autos_follow_edits); @@ -1453,7 +1453,7 @@ void MWindow::mute_selection() edl->session->autos_follow_edits); save_backup(); - undo->update_undo_after(_("mute"), LOAD_EDITS); + undo_after(_("mute"), LOAD_EDITS); restart_brender(); update_plugin_guis(); @@ -1480,7 +1480,7 @@ void MWindow::overwrite(EDL *source, int all) double dst_start = edl->local_session->get_selectionstart(); double dst_len = edl->local_session->get_selectionend() - dst_start; - undo->update_undo_before(); + undo_before(); if( !EQUIV(dst_len, 0) && (dst_len < overwrite_len) ) { // in/out points or selection present and shorter than overwrite range // shorten the copy range @@ -1502,7 +1502,7 @@ void MWindow::overwrite(EDL *source, int all) edl->local_session->set_selectionend(dst_start + overwrite_len); save_backup(); - undo->update_undo_after(_("overwrite"), LOAD_EDITS); + undo_after(_("overwrite"), LOAD_EDITS); restart_brender(); update_plugin_guis(); @@ -1538,7 +1538,7 @@ void MWindow::paste(double start, Track *first_track, int clear_selection, int o if( len ) { char *string = new char[len]; - undo->update_undo_before(); + undo_before(); gui->from_clipboard(string, len, BC_PRIMARY_SELECTION); FileXML file; file.read_from_string(string); @@ -1555,7 +1555,7 @@ void MWindow::paste(double start, Track *first_track, int clear_selection, int o save_backup(); - undo->update_undo_after(_("paste"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("paste"), LOAD_EDITS | LOAD_TIMEBAR); restart_brender(); update_plugin_guis(); gui->update(1, FORCE_REDRAW, 1, 1, 0, 1, 0); @@ -1568,7 +1568,7 @@ void MWindow::paste(double start, Track *first_track, int clear_selection, int o int MWindow::paste_assets(double position, Track *dest_track, int overwrite) { int result = 0; - undo->update_undo_before(); + undo_before(); if( session->drag_assets->total ) { load_assets(session->drag_assets, @@ -1592,7 +1592,7 @@ int MWindow::paste_assets(double position, Track *dest_track, int overwrite) save_backup(); - undo->update_undo_after(_("paste assets"), LOAD_EDITS); + undo_after(_("paste assets"), LOAD_EDITS); restart_brender(); gui->update(1, FORCE_REDRAW, 1, 0, 0, 1, 0); sync_parameters(CHANGE_EDL); @@ -1653,7 +1653,7 @@ int MWindow::paste_automation() int64_t len = gui->clipboard_len(BC_PRIMARY_SELECTION); if( len ) { - undo->update_undo_before(); + undo_before(); speed_before(); char *string = new char[len]; gui->from_clipboard(string, len, BC_PRIMARY_SELECTION); @@ -1667,7 +1667,7 @@ int MWindow::paste_automation() edl->session->typeless_keyframes); int changed_edl = speed_after(1); save_backup(); - undo->update_undo_after(_("paste keyframes"), + undo_after(_("paste keyframes"), !changed_edl ? LOAD_AUTOMATION : LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR); update_gui(changed_edl); @@ -1681,7 +1681,7 @@ int MWindow::paste_default_keyframe() int64_t len = gui->clipboard_len(BC_PRIMARY_SELECTION); if( len ) { - undo->update_undo_before(); + undo_before(); speed_before(); char *string = new char[len]; gui->from_clipboard(string, len, BC_PRIMARY_SELECTION); @@ -1693,7 +1693,7 @@ int MWindow::paste_default_keyframe() edl->session->typeless_keyframes); // edl->tracks->paste_default_keyframe(&file); int changed_edl = speed_after(1); - undo->update_undo_after(_("paste default keyframe"), + undo_after(_("paste default keyframe"), !changed_edl ? LOAD_AUTOMATION : LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR); save_backup(); @@ -2009,14 +2009,14 @@ void MWindow::paste_silence() if( edl->session->frame_rate > 0 ) end += 1./edl->session->frame_rate; } - undo->update_undo_before(_("silence"), this); + undo_before(_("silence"), this); edl->paste_silence(start, end, edl->session->labels_follow_edits, edl->session->plugins_follow_edits, edl->session->autos_follow_edits); edl->optimize(); save_backup(); - undo->update_undo_after(_("silence"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("silence"), LOAD_EDITS | LOAD_TIMEBAR); update_plugin_guis(); restart_brender(); @@ -2027,12 +2027,12 @@ void MWindow::paste_silence() void MWindow::detach_transition(Transition *transition) { - undo->update_undo_before(); + undo_before(); hide_plugin(transition, 1); int is_video = (transition->edit->track->data_type == TRACK_VIDEO); transition->edit->detach_transition(); save_backup(); - undo->update_undo_after(_("detach transition"), LOAD_ALL); + undo_after(_("detach transition"), LOAD_ALL); if( is_video ) restart_brender(); gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0); @@ -2043,13 +2043,13 @@ void MWindow::detach_transitions() { gui->lock_window("MWindow::detach_transitions 1"); - undo->update_undo_before(); + undo_before(); double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); edl->tracks->clear_transitions(start, end); save_backup(); - undo->update_undo_after(_("detach transitions"), LOAD_EDITS); + undo_after(_("detach transitions"), LOAD_EDITS); sync_parameters(CHANGE_EDL); gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0); @@ -2061,10 +2061,10 @@ void MWindow::paste_transition() // Only the first transition gets dropped. PluginServer *server = session->drag_pluginservers->values[0]; - undo->update_undo_before(); + undo_before(); edl->tracks->paste_transition(server, session->edit_highlighted); save_backup(); - undo->update_undo_after(_("transition"), LOAD_EDITS); + undo_after(_("transition"), LOAD_EDITS); if( server->video ) restart_brender(); sync_parameters(CHANGE_ALL); @@ -2074,12 +2074,12 @@ void MWindow::paste_transitions(int track_type, char *title) { gui->lock_window("MWindow::detach_transitions 1"); - undo->update_undo_before(); + undo_before(); double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); edl->tracks->paste_transitions(start, end, track_type, title); save_backup(); - undo->update_undo_after(_("attach transitions"), LOAD_EDITS); + undo_after(_("attach transitions"), LOAD_EDITS); sync_parameters(CHANGE_EDL); gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0); @@ -2089,10 +2089,10 @@ void MWindow::paste_transitions(int track_type, char *title) void MWindow::paste_transition_cwindow(Track *dest_track) { PluginServer *server = session->drag_pluginservers->values[0]; - undo->update_undo_before(); + undo_before(); edl->tracks->paste_video_transition(server, 1); save_backup(); - undo->update_undo_after(_("transition"), LOAD_EDITS); + undo_after(_("transition"), LOAD_EDITS); restart_brender(); gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0); sync_parameters(CHANGE_ALL); @@ -2109,10 +2109,10 @@ void MWindow::paste_audio_transition() return; } - undo->update_undo_before(); + undo_before(); edl->tracks->paste_audio_transition(server); save_backup(); - undo->update_undo_after(_("transition"), LOAD_EDITS); + undo_after(_("transition"), LOAD_EDITS); sync_parameters(CHANGE_EDL); gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0); @@ -2129,11 +2129,11 @@ void MWindow::paste_video_transition() return; } - undo->update_undo_before(); + undo_before(); edl->tracks->paste_video_transition(server); save_backup(); - undo->update_undo_after(_("transition"), LOAD_EDITS); + undo_after(_("transition"), LOAD_EDITS); sync_parameters(CHANGE_EDL); restart_brender(); @@ -2144,14 +2144,14 @@ void MWindow::shuffle_edits() { gui->lock_window("MWindow::shuffle_edits 1"); - undo->update_undo_before(); + undo_before(); double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); edl->tracks->shuffle_edits(start, end); save_backup(); - undo->update_undo_after(_("shuffle edits"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("shuffle edits"), LOAD_EDITS | LOAD_TIMEBAR); sync_parameters(CHANGE_EDL); restart_brender(); @@ -2163,14 +2163,14 @@ void MWindow::reverse_edits() { gui->lock_window("MWindow::reverse_edits 1"); - undo->update_undo_before(); + undo_before(); double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); edl->tracks->reverse_edits(start, end); save_backup(); - undo->update_undo_after(_("reverse edits"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("reverse edits"), LOAD_EDITS | LOAD_TIMEBAR); sync_parameters(CHANGE_EDL); restart_brender(); @@ -2182,14 +2182,14 @@ void MWindow::align_edits() { gui->lock_window("MWindow::align_edits 1"); - undo->update_undo_before(); + undo_before(); double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); edl->tracks->align_edits(start, end); save_backup(); - undo->update_undo_after(_("align edits"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("align edits"), LOAD_EDITS | LOAD_TIMEBAR); sync_parameters(CHANGE_EDL); restart_brender(); @@ -2201,14 +2201,14 @@ void MWindow::set_edit_length(double length) { gui->lock_window("MWindow::set_edit_length 1"); - undo->update_undo_before(); + undo_before(); double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); edl->tracks->set_edit_length(start, end, length); save_backup(); - undo->update_undo_after(_("edit length"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("edit length"), LOAD_EDITS | LOAD_TIMEBAR); sync_parameters(CHANGE_EDL); restart_brender(); @@ -2221,14 +2221,14 @@ void MWindow::set_transition_length(Transition *transition, double length) { gui->lock_window("MWindow::set_transition_length 1"); - undo->update_undo_before(); + undo_before(); //double start = edl->local_session->get_selectionstart(); //double end = edl->local_session->get_selectionend(); edl->tracks->set_transition_length(transition, length); save_backup(); - undo->update_undo_after(_("transition length"), LOAD_EDITS); + undo_after(_("transition length"), LOAD_EDITS); edl->session->default_transition_length = length; sync_parameters(CHANGE_PARAMS); @@ -2240,14 +2240,14 @@ void MWindow::set_transition_length(double length) { gui->lock_window("MWindow::set_transition_length 2"); - undo->update_undo_before(); + undo_before(); double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); edl->tracks->set_transition_length(start, end, length); save_backup(); - undo->update_undo_after(_("transition length"), LOAD_EDITS); + undo_after(_("transition length"), LOAD_EDITS); edl->session->default_transition_length = length; sync_parameters(CHANGE_PARAMS); @@ -2304,14 +2304,14 @@ void MWindow::redo_entry(BC_WindowBase *calling_window_gui) void MWindow::resize_track(Track *track, int w, int h) { - undo->update_undo_before(); + undo_before(); // We have to move all maskpoints so they do not move in relation to image areas ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->translate_masks( (w - track->track_w) / 2, (h - track->track_h) / 2); track->track_w = w; track->track_h = h; - undo->update_undo_after(_("resize track"), LOAD_ALL); + undo_after(_("resize track"), LOAD_ALL); save_backup(); restart_brender(); @@ -2319,76 +2319,43 @@ void MWindow::resize_track(Track *track, int w, int h) } -void MWindow::set_inpoint(int is_mwindow) +void MWindow::set_inpoint() { - undo->update_undo_before(); + undo_before(); edl->set_inpoint(edl->local_session->get_selectionstart(1)); save_backup(); - undo->update_undo_after(_("in point"), LOAD_TIMEBAR); - - if( !is_mwindow ) { - gui->lock_window("MWindow::set_inpoint 1"); - } + undo_after(_("in point"), LOAD_TIMEBAR); gui->update_timebar(1); - if( !is_mwindow ) { - gui->unlock_window(); - } - if( is_mwindow ) { - cwindow->gui->lock_window("MWindow::set_inpoint 2"); - } + cwindow->gui->lock_window("MWindow::set_inpoint 2"); cwindow->gui->timebar->update(1); - if( is_mwindow ) { - cwindow->gui->unlock_window(); - } + cwindow->gui->unlock_window(); } -void MWindow::set_outpoint(int is_mwindow) +void MWindow::set_outpoint() { - undo->update_undo_before(); + undo_before(); edl->set_outpoint(edl->local_session->get_selectionend(1)); save_backup(); - undo->update_undo_after(_("out point"), LOAD_TIMEBAR); + undo_after(_("out point"), LOAD_TIMEBAR); - if( !is_mwindow ) { - gui->lock_window("MWindow::set_outpoint 1"); - } gui->update_timebar(1); - if( !is_mwindow ) { - gui->unlock_window(); - } - - if( is_mwindow ) { - cwindow->gui->lock_window("MWindow::set_outpoint 2"); - } + cwindow->gui->lock_window("MWindow::set_outpoint 2"); cwindow->gui->timebar->update(1); - if( is_mwindow ) { - cwindow->gui->unlock_window(); - } + cwindow->gui->unlock_window(); } -void MWindow::unset_inoutpoint(int is_mwindow) +void MWindow::unset_inoutpoint() { - undo->update_undo_before(); + undo_before(); edl->unset_inoutpoint(); save_backup(); - undo->update_undo_after(_("clear in/out"), LOAD_TIMEBAR); + undo_after(_("clear in/out"), LOAD_TIMEBAR); - if( !is_mwindow ) { - gui->lock_window("MWindow::unset_inoutpoint 1"); - } gui->update_timebar(1); - if( !is_mwindow ) { - gui->unlock_window(); - } - - if( is_mwindow ) { - cwindow->gui->lock_window("MWindow::unset_inoutpoint 2"); - } + cwindow->gui->lock_window("MWindow::unset_inoutpoint 2"); cwindow->gui->timebar->update(1); - if( is_mwindow ) { - cwindow->gui->unlock_window(); - } + cwindow->gui->unlock_window(); } void MWindow::splice(EDL *source, int all) @@ -2396,7 +2363,7 @@ void MWindow::splice(EDL *source, int all) FileXML file; LocalSession *src = source->local_session; - undo->update_undo_before(); + undo_before(); double source_start = all ? 0 : src->inpoint_valid() ? src->get_inpoint() : src->outpoint_valid() ? 0 : src->get_selectionstart(); @@ -2420,7 +2387,7 @@ void MWindow::splice(EDL *source, int all) edl->local_session->set_selectionend(start + source_end - source_start); save_backup(); - undo->update_undo_after(_("splice"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("splice"), LOAD_EDITS | LOAD_TIMEBAR); update_plugin_guis(); restart_brender(); gui->update(1, NORMAL_DRAW, 1, 1, 0, 1, 0); @@ -2517,55 +2484,35 @@ void MWindow::to_clip(EDL *edl, const char *txt, int all) gui->unlock_window(); } -int MWindow::toggle_label(int is_mwindow) +int MWindow::toggle_label() { double position1, position2; - undo->update_undo_before(); - - if( cwindow->playback_engine->is_playing_back ) { - position1 = position2 = - cwindow->playback_engine->get_tracking_position(); - } - else { - position1 = edl->local_session->get_selectionstart(1); - position2 = edl->local_session->get_selectionend(1); - } + undo_before(); + position1 = edl->local_session->get_selectionstart(1); + position2 = edl->local_session->get_selectionend(1); position1 = edl->align_to_frame(position1, 0); position2 = edl->align_to_frame(position2, 0); -//printf("MWindow::toggle_label 1\n"); - edl->labels->toggle_label(position1, position2); save_backup(); - if( !is_mwindow ) { - gui->lock_window("MWindow::toggle_label 1"); - } gui->update_timebar(0); gui->activate_timeline(); gui->flush(); - if( !is_mwindow ) { - gui->unlock_window(); - } - if( is_mwindow ) { - cwindow->gui->lock_window("MWindow::toggle_label 2"); - } + cwindow->gui->lock_window("MWindow::toggle_label 2"); cwindow->gui->timebar->update(1); - if( is_mwindow ) { - cwindow->gui->unlock_window(); - } - + cwindow->gui->unlock_window(); awindow->gui->async_update_assets(); - undo->update_undo_after(_("label"), LOAD_TIMEBAR); + undo_after(_("label"), LOAD_TIMEBAR); return 0; } void MWindow::trim_selection() { - undo->update_undo_before(); + undo_before(); edl->trim_selection(edl->local_session->get_selectionstart(), @@ -2575,7 +2522,7 @@ void MWindow::trim_selection() edl->session->autos_follow_edits); save_backup(); - undo->update_undo_after(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR); update_plugin_guis(); gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0); cwindow->update(1, 0, 0, 0, 1); @@ -2632,21 +2579,21 @@ void MWindow::undo_entry(BC_WindowBase *calling_window_gui) void MWindow::new_folder(const char *new_folder, int is_clips) { - undo->update_undo_before(); + undo_before(); if( edl->new_folder(new_folder, is_clips) ) { MainError::show_error(_("create new folder failed")); } - undo->update_undo_after(_("new folder"), LOAD_ALL); + undo_after(_("new folder"), LOAD_ALL); awindow->gui->async_update_assets(); } void MWindow::delete_folder(char *folder) { - undo->update_undo_before(); + undo_before(); if( edl->delete_folder(folder) < 0 ) { MainError::show_error(_("delete folder failed")); } - undo->update_undo_after(_("del folder"), LOAD_ALL); + undo_after(_("del folder"), LOAD_ALL); awindow->gui->async_update_assets(); } @@ -2679,9 +2626,9 @@ void MWindow::select_point(double position) void MWindow::map_audio(int pattern) { - undo->update_undo_before(); + undo_before(); remap_audio(pattern); - undo->update_undo_after( + undo_after( pattern == MWindow::AUDIO_1_TO_1 ? _("map 1:1") : _("map 5.1:2"), LOAD_AUTOMATION); sync_parameters(CHANGE_PARAMS); @@ -2751,11 +2698,11 @@ void MWindow::add_proxy(int use_scaler, void MWindow::cut_commercials() { #ifdef HAVE_COMMERCIAL - undo->update_undo_before(); + undo_before(); commercials->scan_media(); edl->optimize(); save_backup(); - undo->update_undo_after(_("cut ads"), LOAD_EDITS | LOAD_TIMEBAR); + undo_after(_("cut ads"), LOAD_EDITS | LOAD_TIMEBAR); restart_brender(); update_plugin_guis(); diff --git a/cinelerra-5.1/cinelerra/mwindowmove.C b/cinelerra-5.1/cinelerra/mwindowmove.C index 5fafa512..d64b6c1b 100644 --- a/cinelerra-5.1/cinelerra/mwindowmove.C +++ b/cinelerra-5.1/cinelerra/mwindowmove.C @@ -145,7 +145,7 @@ void MWindow::fit_selection() } -void MWindow::fit_autos(int doall) +void MWindow::fit_autos(int all) { float min = 0, max = 0; double start, end; @@ -167,7 +167,7 @@ void MWindow::fit_autos(int doall) int forstart = edl->local_session->zoombar_showautotype; int forend = edl->local_session->zoombar_showautotype + 1; - if (doall) { + if( all ) { forstart = 0; forend = AUTOGROUPTYPE_COUNT; } @@ -716,6 +716,25 @@ int MWindow::find_selection(double position, int scroll_display) return 0; } +double MWindow::get_position() +{ + return edl->local_session->get_selectionstart(1); +} + +void MWindow::set_position(double position) +{ + if( position != get_position() ) { + if( position < 0 ) position = 0; + edl->local_session->set_selectionstart(position); + edl->local_session->set_selectionend(position); + gui->lock_window(); + find_cursor(); + gui->update(1, NORMAL_DRAW, 1, 1, 1, 1, 0); + gui->unlock_window(); + cwindow->update(1, 0, 0, 0, 0); + } +} + int MWindow::expand_y() { diff --git a/cinelerra-5.1/cinelerra/vtimebar.C b/cinelerra-5.1/cinelerra/vtimebar.C index 2855f161..6e79b89e 100644 --- a/cinelerra-5.1/cinelerra/vtimebar.C +++ b/cinelerra-5.1/cinelerra/vtimebar.C @@ -69,8 +69,7 @@ void VTimeBar::select_label(double position) { EDL *edl = get_edl(); if( edl ) { - gui->stop_transport("VTimeBar::select_label"); - + gui->stop_transport(); position = mwindow->edl->align_to_frame(position, 1); if(shift_down()) diff --git a/cinelerra-5.1/cinelerra/vwindowgui.C b/cinelerra-5.1/cinelerra/vwindowgui.C index 96a24faa..985d484b 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.C +++ b/cinelerra-5.1/cinelerra/vwindowgui.C @@ -385,15 +385,6 @@ 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( vwindow->get_edl() != 0 && canvas->get_canvas() && @@ -494,6 +485,14 @@ int VWindowGUI::drag_stop() return 0; } +void VWindowGUI::stop_transport() +{ + if( !transport->is_stopped() ) { + unlock_window(); + transport->handle_transport(STOP, 1, 0, 0); + lock_window("VWindowGUI::panel_stop_transport"); + } +} void VWindowGUI::update_meters() { @@ -548,8 +547,6 @@ VWindowEditing::VWindowEditing(MWindow *mwindow, VWindow *vwindow) 0, // use_keyframe 1, // use_splice 1, // use_overwrite - 0, // use_lift - 0, // use_extract 1, // use_copy 0, // use_paste 0, // use_undo @@ -571,147 +568,146 @@ VWindowEditing::~VWindowEditing() { } -void VWindowEditing::copy_selection() +#define relock_vm(s) \ + vwindow->gui->unlock_window(); \ + mwindow->gui->lock_window("VWindowEditing::" s) +#define relock_mv(s) \ + mwindow->gui->unlock_window(); \ + vwindow->gui->lock_window("VWindowEditing::" s) + +double VWindowEditing::get_position() { - vwindow->copy(subwindow->shift_down()); + EDL *edl = vwindow->get_edl(); + double position = !edl ? 0 : edl->local_session->get_selectionstart(1); + return position; } -void VWindowEditing::splice_selection() +void VWindowEditing::set_position(double position) { - if(vwindow->get_edl()) - { - mwindow->gui->lock_window("VWindowEditing::splice_selection"); - mwindow->splice(vwindow->get_edl(), subwindow->shift_down()); - mwindow->gui->unlock_window(); + EDL *edl = vwindow->get_edl(); + if( !edl ) return; + if( get_position() != position ) { + if( position < 0 ) position = 0; + edl->local_session->set_selectionstart(position); + edl->local_session->set_selectionend(position); + vwindow->update_position(CHANGE_NONE, 0, 1); } } -void VWindowEditing::overwrite_selection() +void VWindowEditing::set_click_to_play(int v) { - if(vwindow->get_edl()) - { - mwindow->gui->lock_window("VWindowEditing::overwrite_selection"); - mwindow->overwrite(vwindow->get_edl(), subwindow->shift_down()); - mwindow->gui->unlock_window(); - } + click2play->update(v); + relock_vm("set_click_to_play"); + mwindow->edl->session->vwindow_click2play = v; + mwindow->update_vwindow(); + relock_mv("set_click_to_play"); } -void VWindowEditing::toggle_label() +void VWindowEditing::panel_stop_transport() { - if(vwindow->get_edl()) - { - EDL *edl = vwindow->get_edl(); - edl->labels->toggle_label(edl->local_session->get_selectionstart(1), - edl->local_session->get_selectionend(1)); - vwindow->gui->timebar->update(1); - } + vwindow->gui->stop_transport(); } -void VWindowEditing::prev_label(int cut) +void VWindowEditing::panel_toggle_label() { - if(vwindow->get_edl()) - { - EDL *edl = vwindow->get_edl(); - vwindow->gui->unlock_window(); - vwindow->playback_engine->interrupt_playback(1); - vwindow->gui->lock_window("VWindowEditing::prev_label"); + if( !vwindow->get_edl() ) return; + EDL *edl = vwindow->get_edl(); + edl->labels->toggle_label(edl->local_session->get_selectionstart(1), + edl->local_session->get_selectionend(1)); + vwindow->gui->timebar->update(1); +} - Label *current = edl->labels->prev_label( - edl->local_session->get_selectionstart(1)); +void VWindowEditing::panel_next_label(int cut) +{ + if( !vwindow->get_edl() ) return; + vwindow->gui->unlock_window(); + vwindow->playback_engine->interrupt_playback(1); + vwindow->gui->lock_window("VWindowEditing::next_label"); + EDL *edl = vwindow->get_edl(); + Label *current = edl->labels->next_label( + edl->local_session->get_selectionstart(1)); + double position = current ? current->position : + edl->tracks->total_length(); + edl->local_session->set_selectionstart(position); + edl->local_session->set_selectionend(position); + vwindow->update_position(CHANGE_NONE, 0, 1, 0); + vwindow->gui->timebar->update(1); +} - if(!current) - { - edl->local_session->set_selectionstart(0); - edl->local_session->set_selectionend(0); - vwindow->update_position(CHANGE_NONE, 0, 1, 0); - vwindow->gui->timebar->update(1); - } - else - { - edl->local_session->set_selectionstart(current->position); - edl->local_session->set_selectionend(current->position); - vwindow->update_position(CHANGE_NONE, 0, 1, 0); - vwindow->gui->timebar->update(1); - } - } +void VWindowEditing::panel_prev_label(int cut) +{ + if( !vwindow->get_edl() ) return; + vwindow->gui->unlock_window(); + vwindow->playback_engine->interrupt_playback(1); + vwindow->gui->lock_window("VWindowEditing::prev_label"); + + EDL *edl = vwindow->get_edl(); + Label *current = edl->labels->prev_label( + edl->local_session->get_selectionstart(1)); + double position = !current ? 0 : current->position; + edl->local_session->set_selectionstart(position); + edl->local_session->set_selectionend(position); + vwindow->update_position(CHANGE_NONE, 0, 1, 0); + vwindow->gui->timebar->update(1); } -void VWindowEditing::next_label(int cut) +void VWindowEditing::panel_prev_edit(int cut) {} // not used +void VWindowEditing::panel_next_edit(int cut) {} // not used + +void VWindowEditing::panel_copy_selection() { - if(vwindow->get_edl()) - { - EDL *edl = vwindow->get_edl(); - Label *current = edl->labels->next_label( - edl->local_session->get_selectionstart(1)); - if(!current) - { - vwindow->gui->unlock_window(); - vwindow->playback_engine->interrupt_playback(1); - vwindow->gui->lock_window("VWindowEditing::next_label 1"); - - double position = edl->tracks->total_length(); - edl->local_session->set_selectionstart(position); - edl->local_session->set_selectionend(position); - vwindow->update_position(CHANGE_NONE, 0, 1, 0); - vwindow->gui->timebar->update(1); - } - else - { - vwindow->gui->unlock_window(); - vwindow->playback_engine->interrupt_playback(1); - vwindow->gui->lock_window("VWindowEditing::next_label 2"); - - edl->local_session->set_selectionstart(current->position); - edl->local_session->set_selectionend(current->position); - vwindow->update_position(CHANGE_NONE, 0, 1, 0); - vwindow->gui->timebar->update(1); - } - } + vwindow->copy(vwindow->gui->shift_down()); } -double VWindowEditing::get_position() +void VWindowEditing::panel_overwrite_selection() { - EDL *edl = vwindow->get_edl(); - double position = !edl ? 0 : edl->local_session->get_selectionstart(1); - return position; + if( !vwindow->get_edl() ) return; + relock_vm("overwrite_selection"); + mwindow->overwrite(vwindow->get_edl(), vwindow->gui->shift_down()); + relock_mv("overwrite_selection"); } -void VWindowEditing::set_position(double position) +void VWindowEditing::panel_splice_selection() { - EDL *edl = vwindow->get_edl(); - if( !edl ) return; - if( get_position() != position ) { - if( position < 0 ) position = 0; - edl->local_session->set_selectionstart(position); - edl->local_session->set_selectionend(position); - vwindow->update_position(CHANGE_NONE, 0, 1); - } + if( !vwindow->get_edl() ) return; + relock_vm("splice_selection"); + mwindow->splice(vwindow->get_edl(), vwindow->gui->shift_down()); + relock_mv("splice_selection"); } -void VWindowEditing::set_inpoint() +void VWindowEditing::panel_set_inpoint() { vwindow->set_inpoint(); } -void VWindowEditing::set_outpoint() +void VWindowEditing::panel_set_outpoint() { vwindow->set_outpoint(); } -void VWindowEditing::unset_inoutpoint() +void VWindowEditing::panel_unset_inoutpoint() { vwindow->unset_inoutpoint(); } - -void VWindowEditing::to_clip() +void VWindowEditing::panel_to_clip() { EDL *edl = vwindow->get_edl(); if( !edl ) return; mwindow->to_clip(edl, _("viewer window: "), subwindow->shift_down()); } +// not used +void VWindowEditing::panel_cut() {} +void VWindowEditing::panel_paste() {} +void VWindowEditing::panel_fit_selection() {} +void VWindowEditing::panel_fit_autos(int all) {} +void VWindowEditing::panel_set_editing_mode(int mode) {} +void VWindowEditing::panel_set_auto_keyframes(int v) {} +void VWindowEditing::panel_set_labels_follow_edits(int v) {} + + VWindowSource::VWindowSource(MWindow *mwindow, VWindowGUI *vwindow, int x, int y) : BC_PopupTextBox(vwindow, &vwindow->sources, diff --git a/cinelerra-5.1/cinelerra/vwindowgui.h b/cinelerra-5.1/cinelerra/vwindowgui.h index f5a36a06..60dcfeff 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.h +++ b/cinelerra-5.1/cinelerra/vwindowgui.h @@ -56,7 +56,7 @@ public: int resize_event(int w, int h); int translation_event(); int close_event(); - void stop_transport(const char *lock_msg); + void stop_transport(); int keypress_event(); int button_press_event(); int cursor_leave_event(); @@ -135,18 +135,30 @@ public: VWindowEditing(MWindow *mwindow, VWindow *vwindow); virtual ~VWindowEditing(); - void copy_selection(); - void splice_selection(); - void overwrite_selection(); - void set_inpoint(); - void set_outpoint(); - void unset_inoutpoint(); - void to_clip(); - void toggle_label(); - void prev_label(int cut); - void next_label(int cut); double get_position(); void set_position(double position); + void set_click_to_play(int v); + + void panel_stop_transport(); + void panel_toggle_label(); + void panel_next_label(int cut); + void panel_prev_label(int cut); + void panel_prev_edit(int cut); + void panel_next_edit(int cut); + void panel_copy_selection(); + void panel_overwrite_selection(); + void panel_splice_selection(); + void panel_set_inpoint(); + void panel_set_outpoint(); + void panel_unset_inoutpoint(); + void panel_to_clip(); + void panel_cut(); + void panel_paste(); + void panel_fit_selection(); + void panel_fit_autos(int all); + void panel_set_editing_mode(int mode); + void panel_set_auto_keyframes(int v); + void panel_set_labels_follow_edits(int v); MWindow *mwindow; VWindow *vwindow; diff --git a/cinelerra-5.1/guicast/bctrace.C b/cinelerra-5.1/guicast/bctrace.C index 7e279673..7e453925 100644 --- a/cinelerra-5.1/guicast/bctrace.C +++ b/cinelerra-5.1/guicast/bctrace.C @@ -309,6 +309,9 @@ void BC_Trace::dump_traces(FILE *fp) } } +void trace_info::set_owner() { owner = pthread_self(); } +void trace_info::unset_owner() { owner = 0; } + void BC_Trace::dump_locks(FILE *fp) { // Dump lock table @@ -316,8 +319,12 @@ void BC_Trace::dump_locks(FILE *fp) fprintf(fp,"signal_entry: lock table size=%d\n", lock_table.size); for( trace_item *tp=lock_table.first; tp!=0; tp=tp->next ) { lock_item *p=(lock_item*)tp; - fprintf(fp," %p %s %s %p%s\n", p->info, p->title, - p->loc, (void*)p->tid, p->is_owner ? " *" : ""); + fprintf(fp," %p %s, %s %p%s", + p->info, p->title, p->loc, + (void*)p->tid, p->is_owner ? " *" : ""); + if( p->info->owner && p->info->owner != p->tid ) + fprintf(fp," %p", (void*)p->info->owner); + fprintf(fp,"\n"); } int64_t lock_total = lock_table.total(); int64_t free_total = lock_free.total(); diff --git a/cinelerra-5.1/guicast/bctrace.inc b/cinelerra-5.1/guicast/bctrace.inc index 967aa253..b43bfbe7 100644 --- a/cinelerra-5.1/guicast/bctrace.inc +++ b/cinelerra-5.1/guicast/bctrace.inc @@ -26,8 +26,11 @@ class TheChk; class trace_info { public: void *trace; - trace_info() { trace = 0; } + unsigned long owner; + trace_info() { trace = 0; owner = 0; } ~trace_info() {} + void set_owner(); + void unset_owner(); }; #ifdef NO_GUICAST diff --git a/cinelerra-5.1/guicast/condition.C b/cinelerra-5.1/guicast/condition.C index e57110ca..89cbe692 100644 --- a/cinelerra-5.1/guicast/condition.C +++ b/cinelerra-5.1/guicast/condition.C @@ -52,6 +52,7 @@ void Condition::reset() pthread_mutex_init(&mutex, 0); pthread_cond_init(&cond, NULL); UNSET_ALL_LOCKS(this); + unset_owner(); value = init_value; trace = 0; } @@ -66,6 +67,8 @@ void Condition::lock(const char *location) value = 0; else value--; + if( !value ) + set_owner(); pthread_mutex_unlock(&mutex); } @@ -78,6 +81,7 @@ void Condition::unlock() value = 1; else value++; + unset_owner(); pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); } @@ -130,6 +134,8 @@ int Condition::timed_lock(int microseconds, const char *location) else --value; } + if( !value ) + set_owner(); pthread_mutex_unlock(&mutex); return result; } diff --git a/cinelerra-5.1/guicast/mutex.C b/cinelerra-5.1/guicast/mutex.C index 6ac188d5..36dbfb92 100644 --- a/cinelerra-5.1/guicast/mutex.C +++ b/cinelerra-5.1/guicast/mutex.C @@ -30,7 +30,6 @@ Mutex::Mutex(const char *title, int recursive) { this->title = title; - this->trace = 0; pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutex_init(&mutex, &attr); @@ -66,7 +65,7 @@ int Mutex::lock(const char *location) SET_LOCK(this, title, location); if(pthread_mutex_lock(&mutex)) perror("Mutex::lock"); - + set_owner(); // Update recursive status for the first lock @@ -115,6 +114,7 @@ int Mutex::unlock() UNSET_LOCK(this); + unset_owner(); int ret = pthread_mutex_unlock(&mutex); if( ret ) fprintf(stderr, "Mutex::unlock: %s\n",strerror(ret)); @@ -126,6 +126,7 @@ int Mutex::trylock(const char *location) if( count ) return EBUSY; int ret = pthread_mutex_trylock(&mutex); if( ret ) return ret; + set_owner(); // Update recursive status for the first lock if(recursive) { @@ -155,6 +156,7 @@ int Mutex::reset() pthread_mutexattr_init(&attr); pthread_mutex_init(&mutex, &attr); UNSET_ALL_LOCKS(this) + unset_owner(); trace = 0; count = 0; thread_id = 0; diff --git a/cinelerra-5.1/thirdparty/downloads.txt b/cinelerra-5.1/thirdparty/downloads.txt index a3643e68..3a73171a 100644 --- a/cinelerra-5.1/thirdparty/downloads.txt +++ b/cinelerra-5.1/thirdparty/downloads.txt @@ -34,3 +34,5 @@ http://ffmpeg.org/releases/ffmpeg-4.1.tar.gz https://github.com/webmproject/libvpx/releases/tag/v1.7.0 https://github.com/swh/ladspa/releases/tag/v0.4.17, plugin.org.uk https://archive.mozilla.org/pub/opus/opus-1.3.tar.gz +https://github.com/webmproject/libwebp = libwebp-1.0.2 +https://github.com/mozilla/aom = libaom-v1.0.0 -- 2.26.2