tweak map media vicon popup timeline drag/select
authorGood Guy <good1.2guy@gmail.com>
Tue, 4 Dec 2018 02:03:35 +0000 (19:03 -0700)
committerGood Guy <good1.2guy@gmail.com>
Tue, 4 Dec 2018 02:03:35 +0000 (19:03 -0700)
cinelerra-5.1/cinelerra/awindowgui.C
cinelerra-5.1/cinelerra/awindowgui.h
cinelerra-5.1/guicast/vicon.C
cinelerra-5.1/guicast/vicon.h

index 30ae58b39a2f1afcafe649d059c83523b86615a7..e8701eaa0f4be841bdc5d98c4368967a0c75ad33 100644 (file)
@@ -307,13 +307,25 @@ void AssetVIcon::stop_audio()
        playing_audio = 0;
 }
 
        playing_audio = 0;
 }
 
-int AssetVIcon::popup_button_press(int x, int y)
+
+AssetVIconThread::AssetVIconThread(AWindowAssets *asset_list)
+ : VIconThread(asset_list)
+{
+       popup_dragging = 0;
+}
+
+AssetVIconThread::~AssetVIconThread()
+{
+}
+
+int AssetVIconThread::popup_button_press(int x, int y)
 {
 {
-       if( playing_audio >= 0 ) return 0;
-       VIconThread *vt = picon->gui->vicon_thread;
-       ViewPopup *view_win = vt->view_win;
        if( !view_win || !view_win->is_event_win() ) return 0;
        if( !view_win || !view_win->is_event_win() ) return 0;
+       if( !vicon || vicon->playing_audio >= 0 ) return 0;
+       popup_dragging = 0;
        int view_w = view_win->get_w(), view_h = view_win->get_h();
        int view_w = view_win->get_w(), view_h = view_win->get_h();
+       AssetVIcon *vicon = (AssetVIcon *)this->vicon;
+       AssetPicon *picon = vicon->picon;
        MWindow *mwindow = picon->mwindow;
        EDL *edl = mwindow->edl;
        if( y < VIEW_POPUP_BAR_H ) {
        MWindow *mwindow = picon->mwindow;
        EDL *edl = mwindow->edl;
        if( y < VIEW_POPUP_BAR_H ) {
@@ -361,21 +373,70 @@ int AssetVIcon::popup_button_press(int x, int y)
                vwindow->update_position(CHANGE_NONE, 0, 1, 0);
                return 1;
        }
                vwindow->update_position(CHANGE_NONE, 0, 1, 0);
                return 1;
        }
-       return y < view_h-VIEW_POPUP_BAR_H ? 0 : popup_cursor_motion(x, y);
+       if( y >= view_h-VIEW_POPUP_BAR_H ) {
+               popup_dragging = 1;
+               if( !view_win->ctrl_down() )
+                       return popup_cursor_motion(x, y);
+               Indexable *idxbl =
+                       picon->indexable ? picon->indexable :
+                       picon->edl ? picon->edl : 0;
+               if( !idxbl ) return 0;
+               double total_length = mwindow->edl->tracks->total_length();
+               double pos = x * total_length / view_w;
+               double start = 0, end = total_length;
+               double lt = DBL_MAX, rt = DBL_MAX;
+               for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
+                       for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
+                               Indexable *indexable = (Indexable *)edit->asset;
+                               if( !indexable ) indexable = (Indexable *)edit->nested_edl;
+                               if( !indexable ) continue;
+                               if( indexable->id == idxbl->id ||
+                                   (!indexable->is_asset == !idxbl->is_asset &&
+                                    !strcmp(indexable->path, idxbl->path)) ) {
+                                       double start_pos = track->from_units(edit->startproject);
+                                       double end_pos = track->from_units(edit->startproject + edit->length);
+                                       double dlt = pos - start_pos, drt = end_pos - pos;
+                                       if( dlt >= 0 &&  dlt < lt ) { lt = dlt;  start = start_pos; }
+                                       else if( dlt < 0 && -dlt < rt ) { rt = -dlt;  end = start_pos; }
+                                       if( drt >= 0 &&  drt < rt ) { rt = drt;  end = end_pos; }
+                                       else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
+                               }
+                       }
+               }
+               mwindow->gui->lock_window("AssetVIcon::popup_button_press");
+               edl->local_session->set_selectionstart(pos);
+               edl->local_session->set_selectionend(pos);
+               mwindow->find_cursor();
+               edl->local_session->set_selectionstart(start);
+               edl->local_session->set_selectionend(end);
+               mwindow->zoom_sample(edl->local_session->zoom_sample);
+               mwindow->gui->unlock_window();
+               return 1;
+       }
+       return 0;
 }
 
 }
 
-int AssetVIcon::popup_cursor_motion(int x, int y)
+int AssetVIconThread::popup_button_release(int x, int y)
 {
 {
-       if( playing_audio >= 0 ) return 0;
-       VIconThread *vt = picon->gui->vicon_thread;
-       ViewPopup *view_win = (ViewPopup *)vt->view_win;
-       if( !view_win || !view_win->is_event_win() ||
-           !view_win->get_button_down() ) return 0;
-       int view_w = view_win->get_w(), view_h = view_win->get_h();
-       MWindow *mwindow = picon->mwindow;
+       if( !view_win || !view_win->is_event_win() ) return 0;
+       if( !vicon || vicon->playing_audio >= 0 ) return 0;
+       popup_dragging = 0;
+       return 1;
+}
+
+int AssetVIconThread::popup_cursor_motion(int x, int y)
+{
+       if( !view_win || !view_win->is_event_win() ) return 0;
+       if( !vicon || vicon->playing_audio >= 0 ) return 0;
+       if( !view_win->get_button_down() || view_win->get_buttonpress() != 1 ||
+           view_win->ctrl_down() || view_win->alt_down() || view_win->shift_down() )
+               return 0;
+       AssetVIcon *vicon = (AssetVIcon *)this->vicon;
+       MWindow *mwindow = vicon->picon->mwindow;
        EDL *edl = mwindow->edl;
        EDL *edl = mwindow->edl;
-       if( y >= view_h-VIEW_POPUP_BAR_H ) {
+       if( popup_dragging ) {
                double total_length = edl->tracks->total_length();
                double total_length = edl->tracks->total_length();
+               int view_w = view_win->get_w();
                double pos = x * total_length / view_w;
                mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
                mwindow->select_point(pos);
                double pos = x * total_length / view_w;
                mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
                mwindow->select_point(pos);
@@ -1201,7 +1262,7 @@ void AWindowGUI::create_objects()
        y1 += dy;  h1 -= dy;
        add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
 
        y1 += dy;  h1 -= dy;
        add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
 
-       vicon_thread = new VIconThread(asset_list);
+       vicon_thread = new AssetVIconThread(asset_list);
        asset_list->update_vicon_area();
        vicon_thread->start();
        vicon_audio = new AssetVIconAudio(this);
        asset_list->update_vicon_area();
        vicon_thread->start();
        vicon_audio = new AssetVIconAudio(this);
@@ -2525,7 +2586,7 @@ void AWindowAssets::draw_vframe(BC_WindowBase *wdw, VFrame *vframe)
        wdw->draw_box(0,0,wdw->get_w(),wdw->get_h());
        wdw->draw_vframe(vframe, 0,y1, wdw->get_w(),y2-y1);
        ViewPopup *view_popup = (ViewPopup *)wdw;
        wdw->draw_box(0,0,wdw->get_w(),wdw->get_h());
        wdw->draw_vframe(vframe, 0,y1, wdw->get_w(),y2-y1);
        ViewPopup *view_popup = (ViewPopup *)wdw;
-       VIconThread *vt = view_popup->vt;
+       AssetVIconThread *vt = (AssetVIconThread *)view_popup->vt;
        AssetVIcon *vicon = (AssetVIcon *)vt->vicon;
        AssetPicon *picon = (AssetPicon *)vicon->picon;
        Indexable *idxbl =
        AssetVIcon *vicon = (AssetVIcon *)vt->vicon;
        AssetPicon *picon = (AssetPicon *)vicon->picon;
        Indexable *idxbl =
index b936647fd7b572ee874c9ac32ad4688eec53cf33..d15e19f5d30a87607f2651749c9f7f9ee9e2239c 100644 (file)
@@ -155,13 +155,25 @@ public:
        void load_audio();
        void start_audio();
        void stop_audio();
        void load_audio();
        void start_audio();
        void stop_audio();
-       int popup_button_press(int x, int y);
-       int popup_cursor_motion(int x, int y);
 
        AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
        ~AssetVIcon();
 };
 
 
        AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length);
        ~AssetVIcon();
 };
 
+class AssetVIconThread : public VIconThread
+{
+public:
+       AssetVIconThread(AWindowAssets *asset_list);
+       ~AssetVIconThread();
+
+       int popup_button_press(int x, int y);
+       int popup_button_release(int x, int y);
+       int popup_cursor_motion(int x, int y);
+
+       int popup_dragging;
+};
+
+
 class AWindowRemovePlugin;
 
 class AWindowRemovePluginGUI : public BC_Window {
 class AWindowRemovePlugin;
 
 class AWindowRemovePluginGUI : public BC_Window {
index 119b63447902e3a5fe2fa06df04ab39ce831c06d..ecd555129aeae8f9a07a66d7c89158d14619333c 100644 (file)
@@ -174,13 +174,15 @@ int ViewPopup::keypress_event()
 
 int ViewPopup::button_press_event()
 {
 
 int ViewPopup::button_press_event()
 {
-       return !vt->vicon ? 0 :
-               vt->vicon->popup_button_press(get_cursor_x(), get_cursor_y());
+       return vt->popup_button_press(get_cursor_x(), get_cursor_y());
+}
+int ViewPopup::button_release_event()
+{
+       return vt->popup_button_release(get_cursor_x(), get_cursor_y());
 }
 int ViewPopup::cursor_motion_event()
 {
 }
 int ViewPopup::cursor_motion_event()
 {
-       return !vt->vicon ? 0 :
-               vt->vicon->popup_cursor_motion(get_cursor_x(), get_cursor_y());
+       return vt->popup_cursor_motion(get_cursor_x(), get_cursor_y());
 }
 
 
 }
 
 
index bab38462b643b284aed7059b0e642e2e6bf510aa..096182985852ca73a14e846b023b7f98c813aacb 100644 (file)
@@ -16,6 +16,7 @@ public:
        VIconThread *vt;
        int keypress_event();
        int button_press_event();
        VIconThread *vt;
        int keypress_event();
        int button_press_event();
+       int button_release_event();
        int cursor_motion_event();
 
        ViewPopup(VIconThread *vt, VFrame *frame, int x, int y, int w, int h);
        int cursor_motion_event();
 
        ViewPopup(VIconThread *vt, VFrame *frame, int x, int y, int w, int h);
@@ -59,8 +60,6 @@ public:
        virtual void load_audio() {}
        virtual void start_audio() {}
        virtual void stop_audio() {}
        virtual void load_audio() {}
        virtual void start_audio() {}
        virtual void stop_audio() {}
-       virtual int popup_button_press(int x, int y) { return 0; }
-       virtual int popup_cursor_motion(int x, int y) { return 0; }
 
        void add_image(VFrame *frm, int ww, int hh, int vcmdl);
        void draw_vframe(VIconThread *vt, BC_WindowBase *wdw, int x, int y);
 
        void add_image(VFrame *frm, int ww, int hh, int vcmdl);
        void draw_vframe(VIconThread *vt, BC_WindowBase *wdw, int x, int y);
@@ -105,6 +104,9 @@ public:
        void close_view_popup();
        void hide_vicons(int v=1);
        ViewPopup *new_view_window(VFrame *frame);
        void close_view_popup();
        void hide_vicons(int v=1);
        ViewPopup *new_view_window(VFrame *frame);
+       virtual int popup_button_press(int x, int y) { return 0; }
+       virtual int popup_button_release(int x, int y) { return 0; }
+       virtual int popup_cursor_motion(int x, int y) { return 0; }
 
        virtual bool visible(VIcon *vicon, int x, int y);
        virtual void drawing_started() {}
 
        virtual bool visible(VIcon *vicon, int x, int y);
        virtual void drawing_started() {}