load files search box, avoid segv in get_prev_keyframe, fix titles only handles,...
authorGood Guy <[email protected]>
Thu, 4 Oct 2018 00:28:46 +0000 (18:28 -0600)
committerGood Guy <[email protected]>
Thu, 4 Oct 2018 00:28:46 +0000 (18:28 -0600)
cinelerra-5.1/cinelerra/keyframes.C
cinelerra-5.1/cinelerra/mainundo.C
cinelerra-5.1/cinelerra/trackcanvas.C
cinelerra-5.1/guicast/bcfilebox.C
cinelerra-5.1/guicast/bcfilebox.h

index 9e90bd641d796fe43f76481d4a97753bb4a1a92b..696c8068387ec4ac3c16c58ddb2f0d563fe8122d 100644 (file)
@@ -80,31 +80,16 @@ KeyFrame* KeyFrames::get_prev_keyframe(int64_t position,
 
 KeyFrame* KeyFrames::get_keyframe()
 {
+       int64_t pos = track->to_units(edl->local_session->get_selectionstart(1), 0);
 // Search for keyframe on or before selection
-       KeyFrame *result =
-               get_prev_keyframe(
-                       track->to_units(edl->local_session->get_selectionstart(1), 0),
-                       PLAY_FORWARD);
-
-// Return nearest keyframe if not in automatic keyframe generation
-       if(!edl->session->auto_keyframes)
-       {
-               return result;
-       }
-       else
-// Return new keyframe
-       if(result == (KeyFrame*)default_auto ||
-               result->position != track->to_units(edl->local_session->get_selectionstart(1), 0))
-       {
-               return (KeyFrame*)insert_auto(track->to_units(edl->local_session->get_selectionstart(1), 0));
+       KeyFrame *result = get_prev_keyframe(pos, PLAY_FORWARD);
+       if( edl->session->auto_keyframes ) {
+               if( !result || result->position != pos ||
+                   result == (KeyFrame*)default_auto )
+// generate keyframes while tweeking, and no keyframe found at pos
+                       result = (KeyFrame*)insert_auto(pos);
        }
-       else
-// Return existing keyframe
-       {
-               return result;
-       }
-
-       return 0;
+       return result;
 }
 
 
index 14268e1d37709f5d0b57e17cb4b89c919c53450d..3a7d92ca440619b72fc6af67a7a5d2f3fc3ae975 100644 (file)
@@ -261,10 +261,8 @@ int MainUndo::load_from_undo(FileXML *file, uint32_t load_flags)
                mwindow->gui->lock_window("MainUndo::load_from_undo");
        }
        if( (load_flags & LOAD_ALL) == LOAD_ALL ) {
-               EDL *edl = new EDL;
-               edl->create_objects();
                mwindow->edl->remove_user();
-               mwindow->edl = edl;
+               mwindow->init_edl();
        }
        mwindow->edl->load_xml(file, load_flags);
        for( Asset *asset=mwindow->edl->assets->first; asset; asset=asset->next ) {
index cbc62e1f1a7f4b3055594077b68ae5486e538fe9..f1afafdf08a34bb71e116b30a4099646dbff2d36 100644 (file)
@@ -3660,6 +3660,8 @@ int TrackCanvas::render_handle_frame(EDL *edl, int64_t pos, int mode)
                int w = canvas->w, h = canvas->h, w2 = w/2, h2 = h/2;
                int lx = 0, ly = h2/2, rx = w2, ry = h2/2;
                BC_WindowBase *window = canvas->get_canvas();
+               window->set_color(BLACK);
+               window->clear_box(0,0, window->get_w(),window->get_h());
                window->draw_vframe(&vlt, lx,ly, w2,h2, 0,0,vlt.get_w(),vlt.get_h());
                window->draw_vframe(&vrt, rx,ry, w2,h2, 0,0,vrt.get_w(),vrt.get_h());
                window->flash(1);
@@ -4451,8 +4453,6 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press,
        int result = 0;
 
        for( Track *track=mwindow->edl->tracks->first; track && !result; track=track->next) {
-               if( !track->show_assets() ) continue;
-
                for( Edit *edit=track->edits->first; edit && !result; edit=edit->next ) {
                        int64_t edit_x, edit_y, edit_w, edit_h;
                        edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h);
@@ -4462,7 +4462,8 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press,
                                if( cursor_x < edit_x + HANDLE_W ) {
                                        edit_result = edit;
                                        handle_result = 0;
-                                       if( cursor_y >= edit_y+edit_h - HANDLE_W ) {
+                                       if( cursor_y >= edit_y+edit_h - HANDLE_W &&
+                                           track->show_assets() ) {
                                                new_cursor = DOWNLEFT_RESIZE;
                                                if( button_press == LEFT_BUTTON )
                                                        result = -1;
@@ -4473,7 +4474,8 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press,
                                else if( cursor_x >= edit_x + edit_w - HANDLE_W ) {
                                        edit_result = edit;
                                        handle_result = 1;
-                                       if( cursor_y >= edit_y+edit_h - HANDLE_W ) {
+                                       if( cursor_y >= edit_y+edit_h - HANDLE_W &&
+                                           track->show_assets() ) {
                                                new_cursor = DOWNRIGHT_RESIZE;
                                                if( button_press == LEFT_BUTTON )
                                                        result = -1;
@@ -4512,7 +4514,7 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press,
                        update_overlay = 1;
                }
        }
-       else if( result <  0) {
+       else if( result < ) {
                mwindow->undo->update_undo_before();
                if( !shift_down() ) {
                        if( handle_result == 0 )
@@ -4662,8 +4664,6 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag
        int result = 0;
 
        for(Track *track = mwindow->edl->tracks->first; track && !result; track = track->next) {
-               if( !track->show_assets() ) continue;
-
                for(Edit *edit = track->edits->first; edit && !result; edit = edit->next) {
                        int64_t edit_x, edit_y, edit_w, edit_h;
                        edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h);
index 80cf3320191f37ec35b4096c7f418485292cb71e..fa2f8b24401483dc332e28db2a8cd5ace6419d20 100644 (file)
@@ -222,6 +222,19 @@ int BC_FileBoxDirectoryText::handle_event()
 }
 
 
+BC_FileBoxSearchText::BC_FileBoxSearchText(int x, int y, BC_FileBox *filebox)
+ : BC_TextBox(x, y, filebox->get_w() - x - 40, 1, "")
+{
+       this->filebox = filebox;
+}
+
+int BC_FileBoxSearchText::handle_event()
+{
+       filebox->refresh();
+       return 1;
+}
+
+
 BC_FileBoxFilterText::BC_FileBoxFilterText(int x, int y, BC_FileBox *filebox)
  : BC_TextBox(x, y, filebox->get_w() - x - 50, 1, filebox->get_resources()->filebox_filter)
 {
@@ -619,6 +632,14 @@ void BC_FileBox::create_objects()
        x = 10;
        y += directory_title->get_h() + 5;
 
+       BC_Title *search_title;
+       add_subwindow(search_title = new BC_Title(x, y, _("Search:")));
+       x += search_title->get_w() + 10;
+       add_subwindow(search_text = new BC_FileBoxSearchText(x, y, this));
+
+       x = 10;
+       y += search_text->get_h() + 5;
+
        int newest_id = 0, newest = -1;
        for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++) {
                if( !resources->filebox_history[i].path[0] ) continue;
@@ -729,6 +750,11 @@ int BC_FileBox::resize_event(int w, int h)
                directory_title->get_y(),
                directory_title->get_w() + recent_popup->get_w(),
                recent_popup->get_h());
+       search_text->reposition_window(
+               search_text->get_x(),
+               search_text->get_y(),
+               get_w() - search_text->get_x() -  40,
+               1);
        textbox->reposition_window(textbox->get_x(),
                h - (get_h() - textbox->get_y()),
                w - (get_w() - textbox->get_w()),
@@ -819,6 +845,9 @@ int BC_FileBox::create_tables(int select_all)
        for(int i = 0; i < fs->total_files(); i++)
        {
                FileItem *file_item = fs->get_entry(i);
+               const char *text = search_text->get_text();
+               if( text && text[0] && !bstrcasestr(file_item->name, text) )
+                       continue;
                int is_dir = file_item->is_dir;
                BC_Pixmap* icon = get_icon(file_item->name, is_dir);
 
index 96d1ebe2b4065e2a8ec1744a090d89e301c429c4..f450ec5c52f97eaba1eea855e3e3489506cf5d1b 100644 (file)
@@ -126,6 +126,14 @@ public:
        BC_FileBox *filebox;
 };
 
+class BC_FileBoxSearchText : public BC_TextBox
+{
+public:
+       BC_FileBoxSearchText(int x, int y, BC_FileBox *filebox);
+       int handle_event();
+       BC_FileBox *filebox;
+};
+
 class BC_FileBoxFilterText : public BC_TextBox
 {
 public:
@@ -231,6 +239,7 @@ public:
 
        friend class BC_FileBoxCancel;
        friend class BC_FileBoxDirectoryText;
+       friend class BC_FileBoxSearchText;
        friend class BC_FileBoxListBox;
        friend class BC_FileBoxTextBox;
        friend class BC_FileBoxText;
@@ -310,7 +319,8 @@ private:
        BC_Title *filter_title;
        BC_FileBoxFilterText *filter_text;
        BC_FileBoxFilterMenu *filter_popup;
-       BC_TextBox *directory_title;
+       BC_FileBoxDirectoryText *directory_title;
+       BC_FileBoxSearchText *search_text;
        BC_Button *icon_button;
        BC_Button *text_button;
        BC_Button *folder_button;