From 219e9cae947fc9454f65c210d600800158d798fb Mon Sep 17 00:00:00 2001 From: Good Guy Date: Wed, 3 Oct 2018 18:28:46 -0600 Subject: [PATCH] load files search box, avoid segv in get_prev_keyframe, fix titles only handles, black bg render handle drag, fix perpetual session edl session init --- cinelerra-5.1/cinelerra/keyframes.C | 31 +++++++-------------------- cinelerra-5.1/cinelerra/mainundo.C | 4 +--- cinelerra-5.1/cinelerra/trackcanvas.C | 14 ++++++------ cinelerra-5.1/guicast/bcfilebox.C | 29 +++++++++++++++++++++++++ cinelerra-5.1/guicast/bcfilebox.h | 12 ++++++++++- 5 files changed, 56 insertions(+), 34 deletions(-) diff --git a/cinelerra-5.1/cinelerra/keyframes.C b/cinelerra-5.1/cinelerra/keyframes.C index 9e90bd64..696c8068 100644 --- a/cinelerra-5.1/cinelerra/keyframes.C +++ b/cinelerra-5.1/cinelerra/keyframes.C @@ -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; } diff --git a/cinelerra-5.1/cinelerra/mainundo.C b/cinelerra-5.1/cinelerra/mainundo.C index 14268e1d..3a7d92ca 100644 --- a/cinelerra-5.1/cinelerra/mainundo.C +++ b/cinelerra-5.1/cinelerra/mainundo.C @@ -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 ) { diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index cbc62e1f..f1afafdf 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -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 < 0 ) { 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); diff --git a/cinelerra-5.1/guicast/bcfilebox.C b/cinelerra-5.1/guicast/bcfilebox.C index 80cf3320..fa2f8b24 100644 --- a/cinelerra-5.1/guicast/bcfilebox.C +++ b/cinelerra-5.1/guicast/bcfilebox.C @@ -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); diff --git a/cinelerra-5.1/guicast/bcfilebox.h b/cinelerra-5.1/guicast/bcfilebox.h index 96d1ebe2..f450ec5c 100644 --- a/cinelerra-5.1/guicast/bcfilebox.h +++ b/cinelerra-5.1/guicast/bcfilebox.h @@ -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; -- 2.26.2