From: Good Guy Date: Tue, 11 Dec 2018 02:51:32 +0000 (-0700) Subject: edit group selection and cut/copy/paste/del shortcuts, interview mode tweaks X-Git-Tag: 2019-08~156 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=ee1879b1a1850e1d4e19c034d4a9c5459274bbb6;p=goodguy%2Fcinelerra.git edit group selection and cut/copy/paste/del shortcuts, interview mode tweaks --- diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile index 5f7bcbdb..e9d67aa5 100644 --- a/cinelerra-5.1/cinelerra/Makefile +++ b/cinelerra-5.1/cinelerra/Makefile @@ -287,6 +287,7 @@ OBJS := \ $(OBJDIR)/trackcanvas.o \ $(OBJDIR)/tracking.o \ $(OBJDIR)/track.o \ + $(OBJDIR)/trackpopup.o \ $(OBJDIR)/trackscroll.o \ $(OBJDIR)/tracksedit.o \ $(OBJDIR)/tracks.o \ diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index 13e94b95..384090a2 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -357,7 +357,7 @@ int AssetViewPopup::button_press_event() MWindow *mwindow = picon->mwindow; EDL *edl = mwindow->edl; dragging = 0; - if( y < bar_h ) { + if( y < get_h()/2 ) { Indexable *idxbl = picon->indexable ? picon->indexable : picon->edl ? picon->edl : 0; @@ -402,7 +402,7 @@ int AssetViewPopup::button_press_event() vwindow->update_position(CHANGE_NONE, 0, 1, 0); return 1; } - if( y >= get_h()-bar_h ) { + else { dragging = 1; if( !ctrl_down() && !shift_down() ) return cursor_motion_event(); @@ -454,7 +454,9 @@ int AssetViewPopup::cursor_motion_event() { if( !is_event_win() ) return 0; AssetVIconThread *avt = (AssetVIconThread *)vt; - if( !avt->vicon || draw_mode != ASSET_VIEW_MEDIA_MAP ) return 0; + if( !avt->vicon || + ( draw_mode != ASSET_VIEW_FULL && + draw_mode != ASSET_VIEW_MEDIA_MAP ) ) return 0; if( !get_button_down() || get_buttonpress() != LEFT_BUTTON || ctrl_down() || alt_down() || shift_down() ) return 0; diff --git a/cinelerra-5.1/cinelerra/edit.C b/cinelerra-5.1/cinelerra/edit.C index c680d8c6..489a9694 100644 --- a/cinelerra-5.1/cinelerra/edit.C +++ b/cinelerra-5.1/cinelerra/edit.C @@ -83,6 +83,7 @@ void Edit::reset() user_title[0] = 0; nested_edl = 0; is_plugin = 0; + is_selected = 0; hard_left = 0; hard_right = 0; } diff --git a/cinelerra-5.1/cinelerra/edit.h b/cinelerra-5.1/cinelerra/edit.h index d3598adb..e377c336 100644 --- a/cinelerra-5.1/cinelerra/edit.h +++ b/cinelerra-5.1/cinelerra/edit.h @@ -131,7 +131,7 @@ public: int id; // User defined title for timeline char user_title[BCTEXTLEN]; - int is_plugin; + int is_plugin, is_selected; // edge cannot be optimized int hard_left, hard_right; diff --git a/cinelerra-5.1/cinelerra/editpanel.C b/cinelerra-5.1/cinelerra/editpanel.C index 530d530c..26e5b7d0 100644 --- a/cinelerra-5.1/cinelerra/editpanel.C +++ b/cinelerra-5.1/cinelerra/editpanel.C @@ -933,7 +933,7 @@ int EditSplice::handle_event() int EditSplice::keypress_event() { if( alt_down() ) return 0; - if( get_keypress() == 'v' || + if( (get_keypress() == 'v' && !ctrl_down()) || (panel->is_vwindow() && get_keypress() == 'V') ) { handle_event(); return 1; @@ -1065,7 +1065,7 @@ EditCopy::~EditCopy() int EditCopy::keypress_event() { if( alt_down() ) return 0; - if( get_keypress() == 'c' || + if( (get_keypress() == 'c' && !ctrl_down()) || (panel->is_vwindow() && get_keypress() == 'C') ) { return handle_event(); } @@ -1127,7 +1127,7 @@ EditPaste::~EditPaste() int EditPaste::keypress_event() { - if( get_keypress() == 'v' ) + if( get_keypress() == 'v' && !ctrl_down() ) return handle_event(); return 0; } diff --git a/cinelerra-5.1/cinelerra/editpopup.C b/cinelerra-5.1/cinelerra/editpopup.C index 25931b5d..14a85cf3 100644 --- a/cinelerra-5.1/cinelerra/editpopup.C +++ b/cinelerra-5.1/cinelerra/editpopup.C @@ -57,162 +57,105 @@ EditPopup::~EditPopup() void EditPopup::create_objects() { - add_item(new EditAttachEffect(mwindow, this)); - add_item(new EditMoveTrackUp(mwindow, this)); - add_item(new EditMoveTrackDown(mwindow, this)); - add_item(new EditPopupDeleteTrack(mwindow, this)); - add_item(new EditPopupAddTrack(mwindow, this)); + add_item(new EditPopupClear(mwindow, this)); + add_item(new EditPopupDelete(mwindow, this)); + add_item(new EditPopupCopy(mwindow, this)); + add_item(new EditPopupCut(mwindow, this)); + add_item(new EditPopupCopyCut(mwindow, this)); + add_item(new EditPopupPaste(mwindow, this)); add_item(new EditPopupFindAsset(mwindow, this)); add_item(new EditPopupTitle(mwindow, this)); add_item(new EditPopupShow(mwindow, this)); - resize_option = 0; - matchsize_option = 0; } -int EditPopup::update(Track *track, Edit *edit) +int EditPopup::update(Edit *edit) { this->edit = edit; - this->track = track; - - if(track->data_type == TRACK_VIDEO && !resize_option) - { - add_item(resize_option = new EditPopupResize(mwindow, this)); - add_item(matchsize_option = new EditPopupMatchSize(mwindow, this)); - } - else - if(track->data_type == TRACK_AUDIO && resize_option) - { - del_item(resize_option); resize_option = 0; - del_item(matchsize_option); matchsize_option = 0; - } return 0; } -EditAttachEffect::EditAttachEffect(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Attach effect...")) +EditPopupClear::EditPopupClear(MWindow *mwindow, EditPopup *popup) + : BC_MenuItem(_("Clear"),_("Ctrl-m"),'m') { this->mwindow = mwindow; this->popup = popup; - dialog_thread = new PluginDialogThread(mwindow); -} - -EditAttachEffect::~EditAttachEffect() -{ - delete dialog_thread; + set_ctrl(1); } -int EditAttachEffect::handle_event() +int EditPopupClear::handle_event() { - dialog_thread->start_window(popup->track, - 0, _(PROGRAM_NAME ": Attach Effect"), - 0, popup->track->data_type); + mwindow->delete_edits(0); return 1; } - -EditMoveTrackUp::EditMoveTrackUp(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Move up")) +EditPopupDelete::EditPopupDelete(MWindow *mwindow, EditPopup *popup) + : BC_MenuItem(_("Delete"),_("Ctrl-DEL"),DELETE) { this->mwindow = mwindow; this->popup = popup; + set_ctrl(1); } -EditMoveTrackUp::~EditMoveTrackUp() -{ -} -int EditMoveTrackUp::handle_event() -{ - mwindow->move_track_up(popup->track); - return 1; -} - - -EditMoveTrackDown::EditMoveTrackDown(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Move down")) -{ - this->mwindow = mwindow; - this->popup = popup; -} -EditMoveTrackDown::~EditMoveTrackDown() -{ -} -int EditMoveTrackDown::handle_event() +int EditPopupDelete::handle_event() { - mwindow->move_track_down(popup->track); + mwindow->delete_edits(1); return 1; } - -EditPopupResize::EditPopupResize(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Resize track...")) +EditPopupCopy::EditPopupCopy(MWindow *mwindow, EditPopup *popup) + : BC_MenuItem(_("Copy"),_("Ctrl-c"),'c') { this->mwindow = mwindow; this->popup = popup; - dialog_thread = new ResizeTrackThread(mwindow); -} -EditPopupResize::~EditPopupResize() -{ - delete dialog_thread; + set_ctrl(1); } -int EditPopupResize::handle_event() +int EditPopupCopy::handle_event() { - dialog_thread->start_window(popup->track); + mwindow->selected_to_clipboard(); return 1; } - -EditPopupMatchSize::EditPopupMatchSize(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Match output size")) +EditPopupCut::EditPopupCut(MWindow *mwindow, EditPopup *popup) + : BC_MenuItem(_("Cut"),_("Ctrl-x"),'x') { this->mwindow = mwindow; this->popup = popup; -} -EditPopupMatchSize::~EditPopupMatchSize() -{ + set_ctrl(1); } -int EditPopupMatchSize::handle_event() +int EditPopupCut::handle_event() { - mwindow->match_output_size(popup->track); + mwindow->cut_selected_edits(1); return 1; } - -EditPopupDeleteTrack::EditPopupDeleteTrack(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Delete track")) +EditPopupCopyCut::EditPopupCopyCut(MWindow *mwindow, EditPopup *popup) + : BC_MenuItem(_("Copy cut"),_("Ctrl-z"),'z') { this->mwindow = mwindow; this->popup = popup; + set_ctrl(1); } -int EditPopupDeleteTrack::handle_event() + +int EditPopupCopyCut::handle_event() { - mwindow->delete_track(popup->track); + mwindow->cut_selected_edits(0); return 1; } - -EditPopupAddTrack::EditPopupAddTrack(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Add track")) +EditPopupPaste::EditPopupPaste(MWindow *mwindow, EditPopup *popup) + : BC_MenuItem(_("Paste"),_("Ctrl-v"),'v') { this->mwindow = mwindow; this->popup = popup; + set_ctrl(1); } -int EditPopupAddTrack::handle_event() +int EditPopupPaste::handle_event() { - switch( popup->track->data_type ) { - case TRACK_AUDIO: - mwindow->add_audio_track_entry(1, popup->track); - break; - case TRACK_VIDEO: - mwindow->add_video_track_entry(popup->track); - break; - case TRACK_SUBTITLE: - mwindow->add_subttl_track_entry(popup->track); - break; - } + mwindow->paste(); return 1; } @@ -447,8 +390,8 @@ void EditPopupShowWindow::create_objects() int x = 10, y = 10; BC_Title *title; char text[BCTEXTLEN]; - Track *track = popup->track; Edit *edit = popup->edit; + Track *track = edit->track; sprintf(text, _("Track %d:"), mwindow->edl->tracks->number_of(track)+1); add_subwindow(title = new BC_Title(x, y, text)); int x1 = x + title->get_w() + 10; diff --git a/cinelerra-5.1/cinelerra/editpopup.h b/cinelerra-5.1/cinelerra/editpopup.h index 89754a25..488bf4f1 100644 --- a/cinelerra-5.1/cinelerra/editpopup.h +++ b/cinelerra-5.1/cinelerra/editpopup.h @@ -23,30 +23,13 @@ #define EDITPOPUP_H #include "guicast.h" +#include "edit.inc" +#include "editpopup.inc" #include "mwindow.inc" #include "mwindowgui.inc" -#include "edit.inc" #include "plugindialog.inc" #include "resizetrackthread.inc" -class EditPopup; -class EditPopupMatchSize; -class EditPopupResize; -class EditPopupDeleteTrack; -class EditPopupAddTrack; -class EditPopupFindAsset; -class EditAttachEffect; -class EditMoveTrackUp; -class EditMoveTrackDown; -class EditPopupTitle; -class EditTitleDialogThread; -class EditPopupTitleText; -class EditPopupTitleWindow; -class EditPopupShow; -class EditShowDialogThread; -class EditPopupShowText; -class EditPopupShowWindow; - class EditPopup : public BC_PopupMenu { public: @@ -54,104 +37,83 @@ public: ~EditPopup(); void create_objects(); - int update(Track *track, Edit *edit); + int update(Edit *edit); MWindow *mwindow; MWindowGUI *gui; -// Acquired through the update command as the edit currently being operated on Edit *edit; - Track *track; - EditPopupResize *resize_option; - EditPopupMatchSize *matchsize_option; }; -class EditPopupMatchSize : public BC_MenuItem -{ -public: - EditPopupMatchSize(MWindow *mwindow, EditPopup *popup); - ~EditPopupMatchSize(); - int handle_event(); - MWindow *mwindow; - EditPopup *popup; -}; -class EditPopupResize : public BC_MenuItem +class EditPopupClear : public BC_MenuItem { public: - EditPopupResize(MWindow *mwindow, EditPopup *popup); - ~EditPopupResize(); + EditPopupClear(MWindow *mwindow, EditPopup *popup); int handle_event(); + MWindow *mwindow; EditPopup *popup; - ResizeTrackThread *dialog_thread; }; -class EditPopupDeleteTrack : public BC_MenuItem +class EditPopupDelete : public BC_MenuItem { public: - EditPopupDeleteTrack(MWindow *mwindow, EditPopup *popup); + EditPopupDelete(MWindow *mwindow, EditPopup *popup); int handle_event(); + MWindow *mwindow; EditPopup *popup; }; -class EditPopupAddTrack : public BC_MenuItem +class EditPopupCopy : public BC_MenuItem { public: - EditPopupAddTrack(MWindow *mwindow, EditPopup *popup); + EditPopupCopy(MWindow *mwindow, EditPopup *popup); int handle_event(); + MWindow *mwindow; EditPopup *popup; }; -class EditPopupFindAsset : public BC_MenuItem +class EditPopupCut : public BC_MenuItem { public: - EditPopupFindAsset(MWindow *mwindow, EditPopup *popup); + EditPopupCut(MWindow *mwindow, EditPopup *popup); int handle_event(); + MWindow *mwindow; EditPopup *popup; }; - -class EditAttachEffect : public BC_MenuItem +class EditPopupCopyCut : public BC_MenuItem { public: - EditAttachEffect(MWindow *mwindow, EditPopup *popup); - ~EditAttachEffect(); - + EditPopupCopyCut(MWindow *mwindow, EditPopup *popup); int handle_event(); MWindow *mwindow; EditPopup *popup; - PluginDialogThread *dialog_thread; }; -class EditMoveTrackUp : public BC_MenuItem +class EditPopupPaste : public BC_MenuItem { public: - EditMoveTrackUp(MWindow *mwindow, EditPopup *popup); - ~EditMoveTrackUp(); - + EditPopupPaste(MWindow *mwindow, EditPopup *popup); int handle_event(); MWindow *mwindow; EditPopup *popup; }; -class EditMoveTrackDown : public BC_MenuItem +class EditPopupFindAsset : public BC_MenuItem { public: - EditMoveTrackDown(MWindow *mwindow, EditPopup *popup); - ~EditMoveTrackDown(); - + EditPopupFindAsset(MWindow *mwindow, EditPopup *popup); int handle_event(); - MWindow *mwindow; EditPopup *popup; }; - class EditPopupTitle : public BC_MenuItem { public: diff --git a/cinelerra-5.1/cinelerra/editpopup.inc b/cinelerra-5.1/cinelerra/editpopup.inc index c7ea0e2f..37574b1a 100644 --- a/cinelerra-5.1/cinelerra/editpopup.inc +++ b/cinelerra-5.1/cinelerra/editpopup.inc @@ -19,9 +19,24 @@ * */ -#ifndef EDITPOPUP_INC -#define EDITPOPUP_INC +#ifndef __EDITPOPUP_INC__ +#define __EDITPOPUP_INC__ class EditPopup; +class EditClear; +class EditDelete; +class EditCopy; +class EditCut; +class EditCopyCut; +class EditPaste; +class EditPopupFindAsset; +class EditPopupTitle; +class EditTitleDialogThread; +class EditPopupTitleText; +class EditPopupTitleWindow; +class EditPopupShow; +class EditShowDialogThread; +class EditPopupShowText; +class EditPopupShowWindow; #endif diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h index e862459c..79bbb5cd 100644 --- a/cinelerra-5.1/cinelerra/mwindow.h +++ b/cinelerra-5.1/cinelerra/mwindow.h @@ -182,6 +182,7 @@ public: void update_vwindow(); // Fit selected time to horizontal display range void fit_selection(); + void selected_to_clipboard(); // Fit selected autos to the vertical display range void fit_autos(int doall); void change_currentautorange(int autogrouptype, int increment, int changemax); @@ -399,6 +400,10 @@ public: int plugin_type); void match_output_size(Track *track); + void delete_edit(Edit *edit, const char *msg, int collapse=0); + void delete_edits(ArrayList *edits, const char *msg, int collapse=0); + void delete_edits(int collapse=0); + void cut_selected_edits(int collapse=0); // Move edit to new position void move_edits(ArrayList *edits, Track *track, diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index 3d6a69f0..3e6c8999 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -903,6 +903,104 @@ void MWindow::match_output_size(Track *track) } +void MWindow::selected_to_clipboard() +{ + EDL *new_edl = new EDL(); + new_edl->create_objects(); + new_edl->copy_session(edl); + const char *text = _("new_edl edit"); + new_edl->set_path(text); + strcpy(new_edl->local_session->clip_title, text); + strcpy(new_edl->local_session->clip_notes, text); + new_edl->session->video_tracks = 0; + new_edl->session->audio_tracks = 0; + for( Track *track=edl->tracks->first; track; track=track->next ) { + int64_t startproject = 0; + Track *new_track = 0; + for( Edit *edit=track->edits->first; edit; edit=edit->next ) { + if( !edit->is_selected ) continue; + if( !new_track ) { + switch( track->data_type ) { + case TRACK_VIDEO: + ++new_edl->session->video_tracks; + new_track = new_edl->tracks->add_video_track(0, 0); + break; + case TRACK_AUDIO: + ++new_edl->session->audio_tracks; + new_track = new_edl->tracks->add_audio_track(0, 0); + break; + case TRACK_SUBTITLE: + new_track = new_edl->tracks->add_subttl_track(0, 0); + break; + } + } + if( new_track ) { + Edit *clip_edit = new Edit(new_edl, new_track); + clip_edit->copy_from(edit); + clip_edit->startproject = startproject; + startproject += clip_edit->length; + new_track->edits->append(clip_edit); + } + } + } + double length = new_edl->tracks->total_length(); + FileXML file; + new_edl->copy(0, length, 0, &file, "", 1); + const char *file_string = file.string(); + long file_length = strlen(file_string); + gui->to_clipboard(file_string, file_length, BC_PRIMARY_SELECTION); + gui->to_clipboard(file_string, file_length, SECONDARY_SELECTION); + new_edl->remove_user(); +} + +void MWindow::delete_edit(Edit *edit, const char *msg, int collapse) +{ + ArrayList edits; + edits.append(edit); + delete_edits(&edits, msg, collapse); +} + +void MWindow::delete_edits(ArrayList *edits, const char *msg, int collapse) +{ + if( !edits->size() ) return; + undo->update_undo_before(); + for( Track *track=edl->tracks->first; track; track=track->next ) { + for( Edit *next=track->edits->first; next; ) { + Edit *edit = next; next = edit->next; + if( !edit->is_selected ) continue; + int64_t len = edit->length; + delete edit; + if( !collapse ) continue; + for( edit=next; edit; edit=edit->next ) + edit->startproject -= len; + } + } + edl->optimize(); + save_backup(); + undo->update_undo_after(msg, LOAD_EDITS); + + restart_brender(); + cwindow->refresh_frame(CHANGE_EDL); + update_plugin_guis(); + gui->update(1, NORMAL_DRAW, 1, 0, 0, 0, 0); +} + +void MWindow::delete_edits(int collapse) +{ + ArrayList edits; + edl->tracks->get_selected_edits(&edits); + delete_edits(&edits,_("del edit"), collapse); +} + +void MWindow::cut_selected_edits(int collapse) +{ + selected_to_clipboard(); + ArrayList edits; + edl->tracks->get_selected_edits(&edits); + delete_edits(&edits, _("cut edit"), collapse); +} + + void MWindow::move_edits(ArrayList *edits, Track *track, double position, diff --git a/cinelerra-5.1/cinelerra/mwindowgui.C b/cinelerra-5.1/cinelerra/mwindowgui.C index d121f29e..89ddbcce 100644 --- a/cinelerra-5.1/cinelerra/mwindowgui.C +++ b/cinelerra-5.1/cinelerra/mwindowgui.C @@ -65,6 +65,7 @@ #include "swindow.h" #include "theme.h" #include "trackcanvas.h" +#include "trackpopup.h" #include "trackscroll.h" #include "tracks.h" #include "transitionpopup.h" @@ -116,6 +117,7 @@ MWindowGUI::MWindowGUI(MWindow *mwindow) statusbar = 0; zoombar = 0; mainclock = 0; + track_menu = 0; edit_menu = 0; plugin_menu = 0; keyframe_menu = 0; @@ -336,6 +338,9 @@ void MWindowGUI::create_objects() // cursor->create_objects(); + if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__); + add_subwindow(track_menu = new TrackPopup(mwindow, this)); + track_menu->create_objects(); if(debug) printf("MWindowGUI::create_objects %d\n", __LINE__); add_subwindow(edit_menu = new EditPopup(mwindow, this)); edit_menu->create_objects(); @@ -1181,6 +1186,25 @@ int MWindowGUI::keypress_event() result = 1; break; + case 'c': + if( !ctrl_down() || alt_down() ) break; + mwindow->selected_to_clipboard(); + break; + case 'v': + if( !ctrl_down() || alt_down() ) break; + mwindow->paste(); + break; + case 'z': + case 'x': + if( !ctrl_down() || alt_down() ) break; + mwindow->cut_selected_edits(get_keypress()=='x' ? 1 : 0); + break; + case 'm': + case DELETE: + if( !ctrl_down() || alt_down() ) break; + mwindow->delete_edits(get_keypress()==DELETE ? 1 : 0); + break; + case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': if( !alt_down() || shift_down() ) break; diff --git a/cinelerra-5.1/cinelerra/mwindowgui.h b/cinelerra-5.1/cinelerra/mwindowgui.h index 6484dc81..592e3876 100644 --- a/cinelerra-5.1/cinelerra/mwindowgui.h +++ b/cinelerra-5.1/cinelerra/mwindowgui.h @@ -53,6 +53,7 @@ #include "timelinepane.inc" #include "track.inc" #include "trackcanvas.inc" +#include "trackpopup.inc" #include "trackscroll.inc" #include "transitionpopup.inc" #include "zoombar.inc" @@ -212,6 +213,7 @@ public: DbWindow *db_window; SWindow *swindow; // Popup menus + TrackPopup *track_menu; EditPopup *edit_menu; PluginPopup *plugin_menu; KeyframePopup *keyframe_menu; diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index c746de71..f2b7dd02 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -76,6 +76,7 @@ #include "theme.h" #include "trackcanvas.h" #include "tracking.h" +#include "trackpopup.h" #include "tracks.h" #include "transition.h" #include "transitionhandles.h" @@ -1192,11 +1193,12 @@ void TrackCanvas::draw_paste_destination() from_units(drop_edit_position(&insertion, mwindow->session->drag_edit, mwindow->session->drag_edit->length)); + current_vedit++; } } if( paste_position >= 0 ) { position = paste_position; - current_vedit++; + current_vtrack++; //draw_box = 1; } else @@ -1589,10 +1591,22 @@ void TrackCanvas::draw_highlighting() } - - if(draw_box) - { + if( draw_box ) draw_highlight_rectangle(x, y, w, h); + + for( Track *track=mwindow->edl->tracks->first; track; track=track->next ) { + for( Edit *edit=track->edits->first; edit; edit=edit->next ) { + if( !edit->is_selected ) continue; + edit_dimensions(edit, x, y, w, h); + if( !MWindowGUI::visible(x, x + w, 0, get_w()) ) continue; + if( !MWindowGUI::visible(y, y + h, 0, get_h()) ) continue; + set_color(GREEN | BLUE); + set_inverse(); + draw_rectangle(x, y, w, h); + set_color(RED); + draw_rectangle(x-1, y-1, w+2, h+2); + set_opaque(); + } } } @@ -4672,13 +4686,19 @@ int TrackCanvas::do_tracks(int cursor_x, int cursor_y, int button_press) int64_t track_x, track_y, track_w, track_h; track_dimensions(track, track_x, track_y, track_w, track_h); - if( button_press && get_buttonpress() == RIGHT_BUTTON && - cursor_y >= track_y && cursor_y < track_y + track_h) { + if( button_press && cursor_y >= track_y && cursor_y < track_y + track_h ) { double pos = mwindow->edl->get_cursor_position(cursor_x, pane->number); int64_t position = track->to_units(pos, 0); - gui->edit_menu->update(track, track->edits->editof(position, PLAY_FORWARD, 0)); - gui->edit_menu->activate_menu(); - result = 1; + if( get_buttonpress() == RIGHT_BUTTON ) { + gui->track_menu->update(track); + gui->track_menu->activate_menu(); + result = 1; + } + else if( get_buttonpress() == MIDDLE_BUTTON ) { + gui->edit_menu->update(track->edits->editof(position, PLAY_FORWARD, 0)); + gui->edit_menu->activate_menu(); + result = 1; + } } } @@ -4701,7 +4721,7 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag cursor_y >= edit_y && cursor_y < edit_y + edit_h) { // Select duration of edit if(button_press) { - if(get_double_click() && !drag_start) { + if( !drag_start && get_double_click() ) { mwindow->edl->local_session->set_selectionstart(edit->track->from_units(edit->startproject)); mwindow->edl->local_session->set_selectionend(edit->track->from_units(edit->startproject) + edit->track->from_units(edit->length)); @@ -4712,31 +4732,33 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag mwindow->edl->local_session->set_selectionend( mwindow->edl->align_to_frame(mwindow->edl->local_session->get_selectionend(1), 1)); } + result = 1; + } + if( ctrl_down() && get_buttonpress() == 1 && + mwindow->edl->session->editing_mode == EDITING_ARROW ) { + edit->is_selected = !edit->is_selected ? 1 : 0; + result = 1; + } + if( result ) { redraw = 1; rerender = 1; update_cursor = -1; - result = 1; } } - else if(drag_start && track->record) { - if(mwindow->edl->session->editing_mode == EDITING_ARROW) { + else if( drag_start && track->record ) { + if( mwindow->edl->session->editing_mode == EDITING_ARROW ) { // Need to create drag window mwindow->session->current_operation = DRAG_EDIT; mwindow->session->drag_edit = edit; -//printf("TrackCanvas::do_edits 2\n"); - -// Drag only one edit if ctrl is initially down - if(ctrl_down()) { - mwindow->session->drag_edits->remove_all(); - mwindow->session->drag_edits->append(edit); - } - else { // Construct list of all affected edits - mwindow->edl->tracks->get_affected_edits( - mwindow->session->drag_edits, + mwindow->edl->tracks->clear_selected_edits(); + if( ctrl_down() ) + edit->is_selected = 1; + else + mwindow->edl->tracks->select_affected_edits( edit->track->from_units(edit->startproject), edit->track); - } + mwindow->edl->tracks->get_selected_edits(mwindow->session->drag_edits); mwindow->session->drag_origin_x = cursor_x; mwindow->session->drag_origin_y = cursor_y; // Where the drag started, so we know relative position inside the edit later @@ -4996,7 +5018,7 @@ int TrackCanvas::button_press_event() update_cursor) ) break; if( do_edits(cursor_x, cursor_y, 1, 0, - update_cursor, rerender, new_cursor, + update_overlay, rerender, new_cursor, update_cursor) ) break; if( do_plugins(cursor_x, cursor_y, 0, 1, diff --git a/cinelerra-5.1/cinelerra/trackpopup.C b/cinelerra-5.1/cinelerra/trackpopup.C new file mode 100644 index 00000000..0b120882 --- /dev/null +++ b/cinelerra-5.1/cinelerra/trackpopup.C @@ -0,0 +1,212 @@ + +/* + * CINELERRA + * Copyright (C) 2008 Adam Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "asset.h" +#include "assets.h" +#include "awindow.h" +#include "awindowgui.h" +#include "edl.h" +#include "edlsession.h" +#include "file.h" +#include "keys.h" +#include "language.h" +#include "localsession.h" +#include "mainerror.h" +#include "mainsession.h" +#include "mwindow.h" +#include "mwindowgui.h" +#include "plugindialog.h" +#include "resizetrackthread.h" +#include "track.h" +#include "tracks.h" +#include "trackpopup.h" +#include "trackcanvas.h" + +#include + +TrackPopup::TrackPopup(MWindow *mwindow, MWindowGUI *gui) + : BC_PopupMenu(0, 0, 0, "", 0) +{ + this->mwindow = mwindow; + this->gui = gui; +} + +TrackPopup::~TrackPopup() +{ +} + +void TrackPopup::create_objects() +{ + add_item(new TrackAttachEffect(mwindow, this)); + add_item(new TrackMoveUp(mwindow, this)); + add_item(new TrackMoveDown(mwindow, this)); + add_item(new TrackPopupDeleteTrack(mwindow, this)); + add_item(new TrackPopupAddTrack(mwindow, this)); + resize_option = 0; + matchsize_option = 0; +} + +int TrackPopup::update(Track *track) +{ + this->track = track; + + if(track->data_type == TRACK_VIDEO && !resize_option) + { + add_item(resize_option = new TrackPopupResize(mwindow, this)); + add_item(matchsize_option = new TrackPopupMatchSize(mwindow, this)); + } + else + if(track->data_type == TRACK_AUDIO && resize_option) + { + del_item(resize_option); resize_option = 0; + del_item(matchsize_option); matchsize_option = 0; + } + return 0; +} + + +TrackAttachEffect::TrackAttachEffect(MWindow *mwindow, TrackPopup *popup) + : BC_MenuItem(_("Attach effect...")) +{ + this->mwindow = mwindow; + this->popup = popup; + dialog_thread = new PluginDialogThread(mwindow); +} + +TrackAttachEffect::~TrackAttachEffect() +{ + delete dialog_thread; +} + +int TrackAttachEffect::handle_event() +{ + dialog_thread->start_window(popup->track, + 0, _(PROGRAM_NAME ": Attach Effect"), + 0, popup->track->data_type); + return 1; +} + + +TrackMoveUp::TrackMoveUp(MWindow *mwindow, TrackPopup *popup) + : BC_MenuItem(_("Move up")) +{ + this->mwindow = mwindow; + this->popup = popup; +} +TrackMoveUp::~TrackMoveUp() +{ +} +int TrackMoveUp::handle_event() +{ + mwindow->move_track_up(popup->track); + return 1; +} + + + +TrackMoveDown::TrackMoveDown(MWindow *mwindow, TrackPopup *popup) + : BC_MenuItem(_("Move down")) +{ + this->mwindow = mwindow; + this->popup = popup; +} +TrackMoveDown::~TrackMoveDown() +{ +} +int TrackMoveDown::handle_event() +{ + mwindow->move_track_down(popup->track); + return 1; +} + + +TrackPopupResize::TrackPopupResize(MWindow *mwindow, TrackPopup *popup) + : BC_MenuItem(_("Resize track...")) +{ + this->mwindow = mwindow; + this->popup = popup; + dialog_thread = new ResizeTrackThread(mwindow); +} +TrackPopupResize::~TrackPopupResize() +{ + delete dialog_thread; +} + +int TrackPopupResize::handle_event() +{ + dialog_thread->start_window(popup->track); + return 1; +} + + +TrackPopupMatchSize::TrackPopupMatchSize(MWindow *mwindow, TrackPopup *popup) + : BC_MenuItem(_("Match output size")) +{ + this->mwindow = mwindow; + this->popup = popup; +} +TrackPopupMatchSize::~TrackPopupMatchSize() +{ +} + +int TrackPopupMatchSize::handle_event() +{ + mwindow->match_output_size(popup->track); + return 1; +} + + +TrackPopupDeleteTrack::TrackPopupDeleteTrack(MWindow *mwindow, TrackPopup *popup) + : BC_MenuItem(_("Delete track")) +{ + this->mwindow = mwindow; + this->popup = popup; +} +int TrackPopupDeleteTrack::handle_event() +{ + mwindow->delete_track(popup->track); + return 1; +} + + +TrackPopupAddTrack::TrackPopupAddTrack(MWindow *mwindow, TrackPopup *popup) + : BC_MenuItem(_("Add track")) +{ + this->mwindow = mwindow; + this->popup = popup; +} + +int TrackPopupAddTrack::handle_event() +{ + switch( popup->track->data_type ) { + case TRACK_AUDIO: + mwindow->add_audio_track_entry(1, popup->track); + break; + case TRACK_VIDEO: + mwindow->add_video_track_entry(popup->track); + break; + case TRACK_SUBTITLE: + mwindow->add_subttl_track_entry(popup->track); + break; + } + return 1; +} + diff --git a/cinelerra-5.1/cinelerra/trackpopup.h b/cinelerra-5.1/cinelerra/trackpopup.h new file mode 100644 index 00000000..de6dd161 --- /dev/null +++ b/cinelerra-5.1/cinelerra/trackpopup.h @@ -0,0 +1,137 @@ + +/* + * CINELERRA + * Copyright (C) 2008 Adam Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __TRACKPOPUP_H__ +#define __TRACKPOPUP_H__ + +#include "guicast.h" +#include "mwindow.inc" +#include "mwindowgui.inc" +#include "plugindialog.inc" +#include "resizetrackthread.inc" +#include "track.inc" +#include "trackpopup.inc" + + +class TrackPopup : public BC_PopupMenu +{ +public: + TrackPopup(MWindow *mwindow, MWindowGUI *gui); + ~TrackPopup(); + + void create_objects(); + int update(Track *track); + + MWindow *mwindow; + MWindowGUI *gui; + Track *track; + TrackPopupResize *resize_option; + TrackPopupMatchSize *matchsize_option; +}; + +class TrackPopupMatchSize : public BC_MenuItem +{ +public: + TrackPopupMatchSize(MWindow *mwindow, TrackPopup *popup); + ~TrackPopupMatchSize(); + int handle_event(); + MWindow *mwindow; + TrackPopup *popup; +}; + +class TrackPopupResize : public BC_MenuItem +{ +public: + TrackPopupResize(MWindow *mwindow, TrackPopup *popup); + ~TrackPopupResize(); + int handle_event(); + MWindow *mwindow; + TrackPopup *popup; + ResizeTrackThread *dialog_thread; +}; + +class TrackPopupDeleteTrack : public BC_MenuItem +{ +public: + TrackPopupDeleteTrack(MWindow *mwindow, TrackPopup *popup); + int handle_event(); + MWindow *mwindow; + TrackPopup *popup; +}; + +class TrackPopupAddTrack : public BC_MenuItem +{ +public: + TrackPopupAddTrack(MWindow *mwindow, TrackPopup *popup); + int handle_event(); + MWindow *mwindow; + TrackPopup *popup; +}; + +class TrackPopupFindAsset : public BC_MenuItem +{ +public: + TrackPopupFindAsset(MWindow *mwindow, TrackPopup *popup); + int handle_event(); + MWindow *mwindow; + TrackPopup *popup; +}; + + +class TrackAttachEffect : public BC_MenuItem +{ +public: + TrackAttachEffect(MWindow *mwindow, TrackPopup *popup); + ~TrackAttachEffect(); + + int handle_event(); + + MWindow *mwindow; + TrackPopup *popup; + PluginDialogThread *dialog_thread; +}; + +class TrackMoveUp : public BC_MenuItem +{ +public: + TrackMoveUp(MWindow *mwindow, TrackPopup *popup); + ~TrackMoveUp(); + + int handle_event(); + + MWindow *mwindow; + TrackPopup *popup; +}; + +class TrackMoveDown : public BC_MenuItem +{ +public: + TrackMoveDown(MWindow *mwindow, TrackPopup *popup); + ~TrackMoveDown(); + + int handle_event(); + + MWindow *mwindow; + TrackPopup *popup; +}; + + +#endif diff --git a/cinelerra-5.1/cinelerra/trackpopup.inc b/cinelerra-5.1/cinelerra/trackpopup.inc new file mode 100644 index 00000000..435e6dca --- /dev/null +++ b/cinelerra-5.1/cinelerra/trackpopup.inc @@ -0,0 +1,35 @@ + +/* + * CINELERRA + * Copyright (C) 2008 Adam Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __TRACKPOPUP_INC__ +#define __TRACKPOPUP_INC__ + +class TrackPopup; +class TrackPopupMatchSize; +class TrackPopupResize; +class TrackPopupDeleteTrack; +class TrackPopupAddTrack; +class TrackPopupFindAsset; +class TrackAttachEffect; +class TrackMoveTrackUp; +class TrackMoveTrackDown; + +#endif diff --git a/cinelerra-5.1/cinelerra/tracks.C b/cinelerra-5.1/cinelerra/tracks.C index 08952e42..bab0b6b4 100644 --- a/cinelerra-5.1/cinelerra/tracks.C +++ b/cinelerra-5.1/cinelerra/tracks.C @@ -105,32 +105,37 @@ void Tracks::equivalent_output(Tracks *tracks, double *result) } - - -void Tracks::get_affected_edits(ArrayList *drag_edits, double position, Track *start_track) +void Tracks::clear_selected_edits() { - drag_edits->remove_all(); + for( Track *track=first; track; track=track->next ) { + for( Edit *edit=track->edits->first; edit; edit=edit->next ) + edit->is_selected = 0; + } +} - for(Track *track = start_track; - track; - track = track->next) - { -//printf("Tracks::get_affected_edits 1 %p %d %d\n", track, track->data_type, track->record); - if(track->record) - { - for(Edit *edit = track->edits->first; edit; edit = edit->next) - { - double startproject = track->from_units(edit->startproject); -//printf("Tracks::get_affected_edits 1 %d\n", edl->equivalent(startproject, position)); - if(edl->equivalent(startproject, position)) - { - drag_edits->append(edit); - break; - } +void Tracks::select_affected_edits(double position, Track *start_track) +{ + for( Track *track=start_track; track; track=track->next ) { + if( !track->record ) continue; + for( Edit *edit=track->edits->first; edit; edit=edit->next ) { + double startproject = track->from_units(edit->startproject); + if( edl->equivalent(startproject, position) ) { + edit->is_selected = 1; + break; } } } +} +void Tracks::get_selected_edits(ArrayList *drag_edits) +{ + drag_edits->remove_all(); + for( Track *track=first; track; track=track->next ) { + for( Edit *edit=track->edits->first; edit; edit=edit->next ) { + if( !edit->is_selected ) continue; + drag_edits->append(edit); + } + } } void Tracks::get_automation_extents(float *min, diff --git a/cinelerra-5.1/cinelerra/tracks.h b/cinelerra-5.1/cinelerra/tracks.h index 7ba98267..22baa7b0 100644 --- a/cinelerra-5.1/cinelerra/tracks.h +++ b/cinelerra-5.1/cinelerra/tracks.h @@ -64,9 +64,9 @@ public: int64_t position); // Construct a list of all the recordable edits which start on position - void get_affected_edits(ArrayList *drag_edits, - double position, - Track *start_track); + void clear_selected_edits(); + void select_affected_edits(double position, Track *start_track); + void get_selected_edits(ArrayList *drag_edits); void get_automation_extents(float *min, float *max,