clip fixes, ladspa build fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / vwindowgui.C
index 7fcd82a264e75877385cb637e512a61fe6e4978c..0c4621e2bb2f3e096dda7ae4364d708177b32c9a 100644 (file)
@@ -76,6 +76,7 @@ VWindowGUI::VWindowGUI(MWindow *mwindow, VWindow *vwindow)
        meters = 0;
 //     source = 0;
        strcpy(loaded_title, "");
+       highlighted = 0;
 }
 
 VWindowGUI::~VWindowGUI()
@@ -394,34 +395,20 @@ void VWindowGUI::drag_motion()
 // Window hidden
        if(get_hidden()) return;
        if(mwindow->session->current_operation != DRAG_ASSET) return;
-
-       int old_status = mwindow->session->vcanvas_highlighted;
-
-       int cursor_x = get_relative_cursor_x();
-       int cursor_y = get_relative_cursor_y();
-
-       mwindow->session->vcanvas_highlighted = (get_cursor_over_window() &&
-               cursor_x >= canvas->x &&
-               cursor_x < canvas->x + canvas->w &&
-               cursor_y >= canvas->y &&
-               cursor_y < canvas->y + canvas->h);
-
-
-//printf("VWindowGUI::drag_motion 1 %d %d %d %d %d\n", __LINE__,
-// mwindow->session->vcanvas_highlighted, get_cursor_over_window(), cursor_x, cursor_y);
-
-       if(old_status != mwindow->session->vcanvas_highlighted)
-               canvas->draw_refresh();
+       int need_highlight = cursor_above() && get_cursor_over_window() ? 1 : 0;
+       if( highlighted == need_highlight ) return;
+       highlighted = need_highlight;
+       canvas->draw_refresh();
 }
 
 int VWindowGUI::drag_stop()
 {
        if(get_hidden()) return 0;
 
-       if(mwindow->session->vcanvas_highlighted &&
+       if(highlighted &&
                mwindow->session->current_operation == DRAG_ASSET)
        {
-               mwindow->session->vcanvas_highlighted = 0;
+               highlighted = 0;
                canvas->draw_refresh();
 
                Indexable *indexable = mwindow->session->drag_assets->size() ?
@@ -667,61 +654,11 @@ void VWindowEditing::clear_outpoint()
 
 void VWindowEditing::to_clip()
 {
-       if(vwindow->get_edl())
-       {
-               FileXML file;
-               EDL *edl = vwindow->get_edl();
-               double start = edl->local_session->get_selectionstart();
-               double end = edl->local_session->get_selectionend();
-
-               if(EQUIV(start, end))
-               {
-                       end = edl->tracks->total_length();
-                       start = 0;
-               }
-
-
-
-               edl->copy(start,
-                       end,
-                       1,
-                       0,
-                       0,
-                       &file,
-                       "",
-                       1);
-
-
-
-
-               EDL *new_edl = new EDL(mwindow->edl);
-               new_edl->create_objects();
-               new_edl->load_xml(&file, LOAD_ALL);
-               sprintf(new_edl->local_session->clip_title,
-                       _("Clip %d"), mwindow->session->clip_number++);
-               char string[BCTEXTLEN];
-               Units::totext(string,
-                               end - start,
-                               edl->session->time_format,
-                               edl->session->sample_rate,
-                               edl->session->frame_rate,
-                               edl->session->frames_per_foot);
-
-               sprintf(new_edl->local_session->clip_notes,
-                       _("%s\n Created from:\n%s"), string, vwindow->gui->loaded_title);
-
-               new_edl->local_session->set_selectionstart(0);
-               new_edl->local_session->set_selectionend(0);
-
-
-//printf("VWindowEditing::to_clip 1 %s\n", edl->local_session->clip_title);
-               new_edl->local_session->set_selectionstart(0.0);
-               new_edl->local_session->set_selectionend(0.0);
-               vwindow->clip_edit->create_clip(new_edl);
-       }
+       EDL *edl = vwindow->get_edl();
+       if( !edl ) return;
+       mwindow->to_clip(edl, _("viewer window: "));
 }
 
-
 VWindowSource::VWindowSource(MWindow *mwindow, VWindowGUI *vwindow, int x, int y)
  : BC_PopupTextBox(vwindow,
        &vwindow->sources,
@@ -878,7 +815,7 @@ void VWindowCanvas::draw_refresh(int flush)
 
 void VWindowCanvas::draw_overlays()
 {
-       if(mwindow->session->vcanvas_highlighted)
+       if( gui->highlighted )
        {
                get_canvas()->set_color(WHITE);
                get_canvas()->set_inverse();