edit group selection and cut/copy/paste/del shortcuts, interview mode tweaks
authorGood Guy <good1.2guy@gmail.com>
Tue, 11 Dec 2018 02:51:32 +0000 (19:51 -0700)
committerGood Guy <good1.2guy@gmail.com>
Tue, 11 Dec 2018 02:51:32 +0000 (19:51 -0700)
18 files changed:
cinelerra-5.1/cinelerra/Makefile
cinelerra-5.1/cinelerra/awindowgui.C
cinelerra-5.1/cinelerra/edit.C
cinelerra-5.1/cinelerra/edit.h
cinelerra-5.1/cinelerra/editpanel.C
cinelerra-5.1/cinelerra/editpopup.C
cinelerra-5.1/cinelerra/editpopup.h
cinelerra-5.1/cinelerra/editpopup.inc
cinelerra-5.1/cinelerra/mwindow.h
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/cinelerra/mwindowgui.C
cinelerra-5.1/cinelerra/mwindowgui.h
cinelerra-5.1/cinelerra/trackcanvas.C
cinelerra-5.1/cinelerra/trackpopup.C [new file with mode: 0644]
cinelerra-5.1/cinelerra/trackpopup.h [new file with mode: 0644]
cinelerra-5.1/cinelerra/trackpopup.inc [new file with mode: 0644]
cinelerra-5.1/cinelerra/tracks.C
cinelerra-5.1/cinelerra/tracks.h

index 5f7bcbdb2a46af20e765cafb5e37c1a45e961c6b..e9d67aa56c8875439fc7b7d4f0ec50b71b9b482f 100644 (file)
@@ -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 \
index 13e94b9570c4bff7cd57f09478278fe2d199acd7..384090a2e63d39c96adc7b8c4037786b63830090 100644 (file)
@@ -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;
index c680d8c634c4854ba86eb64af4eae0449ac17d01..489a96944de08a04aef3984e56014292344e73f9 100644 (file)
@@ -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;
 }
index d3598adb96af4d98271e257fb92f2d872bf0af34..e377c3361fb1aa895fb2679b8d0d3f4599bf181c 100644 (file)
@@ -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;
 
index 530d530c42fe1ef4ed925254644738c765a08d98..26e5b7d071115c80ac91d206a01249afe03499d8 100644 (file)
@@ -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;
 }
index 25931b5d42a8821443de286a97931fc9880b3278..14a85cf3b8ba77e2b4cc54bca5e45d615c91631a 100644 (file)
@@ -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;
index 89754a25b880ce9ebbb23f9b72723c67c49326e7..488bf4f1d289518f34e35d9a3de228ed327f90af 100644 (file)
 #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:
index c7ea0e2f394cefb99cdb67bd007c4c1688cb1339..37574b1a426e6379afcac433e44de4a07e9093af 100644 (file)
  *
  */
 
-#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
index e862459c8156d079ebdf77feba46ed11753708a8..79bbb5cd606d7b2b59a7b6397d40e706f161fdbb 100644 (file)
@@ -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<Edit*> *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<Edit*> *edits,
                Track *track,
index 3d6a69f0678f09e817eb8d01773385148425ecb6..3e6c89995254e2ea987929bc9581750609f7879a 100644 (file)
@@ -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<Edit*> edits;
+       edits.append(edit);
+       delete_edits(&edits, msg, collapse);
+}
+
+void MWindow::delete_edits(ArrayList<Edit*> *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<Edit*> edits;
+       edl->tracks->get_selected_edits(&edits);
+       delete_edits(&edits,_("del edit"), collapse);
+}
+
+void MWindow::cut_selected_edits(int collapse)
+{
+       selected_to_clipboard();
+       ArrayList<Edit*> edits;
+       edl->tracks->get_selected_edits(&edits);
+       delete_edits(&edits, _("cut edit"), collapse);
+}
+
+
 void MWindow::move_edits(ArrayList<Edit*> *edits,
                Track *track,
                double position,
index d121f29eb222ffba4ad67532455e2aa12bf1fa9b..89ddbccef325bdecc00824de2ec1f23a752159db 100644 (file)
@@ -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;
index 6484dc8184c1927982ad1d32ecf4ba806e380e88..592e38767f674270337fdabf3d157d900a743cc8 100644 (file)
@@ -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;
index c746de7149af56c417a8566ada27087bc2c60c4f..f2b7dd02df8309f963145c21bcd73bd11872e1ad 100644 (file)
@@ -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 (file)
index 0000000..0b12088
--- /dev/null
@@ -0,0 +1,212 @@
+
+/*
+ * CINELERRA
+ * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
+ *
+ * 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 <string.h>
+
+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 (file)
index 0000000..de6dd16
--- /dev/null
@@ -0,0 +1,137 @@
+
+/*
+ * CINELERRA
+ * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
+ *
+ * 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 (file)
index 0000000..435e6dc
--- /dev/null
@@ -0,0 +1,35 @@
+
+/*
+ * CINELERRA
+ * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
+ *
+ * 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
index 08952e429d3fbd06e50bfe9859b335a15e623ceb..bab0b6b47679be66ca9b5b267e25a73c29be64fb 100644 (file)
@@ -105,32 +105,37 @@ void Tracks::equivalent_output(Tracks *tracks, double *result)
 }
 
 
-
-
-void Tracks::get_affected_edits(ArrayList<Edit*> *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<Edit*> *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,
index 7ba9826710bfa0d02a21d43178cd1960fc67427e..22baa7b0c118c2c2fb02acb6a11366c0e980ffea 100644 (file)
@@ -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<Edit*> *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<Edit*> *drag_edits);
 
        void get_automation_extents(float *min,
                float *max,