From 7eded24eb31529ad7652dea64e34b0a6210e5be1 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Fri, 12 Oct 2018 16:42:15 -0600 Subject: [PATCH] reload plugin btn in prefs, speed gang fader tweaks --- cinelerra-5.1/cinelerra/interfaceprefs.C | 28 ++++- cinelerra-5.1/cinelerra/interfaceprefs.h | 11 ++ cinelerra-5.1/cinelerra/interfaceprefs.inc | 3 + cinelerra-5.1/cinelerra/keyframepopup.C | 11 +- cinelerra-5.1/cinelerra/mainundo.C | 3 + cinelerra-5.1/cinelerra/mwindow.C | 7 +- cinelerra-5.1/cinelerra/preferencesthread.C | 4 +- cinelerra-5.1/cinelerra/trackcanvas.C | 117 ++++++++++---------- cinelerra-5.1/cinelerra/trackcanvas.h | 4 +- 9 files changed, 118 insertions(+), 70 deletions(-) diff --git a/cinelerra-5.1/cinelerra/interfaceprefs.C b/cinelerra-5.1/cinelerra/interfaceprefs.C index 9c0b51dd..60241a77 100644 --- a/cinelerra-5.1/cinelerra/interfaceprefs.C +++ b/cinelerra-5.1/cinelerra/interfaceprefs.C @@ -125,9 +125,10 @@ void InterfacePrefs::create_objects() y += 5; add_subwindow(new BC_Title(x, y, _("Operation:"), LARGEFONT, resources->text_default)); - y += 35; int y1 = y; + y += 15; + AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y); add_subwindow(android_remote); y += android_remote->get_h() + 10; @@ -139,11 +140,14 @@ void InterfacePrefs::create_objects() add_subwindow(title = new BC_Title(x2, y, _("PIN:"))); AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y); add_subwindow(android_pin); - y += title->get_h() + 30; + y += title->get_h() + 20; ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y); add_subwindow(shbtn_prefs); - y += shbtn_prefs->get_h() + 30; + y += shbtn_prefs->get_h() + 20; + + add_subwindow(reload_plugins = new PrefsReloadPlugins(pwindow, this, x2, y)); + y += reload_plugins->get_h() + 10; add_subwindow(title = new BC_Title(x2, y, _("Default LV2_PATH:"))); y += title->get_h() + 10; @@ -152,7 +156,7 @@ void InterfacePrefs::create_objects() y += 30; y2 = y; - x = x0; y = y1; + x = x0; y = y1 + 35; add_subwindow(file_probes = new PrefsFileProbes(pwindow, this, x, y)); y += 30; @@ -647,6 +651,22 @@ int PrefsAutostartLV2UI::handle_event() return 1; } +PrefsReloadPlugins::PrefsReloadPlugins(PreferencesWindow *pwindow, + InterfacePrefs *iface_prefs, int x, int y) + : BC_GenericButton(x, y, _("Reload plugin index")) +{ + this->pwindow = pwindow; + this->iface_prefs = iface_prefs; +} + +int PrefsReloadPlugins::handle_event() +{ + pwindow->thread->reload_plugins = 1; + text_color(get_resources()->button_highlighted); + draw_face(1); + return 1; +} + PrefsLV2PathText::PrefsLV2PathText(PreferencesWindow *pwindow, InterfacePrefs *subwindow, int x, int y, int w) : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->lv2_path) diff --git a/cinelerra-5.1/cinelerra/interfaceprefs.h b/cinelerra-5.1/cinelerra/interfaceprefs.h index 1d1844c1..0a6f761a 100644 --- a/cinelerra-5.1/cinelerra/interfaceprefs.h +++ b/cinelerra-5.1/cinelerra/interfaceprefs.h @@ -64,6 +64,7 @@ public: PrefsTrapSigSEGV *trap_segv; PrefsTrapSigINTR *trap_intr; SnapshotPathText *snapshot_path; + PrefsReloadPlugins *reload_plugins; }; @@ -307,5 +308,15 @@ public: InterfacePrefs *subwindow; }; +class PrefsReloadPlugins : public BC_GenericButton +{ +public: + PreferencesWindow *pwindow; + InterfacePrefs *iface_prefs; + + int handle_event(); + PrefsReloadPlugins(PreferencesWindow *pwindow, + InterfacePrefs *iface_prefs, int x, int y); +}; #endif diff --git a/cinelerra-5.1/cinelerra/interfaceprefs.inc b/cinelerra-5.1/cinelerra/interfaceprefs.inc index 7fe7f91e..5ce8cb5b 100644 --- a/cinelerra-5.1/cinelerra/interfaceprefs.inc +++ b/cinelerra-5.1/cinelerra/interfaceprefs.inc @@ -45,5 +45,8 @@ class PrefsTrapSigINTR; class PrefsFileProbes; class PrefsYUV420P_DVDlace; class SnapshotPathText; +class PrefsAutostartLV2UI; +class PrefsLV2PathText; +class PrefsReloadPlugins; #endif diff --git a/cinelerra-5.1/cinelerra/keyframepopup.C b/cinelerra-5.1/cinelerra/keyframepopup.C index 362e51e8..7624da16 100644 --- a/cinelerra-5.1/cinelerra/keyframepopup.C +++ b/cinelerra-5.1/cinelerra/keyframepopup.C @@ -49,6 +49,7 @@ #include "theme.h" #include "timelinepane.h" #include "track.h" +#include "trackcanvas.h" #include "vtrack.h" KeyframePopup::KeyframePopup(MWindow *mwindow, MWindowGUI *gui) @@ -651,12 +652,20 @@ void KeySpeedPatch::update_speed(float v) { patch->change_source = 1; double position = mwindow->edl->local_session->get_selectionstart(1); - Autos *speed_autos = patch->track->automation->autos[AUTOMATION_SPEED]; + Track *track = patch->track; + Autos *speed_autos = track->automation->autos[AUTOMATION_SPEED]; int need_undo = !speed_autos->auto_exists_for_editing(position); mwindow->undo->update_undo_before(_("speed"), need_undo ? 0 : this); FloatAuto *current = (FloatAuto*)speed_autos->get_auto_for_editing(position); + float change = v - current->get_value(); current->set_value(v); + if( track->gang && track->record ) { + TrackCanvas *track_canvas = patch->patchbay->pane->canvas; + track_canvas->fill_ganged_autos(1, change, track, current); + track_canvas->update_ganged_autos(0, track, current); + track_canvas->clear_ganged_autos(); + } mwindow->undo->update_undo_after(_("speed"), LOAD_AUTOMATION+LOAD_EDITS); patch->change_source = 0; diff --git a/cinelerra-5.1/cinelerra/mainundo.C b/cinelerra-5.1/cinelerra/mainundo.C index 3a7d92ca..0c149cd4 100644 --- a/cinelerra-5.1/cinelerra/mainundo.C +++ b/cinelerra-5.1/cinelerra/mainundo.C @@ -255,6 +255,9 @@ int MainUndo::redo() // Here the master EDL loads int MainUndo::load_from_undo(FileXML *file, uint32_t load_flags) { + delete mwindow->gui->keyvalue_popup; + mwindow->gui->keyvalue_popup = 0; + if( load_flags & LOAD_SESSION ) { mwindow->gui->unlock_window(); mwindow->close_mixers(); diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 8a33473c..7d871c96 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -3473,9 +3473,10 @@ void MWindow::update_project(int load_mode) if(debug) PRINT_TRACE - if(load_mode == LOADMODE_REPLACE || - load_mode == LOADMODE_REPLACE_CONCATENATE) - { + if( load_mode == LOADMODE_REPLACE || + load_mode == LOADMODE_REPLACE_CONCATENATE ) { + delete gui->keyvalue_popup; + gui->keyvalue_popup = 0; gui->load_panes(); } diff --git a/cinelerra-5.1/cinelerra/preferencesthread.C b/cinelerra-5.1/cinelerra/preferencesthread.C index 87a90096..af64fed1 100644 --- a/cinelerra-5.1/cinelerra/preferencesthread.C +++ b/cinelerra-5.1/cinelerra/preferencesthread.C @@ -235,7 +235,9 @@ int PreferencesThread::apply_settings() mwindow->restart_status = -1; // reload, need new bcresources if( strcmp(preferences->plugin_icons, mwindow->preferences->plugin_icons) != 0 ) mwindow->restart_status = -1; - if( strcmp(preferences->lv2_path, mwindow->preferences->lv2_path) != 0 ) { + if( strcmp(preferences->lv2_path, mwindow->preferences->lv2_path) != 0 ) + reload_plugins = 1; + if( reload_plugins ) { MWindow::remove_plugin_index(); File::setenv_path("LV2_PATH", preferences->lv2_path, 1); mwindow->restart_status = -1; diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index 5b283ff6..fdd3112b 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -2095,10 +2095,8 @@ int TrackCanvas::do_keyframes(int cursor_x, if (buttonpress != 3) { if(i == AUTOMATION_FADE || i == AUTOMATION_SPEED) - synchronize_autos(0, - track, - (FloatAuto*)mwindow->session->drag_auto, - 1); + fill_ganged_autos(get_double_click(), 0, track, + (FloatAuto*)mwindow->session->drag_auto); mwindow->session->current_operation = pre_auto_operations[i]; update_drag_caption(); rerender = 1; @@ -2723,69 +2721,68 @@ int TrackCanvas::test_floatline(int center_pixel, } -void TrackCanvas::synchronize_autos(float change, - Track *skip, FloatAuto *fauto, int fill_gangs) +void TrackCanvas::fill_ganged_autos(int all, float change, Track *skip, FloatAuto *fauto) { + if( !skip->gang ) return; // Handles the special case of modifying a fadeauto // when there are ganged faders on several tracks -// (skip and fauto may be NULL if fill_gangs==-1) - - if( fill_gangs > 0 && skip->gang ) { - double position = skip->from_units(fauto->position); - int autoidx = fauto->autos->autoidx; - - for(Track *current = mwindow->edl->tracks->first; current; current = NEXT) { - if( (current->data_type == skip->data_type || get_double_click()) && - current->gang && current->record && current != skip ) { - int64_t current_position = current->to_units(position, 1); - FloatAutos *fade_autos = (FloatAutos*)current->automation->autos[autoidx]; - float auto_min = mwindow->edl->local_session->automation_mins[fade_autos->autogrouptype]; - float auto_max = mwindow->edl->local_session->automation_maxs[fade_autos->autogrouptype]; - FloatAuto *previous = 0, *next = 0; - FloatAuto *keyframe = (FloatAuto*)fade_autos->get_auto_at_position(current_position); - if( !keyframe ) { -// create keyframe on neighbouring track at the point in time given by fauto - float init_value = fade_autos->get_value(current_position, PLAY_FORWARD, previous, next); - float new_value = init_value + change; - CLAMP(new_value, auto_min, auto_max); - keyframe = (FloatAuto*)fade_autos->insert_auto(current_position); - keyframe->set_value(new_value); - } - else { + double position = skip->from_units(fauto->position); + int autoidx = fauto->autos->autoidx; + + for(Track *current = mwindow->edl->tracks->first; current; current = NEXT) { + if( (all || current->data_type == skip->data_type) && + current->gang && current->record && current != skip ) { + FloatAutos *fade_autos = (FloatAutos*)current->automation->autos[autoidx]; + float auto_min = mwindow->edl->local_session->automation_mins[fade_autos->autogrouptype]; + float auto_max = mwindow->edl->local_session->automation_maxs[fade_autos->autogrouptype]; + int64_t current_position = current->to_units(position, 1); + FloatAuto *keyframe = (FloatAuto*)fade_autos->get_auto_at_position(position); + if( keyframe ) { // keyframe exists, just change it - float new_value = keyframe->get_value() + change; - CLAMP(new_value, auto_min, auto_max); - keyframe->adjust_to_new_coordinates(current_position, new_value); -// need to (re)set the position, as the existing node could be on a "equivalent" position (within half a frame) - } - - mwindow->session->drag_auto_gang->append((Auto *)keyframe); + float value = keyframe->get_value(); + float new_value = value + change; + CLAMP(new_value, auto_min, auto_max); + keyframe->adjust_to_new_coordinates(current_position, new_value); } + else if( mwindow->edl->session->auto_keyframes ) { +// create keyframe on neighbouring track at the point in time given by fauto + FloatAuto *previous = 0, *next = 0; + float value = fade_autos->get_value(current_position, PLAY_FORWARD, previous, next); + float new_value = value + change; + CLAMP(new_value, auto_min, auto_max); + keyframe = (FloatAuto*)fade_autos->insert_auto(current_position); + keyframe->set_value(new_value); + } + else + continue; + mwindow->session->drag_auto_gang->append((Auto *)keyframe); } } - else if( !fill_gangs ) { - double position = skip->from_units(fauto->position); -// Move the gangs - for (int i = 0; i < mwindow->session->drag_auto_gang->total; i++) { - FloatAuto *keyframe = (FloatAuto *)mwindow->session->drag_auto_gang->values[i]; - int64_t keyframe_position = keyframe->autos->track->to_units(position, 1); - float new_value = keyframe->get_value() + change; - CLAMP(new_value, - mwindow->edl->local_session->automation_mins[keyframe->autos->autogrouptype], - mwindow->edl->local_session->automation_maxs[keyframe->autos->autogrouptype]); - keyframe->adjust_to_new_coordinates(keyframe_position, new_value); - } +} +void TrackCanvas::update_ganged_autos(float change, Track *skip, FloatAuto *fauto) +{ + double position = skip->from_units(fauto->position); +// Move the gangs + for (int i = 0; i < mwindow->session->drag_auto_gang->total; i++) { + FloatAuto *keyframe = (FloatAuto *)mwindow->session->drag_auto_gang->values[i]; + int64_t keyframe_position = keyframe->autos->track->to_units(position, 1); + float new_value = keyframe->get_value() + change; + CLAMP(new_value, + mwindow->edl->local_session->automation_mins[keyframe->autos->autogrouptype], + mwindow->edl->local_session->automation_maxs[keyframe->autos->autogrouptype]); + keyframe->adjust_to_new_coordinates(keyframe_position, new_value); } - else { +} + +void TrackCanvas::clear_ganged_autos() +{ // remove the gangs - for (int i = 0; i < mwindow->session->drag_auto_gang->total; i++) { - FloatAuto *keyframe = (FloatAuto *)mwindow->session->drag_auto_gang->values[i]; - keyframe->autos->remove_nonsequential( - keyframe); - } - mwindow->session->drag_auto_gang->remove_all(); + for (int i = 0; i < mwindow->session->drag_auto_gang->total; i++) { + FloatAuto *keyframe = (FloatAuto *)mwindow->session->drag_auto_gang->values[i]; + keyframe->autos->remove_nonsequential(keyframe); } + mwindow->session->drag_auto_gang->remove_all(); } @@ -3848,7 +3845,7 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y) result = 1; float change = value - old_value; current->adjust_to_new_coordinates(position, value); - synchronize_autos(change, current->autos->track, current, 0); + update_ganged_autos(change, current->autos->track, current); show_message(current, 1,", %.2f", current->get_value()); } break; @@ -3867,7 +3864,7 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y) current->set_control_in_value( value * levered_position(position - current->position, current->get_control_in_position())); - synchronize_autos(0, current->autos->track, current, 0); + update_ganged_autos(0, current->autos->track, current); show_message(current, 1,", %.2f", current->get_control_in_value()); } break; } @@ -3881,7 +3878,7 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y) current->set_control_out_value( value * levered_position(position - current->position, current->get_control_out_position())); - synchronize_autos(0, current->autos->track, current, 0); + update_ganged_autos(0, current->autos->track, current); show_message(current, 1,", %.2f", current->get_control_out_value()); } break; } @@ -4408,7 +4405,7 @@ int TrackCanvas::button_release_event() load_flags |= LOAD_EDITS; case DRAG_FADE: // delete the drag_auto_gang first and remove out of order keys - synchronize_autos(0, 0, 0, -1); + clear_ganged_autos(); case DRAG_CZOOM: case DRAG_PZOOM: case DRAG_PLAY: diff --git a/cinelerra-5.1/cinelerra/trackcanvas.h b/cinelerra-5.1/cinelerra/trackcanvas.h index bb261ad7..b42660c5 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.h +++ b/cinelerra-5.1/cinelerra/trackcanvas.h @@ -258,8 +258,10 @@ public: double zoom_units, double yscale, int autogrouptype); - void synchronize_autos(float change, Track *skip, FloatAuto *fauto, int fill_gangs); + void fill_ganged_autos(int all, float change, Track *skip, FloatAuto *fauto); + void update_ganged_autos(float change, Track *skip, FloatAuto *fauto); + void clear_ganged_autos(); void draw_brender_range(); void draw_loop_points(); -- 2.26.2