X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fvpatchgui.C;h=5fa6eb94355e40854b483fca6637c6221de9f0ae;hp=1095238feef887aa8b5f68ed09e8df320577986e;hb=702161ddaf384a773831f1643fca0a54133625b2;hpb=0f8dc862440439b96c65bed178f2457f6f1cc079 diff --git a/cinelerra-5.1/cinelerra/vpatchgui.C b/cinelerra-5.1/cinelerra/vpatchgui.C index 1095238f..5fa6eb94 100644 --- a/cinelerra-5.1/cinelerra/vpatchgui.C +++ b/cinelerra-5.1/cinelerra/vpatchgui.C @@ -28,6 +28,7 @@ #include "gwindowgui.h" #include "intauto.h" #include "intautos.h" +#include "keys.h" #include "language.h" #include "localsession.h" #include "mainsession.h" @@ -101,8 +102,9 @@ int VPatchGUI::update(int x, int y) } } else if( h >= y2 ) { - patchbay->add_subwindow(fade = new VFadePatch(mwindow, this, x1+x, y1+y, - patchbay->get_w() - 10)); + int64_t v = mwindow->get_float_auto(this, AUTOMATION_FADE)->get_value(); + patchbay->add_subwindow(fade = new VFadePatch(this, x1+x, y1+y, + patchbay->get_w() - 10, v)); } y1 = y2; @@ -136,43 +138,40 @@ int VPatchGUI::update(int x, int y) return y1; } - -void VPatchGUI::synchronize_fade(float value_change) -{ - if( fade && !change_source ) { - fade->update(Units::to_int64(fade->get_value() + value_change)); - fade->update_edl(); - } -} - - -VFadePatch::VFadePatch(MWindow *mwindow, VPatchGUI *patch, int x, int y, int w) +VFadePatch::VFadePatch(VPatchGUI *patch, int x, int y, int w, int64_t v) : BC_ISlider(x, y, 0, w, w, - mwindow->edl->local_session->automation_mins[AUTOGROUPTYPE_VIDEO_FADE], - mwindow->edl->local_session->automation_maxs[AUTOGROUPTYPE_VIDEO_FADE], - (int64_t)mwindow->get_float_auto(patch,AUTOMATION_FADE)->get_value()) + patch->mwindow->edl->local_session->automation_mins[AUTOGROUPTYPE_VIDEO_FADE], + patch->mwindow->edl->local_session->automation_maxs[AUTOGROUPTYPE_VIDEO_FADE], + v) { - this->mwindow = mwindow; this->patch = patch; } -float VFadePatch::update_edl() +void VPatchGUI::update_faders(float v) { - FloatAuto *current; + if( fade ) + fade->update(v); + + change_source = 1; double position = mwindow->edl->local_session->get_selectionstart(1); - Autos *fade_autos = patch->vtrack->automation->autos[AUTOMATION_FADE]; + Autos *fade_autos = vtrack->automation->autos[AUTOMATION_FADE]; int need_undo = !fade_autos->auto_exists_for_editing(position); mwindow->undo->update_undo_before(_("fade"), need_undo ? 0 : this); + FloatAuto *current = (FloatAuto*)fade_autos->get_auto_for_editing(position); + float change = v - current->get_value(); + current->set_value(v); - current = (FloatAuto*)fade_autos->get_auto_for_editing(position); - - float result = get_value() - current->get_value(); - current->set_value(get_value()); - + if( track->gang && track->record ) + patchbay->synchronize_faders(change, TRACK_AUDIO, track); mwindow->undo->update_undo_after(_("fade"), LOAD_AUTOMATION); + change_source = 0; + + mwindow->sync_parameters(CHANGE_PARAMS); - return result; + if( mwindow->edl->session->auto_conf->autos[AUTOMATION_FADE] ) { + mwindow->gui->draw_overlays(1); + } } int VFadePatch::handle_event() @@ -181,31 +180,12 @@ int VFadePatch::handle_event() update(100); set_tooltip(get_caption()); } - - patch->change_source = 1; - - float change = update_edl(); - - if( patch->track->gang && patch->track->record ) - patch->patchbay->synchronize_faders(change, TRACK_VIDEO, patch->track); - - patch->change_source = 0; - - - mwindow->gui->unlock_window(); - mwindow->restart_brender(); - mwindow->sync_parameters(CHANGE_PARAMS); - mwindow->gui->lock_window("VFadePatch::handle_event"); - if( mwindow->edl->session->auto_conf->autos[AUTOMATION_FADE] ) { - mwindow->gui->draw_overlays(1); - } + patch->update_faders(get_value()); return 1; } - VKeyFadePatch::VKeyFadePatch(MWindow *mwindow, VPatchGUI *patch, int x, int y) - : BC_SubWindow(x,y, patch->patchbay->get_w(),20, - GWindowGUI::auto_colors[AUTOMATION_FADE]) + : BC_SubWindow(x,y, 200,20, GWindowGUI::auto_colors[AUTOMATION_FADE]) { this->mwindow = mwindow; this->patch = patch; @@ -213,33 +193,66 @@ VKeyFadePatch::VKeyFadePatch(MWindow *mwindow, VPatchGUI *patch, int x, int y) void VKeyFadePatch::create_objects() { - vkey_fade_value = new VKeyFadeValue(this); - add_subwindow(vkey_fade_value); - vkey_fade_value->activate(); + int x = 0, y = 0; + int64_t v = mwindow->get_float_auto(patch, AUTOMATION_FADE)->get_value(); + add_subwindow(vkey_fade_text = new VKeyFadeText(this, x, y, 64, v)); + x += vkey_fade_text->get_w(); + VFrame **lok_images = mwindow->theme->get_image_set("lok"); + int w1 = get_w() - x - lok_images[0]->get_w(); + add_subwindow(vkey_fade_slider = new VKeyFadeSlider(this, x, y, w1, v)); + x += vkey_fade_slider->get_w(); + add_subwindow(vkey_fade_ok = new VKeyFadeOK(this, x, y, lok_images)); + activate(); show_window(); } -VKeyFadeValue::VKeyFadeValue(VKeyFadePatch *vkey_fade_patch) - : VFadePatch(vkey_fade_patch->mwindow, vkey_fade_patch->patch, - 0,0, vkey_fade_patch->get_w()) +void VKeyFadePatch::update(int64_t v) +{ + vkey_fade_text->update(v); + vkey_fade_slider->update(v); + patch->update_faders(v); +} + +VKeyFadeOK::VKeyFadeOK(VKeyFadePatch *vkey_fade_patch, int x, int y, VFrame **images) + : BC_Button(x, y, images) { this->vkey_fade_patch = vkey_fade_patch; } -int VKeyFadeValue::button_release_event() +int VKeyFadeOK::handle_event() { - VFadePatch::button_release_event(); - return 0; + MWindowGUI *mgui = vkey_fade_patch->mwindow->gui; + delete mgui->keyvalue_popup; + mgui->keyvalue_popup = 0; + return 1; } -int VKeyFadeValue::handle_event() +VKeyFadeText::VKeyFadeText(VKeyFadePatch *vkey_fade_patch, int x, int y, int w, int64_t v) + : BC_TextBox(x, y, w, 1, v, 1, MEDIUMFONT) { - VPatchGUI *patch = vkey_fade_patch->patch; - int ret = VFadePatch::handle_event(); - VFadePatch *fade = patch->fade; - if( fade ) - fade->update(get_value()); - return ret; + this->vkey_fade_patch = vkey_fade_patch; +} + +int VKeyFadeText::handle_event() +{ + int64_t v = atoi(get_text()); + vkey_fade_patch->update(v); + return get_keypress() != RETURN ? 1 : + vkey_fade_patch->vkey_fade_ok->handle_event(); +} + +VKeyFadeSlider::VKeyFadeSlider(VKeyFadePatch *vkey_fade_patch, + int x, int y, int w, int64_t v) + : VFadePatch(vkey_fade_patch->patch, x,y, w, v) +{ + this->vkey_fade_patch = vkey_fade_patch; +} + +int VKeyFadeSlider::handle_event() +{ + int64_t v = get_value(); + vkey_fade_patch->update(v); + return 1; } @@ -451,12 +464,6 @@ VKeyModePatch::VKeyModePatch(MWindow *mwindow, VPatchGUI *patch) { } -int VKeyModePatch::button_release_event() -{ - VModePatch::button_release_event(); - return 0; -} - int VKeyModePatch::handle_event() { int ret = VModePatch::handle_event();