usb_direct fix for rev2 shuttle, playbackengine locks again, viewer cursor fix
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / awindowgui.C
index 072f878e80fd933c8bb4dcb88503763c13f691a0..8b53f7ad594b1cb7a61d0e3f7390307e23570624 100644 (file)
@@ -328,24 +328,36 @@ int AssetViewPopup::button_press_event()
        AssetVIconThread *avt = (AssetVIconThread *)vt;
        if( !avt->vicon ) return 0;
 
-       int dir = 1, button = get_buttonpress();
-       switch( button ) {
-       case WHEEL_DOWN: dir = -1; // fall thru
-       case WHEEL_UP:   return zoom_scale(dir);
+       switch( draw_mode ) {
+       case ASSET_VIEW_MEDIA_MAP:
+       case ASSET_VIEW_FULL:
+               break;
+       default:
+               return 0;
+       }
+
+       int dir = 1;
+       switch( get_buttonpress() ) {
        case LEFT_BUTTON:
                break;
+       case WHEEL_DOWN:
+               dir = -1;
+               // fall thru
+       case WHEEL_UP:
+               if( draw_mode != ASSET_VIEW_FULL )
+                       return avt->zoom_scale(dir);
+               // fall thru
        default:
                return 0;
        }
 
-       if( draw_mode != ASSET_VIEW_MEDIA_MAP ) return 0;
        int x = get_cursor_x(), y = get_cursor_y();
        AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
        AssetPicon *picon = vicon->picon;
        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;
@@ -386,11 +398,13 @@ int AssetViewPopup::button_press_event()
                vedl->set_inpoint(start);
                vedl->set_outpoint(end);
                vedl->local_session->set_selectionstart(start);
-               vedl->local_session->set_selectionend(end);
-               vwindow->update_position(CHANGE_NONE, 0, 1, 0);
+               vedl->local_session->set_selectionend(start);
+               vwindow->gui->lock_window("AssetViewPopup::button_press_event");
+               vwindow->update_position();
+               vwindow->gui->unlock_window();
                return 1;
        }
-       if( y >= get_h()-bar_h ) {
+       else {
                dragging = 1;
                if( !ctrl_down() && !shift_down() )
                        return cursor_motion_event();
@@ -442,7 +456,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;
@@ -472,6 +488,7 @@ void AssetViewPopup::draw_vframe(VFrame *vframe)
        default:
                return;
        case ASSET_VIEW_MEDIA_MAP:
+       case ASSET_VIEW_FULL:
                break;
        }
        set_color(BLACK);
@@ -499,6 +516,7 @@ void AssetViewPopup::draw_vframe(VFrame *vframe)
        double total_length = edl->tracks->total_length();
        if( !total_length ) total_length = 1;
        for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
+               if( !track->record ) continue;
                for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
                        Indexable *indexable = (Indexable *)edit->asset;
                        if( !indexable ) indexable = (Indexable *)edit->nested_edl;
@@ -533,6 +551,27 @@ void AssetViewPopup::draw_vframe(VFrame *vframe)
        }
 }
 
+int AssetViewPopup::keypress_event()
+{
+       AssetVIconThread *avt = (AssetVIconThread *)vt;
+       switch( avt->draw_mode ) {
+       case ASSET_VIEW_MEDIA_MAP:
+               switch( get_keypress() ) {
+               case 'f':
+               case 'F':
+                       avt->draw_mode = ASSET_VIEW_FULL;
+                       avt->viewing = 0;
+                       return 1;
+               }
+               break;
+       case ASSET_VIEW_FULL:
+               avt->draw_mode = ASSET_VIEW_MEDIA_MAP;
+               avt->viewing = 0;
+               return 1;
+       }
+       return ViewPopup::keypress_event();
+}
+
 
 AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
  : VIconThread(gui->asset_list, preferences->vicon_size * 16/9, preferences->vicon_size,
@@ -547,10 +586,22 @@ AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
        case VICON_COLOR_MODE_HIGH:  vicon_cmodel = BC_RGB888;  break;
        }
        this->vicon_cmodel = vicon_cmodel;
+       this->draw_lock = new Mutex("AssetVIconThread::draw_lock");
 }
 
 AssetVIconThread::~AssetVIconThread()
 {
+       delete draw_lock;
+}
+
+void AssetVIconThread::drawing_started()
+{
+       draw_lock->lock("AssetVIconThread::drawing_started");
+}
+
+void AssetVIconThread::drawing_stopped()
+{
+       draw_lock->unlock();
 }
 
 void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
@@ -567,22 +618,33 @@ void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
 ViewPopup *AssetVIconThread::new_view_window()
 {
        BC_WindowBase *parent = wdw->get_parent();
-       XineramaScreenInfo *info = parent->get_xinerama_info(-1);
-       int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
-       int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
-       int vx = viewing->get_vx(), rx = 0;
-       int vy = viewing->get_vy(), ry = 0;
-       wdw->get_root_coordinates(vx, vy, &rx, &ry);
-       rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
-       ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
-       AssetViewPopup *popup = new AssetViewPopup(this, draw_mode,
-               rx, ry, view_w, view_h);
-       if( draw_mode == ASSET_VIEW_MEDIA_MAP )
+       int rx = 0, ry = 0, rw = 0, rh = 0;
+       if( draw_mode != ASSET_VIEW_FULL ) {
+               XineramaScreenInfo *info = parent->get_xinerama_info(-1);
+               int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
+               int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
+               int vx = viewing->get_vx(), vy = viewing->get_vy();
+               wdw->get_root_coordinates(vx, vy, &rx, &ry);
+               rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
+               ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
+               rw = view_w;  rh = view_h;
+       }
+       else
+               parent->get_fullscreen_geometry(rx, ry, rw, rh);
+       AssetViewPopup *popup = new AssetViewPopup(this, draw_mode, rx, ry, rw, rh);
+       if( draw_mode == ASSET_VIEW_MEDIA_MAP || draw_mode == ASSET_VIEW_FULL )
                vicon->playing_audio = -1;
        wdw->set_active_subwindow(popup);
        return popup;
 }
 
+void AssetVIconThread::close_view_popup()
+{
+       stop_drawing();
+       drawing_started(); // waits for draw lock
+       drawing_stopped();
+}
+
 
 AWindowFolderItem::AWindowFolderItem()
  : BC_ListBoxItem()
@@ -1153,14 +1215,6 @@ AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
        video_vframe = 0;               video_icon = 0;
        label_vframe = 0;               label_icon = 0;
 
-       atransition_vframe = 0;         atransition_icon = 0;
-       vtransition_vframe = 0;         vtransition_icon = 0;
-       aeffect_vframe = 0;             aeffect_icon = 0;
-       ladspa_vframe = 0;              ladspa_icon = 0;
-       veffect_vframe = 0;             veffect_icon = 0;
-       ff_aud_vframe = 0;              ff_aud_icon = 0;
-       ff_vid_vframe = 0;              ff_vid_icon = 0;
-
        aeffect_folder_vframe = 0;      aeffect_folder_icon = 0;
        atransition_folder_vframe = 0;  atransition_folder_icon = 0;
        clip_folder_vframe = 0;         clip_folder_icon = 0;
@@ -1553,6 +1607,11 @@ void AWindowGUI::stop_vicon_drawing()
        vicon_thread->stop_drawing();
 }
 
+void AWindowGUI::close_view_popup()
+{
+       vicon_thread->close_view_popup();
+}
+
 VFrame *AssetPicon::get_vicon_frame()
 {
        if( !vicon ) return 0;
@@ -2570,7 +2629,7 @@ int AWindowAssets::button_press_event()
                case WHEEL_UP: {
                        int x = get_cursor_x(), y = get_cursor_y();
                        if( avt->cursor_inside(x, y) && avt->view_win )
-                               return avt->view_win->zoom_scale(dir);
+                               return avt->zoom_scale(dir);
                        return 1; }
                }
        }