X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fapatchgui.C;h=f46e4ab7390d6426e0f7d7c007e373abd6292784;hb=ae44cc4a24c9e04ee5e3b38baf6ce529832cfb39;hp=8243fc255f53c6ae387de131b6e4bafe304c1073;hpb=2ba7e9962ea989863e152373e96a09b00a0b4eb8;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/apatchgui.C b/cinelerra-5.1/cinelerra/apatchgui.C index 8243fc25..f46e4ab7 100644 --- a/cinelerra-5.1/cinelerra/apatchgui.C +++ b/cinelerra-5.1/cinelerra/apatchgui.C @@ -30,8 +30,10 @@ #include "gwindowgui.h" #include "intauto.h" #include "intautos.h" +#include "keys.h" #include "language.h" #include "localsession.h" +#include "mainsession.h" #include "mainundo.h" #include "mwindow.h" #include "mwindowgui.h" @@ -40,20 +42,11 @@ #include "patchbay.h" #include "theme.h" #include "trackcanvas.h" +#include "zwindow.h" - - - -APatchGUI::APatchGUI(MWindow *mwindow, - PatchBay *patchbay, - ATrack *track, - int x, - int y) - : PatchGUI(mwindow, - patchbay, - track, - x, - y) +APatchGUI::APatchGUI(MWindow *mwindow, PatchBay *patchbay, + ATrack *track, int x, int y) + : PatchGUI(mwindow, patchbay, track, x, y) { data_type = TRACK_AUDIO; this->atrack = track; @@ -64,9 +57,9 @@ APatchGUI::APatchGUI(MWindow *mwindow, APatchGUI::~APatchGUI() { - if(fade) delete fade; - if(meter) delete meter; - if(pan) delete pan; + if( fade ) delete fade; + if( meter ) delete meter; + if( pan ) delete pan; } void APatchGUI::create_objects() @@ -78,23 +71,20 @@ int APatchGUI::reposition(int x, int y) { int y1 = PatchGUI::reposition(x, y); - if(fade) fade->reposition_window(fade->get_x(), - y1 + y); + if( fade ) + fade->reposition_window(fade->get_x(), y1+y); y1 += mwindow->theme->fade_h; - - if(meter) meter->reposition_window(meter->get_x(), - y1 + y, - -1, - meter->get_w()); + if( meter ) + meter->reposition_window(meter->get_x(), y1+y, -1, meter->get_w()); y1 += mwindow->theme->meter_h; - - if(pan) pan->reposition_window(pan->get_x(), - y1 + y); - - if(nudge) nudge->reposition_window(nudge->get_x(), - y1 + y); - + if( mix ) + mix->reposition_window(mix->get_x(), y1+y); + if( pan ) + pan->reposition_window(pan->get_x(), y1+y); + if( nudge ) + nudge->reposition_window(nudge->get_x(), y1+y); y1 += mwindow->theme->pan_h; + return y1; } @@ -104,182 +94,134 @@ int APatchGUI::update(int x, int y) int x1 = 0; int y1 = PatchGUI::update(x, y); - if(fade) - { - if(h - y1 < mwindow->theme->fade_h) - { + int y2 = y1 + mwindow->theme->fade_h; + if( fade ) { + if( h < y2 ) { delete fade; fade = 0; } - else - { + else { FloatAuto *previous = 0, *next = 0; double unit_position = mwindow->edl->local_session->get_selectionstart(1); unit_position = mwindow->edl->align_to_frame(unit_position, 0); unit_position = atrack->to_units(unit_position, 0); FloatAutos *ptr = (FloatAutos*)atrack->automation->autos[AUTOMATION_FADE]; - float value = ptr->get_value( - (long)unit_position, - PLAY_FORWARD, - previous, - next); - fade->update(fade->get_w(), - value, + float value = ptr->get_value((long)unit_position, PLAY_FORWARD, previous, next); + fade->update(fade->get_w(), value, mwindow->edl->local_session->automation_mins[AUTOGROUPTYPE_AUDIO_FADE], mwindow->edl->local_session->automation_maxs[AUTOGROUPTYPE_AUDIO_FADE]); } } - else - if(h - y1 >= mwindow->theme->fade_h) - { - patchbay->add_subwindow(fade = new AFadePatch(mwindow, - this, - x1 + x, - y1 + y, - patchbay->get_w() - 10)); + else if( h >= y2 ) { + float v = mwindow->get_float_auto(this, AUTOMATION_FADE)->get_value(); + patchbay->add_subwindow(fade = new AFadePatch(this, x1+x, y1+y, + patchbay->get_w() - 10, v)); } - y1 += mwindow->theme->fade_h; + y1 = y2; - if(meter) - { - if(h - y1 < mwindow->theme->meter_h) - { - delete meter; - meter = 0; + y2 = y1 + mwindow->theme->meter_h; + if( meter ) { + if( h < y2 ) { + delete meter; meter = 0; } } - else - if(h - y1 >= mwindow->theme->meter_h) - { - patchbay->add_subwindow(meter = new AMeterPatch(mwindow, - this, - x1 + x, - y1 + y)); + else if( h >= y2 ) { + patchbay->add_subwindow(meter = new AMeterPatch(mwindow, this, x1+x, y1+y)); } - y1 += mwindow->theme->meter_h; - x1 += 10; - - if(pan) - { - if(h - y1 < mwindow->theme->pan_h) - { - delete pan; - pan = 0; - delete nudge; - nudge = 0; + y1 = y2; + + y2 = y1 + mwindow->theme->pan_h; + if( pan ) { + if( h < y2 ) { + delete mix; mix = 0; + delete pan; pan = 0; + delete nudge; nudge = 0; } - else - { - if(pan->get_total_values() != mwindow->edl->session->audio_channels) - { + else { + if( mwindow->session->selected_zwindow >= 0 ) { + int v = mwindow->mixer_track_active(track); + mix->update(v); + } + if( pan->get_total_values() != mwindow->edl->session->audio_channels ) { pan->change_channels(mwindow->edl->session->audio_channels, mwindow->edl->session->achannel_positions); } - else - { + else { int handle_x, handle_y; PanAuto *previous = 0, *next = 0; double unit_position = mwindow->edl->local_session->get_selectionstart(1); unit_position = mwindow->edl->align_to_frame(unit_position, 0); unit_position = atrack->to_units(unit_position, 0); PanAutos *ptr = (PanAutos*)atrack->automation->autos[AUTOMATION_PAN]; - ptr->get_handle(handle_x, - handle_y, - (long)unit_position, - PLAY_FORWARD, - previous, - next); + ptr->get_handle(handle_x, handle_y, (long)unit_position, + PLAY_FORWARD, previous, next); pan->update(handle_x, handle_y); } nudge->update(); } } - else - if(h - y1 >= mwindow->theme->pan_h) - { - patchbay->add_subwindow(pan = new APanPatch(mwindow, - this, - x1 + x, - y1 + y)); - x1 += pan->get_w() + 10; - patchbay->add_subwindow(nudge = new NudgePatch(mwindow, - this, - x1 + x, - y1 + y, - patchbay->get_w() - x1 - 10)); + else if( h >= y2 ) { + patchbay->add_subwindow(mix = new AMixPatch(mwindow, this, x1+x, y1+y+5)); + x1 += mix->get_w() + 10; + patchbay->add_subwindow(pan = new APanPatch(mwindow, this, x1+x, y1+y)); + x1 += pan->get_w() + 20; + patchbay->add_subwindow(nudge = new NudgePatch(mwindow, this, x1+x, y1+y, + patchbay->get_w() - x1-x - 10)); } - y1 += mwindow->theme->pan_h; + y1 = y2; return y1; } -void APatchGUI::synchronize_fade(float value_change) -{ - if(fade && !change_source) - { - fade->update(fade->get_value() + value_change); - fade->update_edl(); - } -} - - - -AFadePatch::AFadePatch(MWindow *mwindow, APatchGUI *patch, int x, int y, int w) - : BC_FSlider(x, y, 0, w, w, - mwindow->edl->local_session->automation_mins[AUTOGROUPTYPE_AUDIO_FADE], - mwindow->edl->local_session->automation_maxs[AUTOGROUPTYPE_AUDIO_FADE], - mwindow->get_float_auto(patch, AUTOMATION_FADE)->get_value()) +void APatchGUI::update_faders(float v) { - this->mwindow = mwindow; - this->patch = patch; -} + if( fade ) + fade->update(v); -float AFadePatch::update_edl() -{ - FloatAuto *current; + change_source = 1; double position = mwindow->edl->local_session->get_selectionstart(1); - Autos *fade_autos = patch->atrack->automation->autos[AUTOMATION_FADE]; + Autos *fade_autos = atrack->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); + if( track->gang && track->record ) + patchbay->synchronize_faders(change, TRACK_AUDIO, track); + mwindow->undo->update_undo_after(_("fade"), LOAD_AUTOMATION); + change_source = 0; - float result = get_value() - current->get_value(); - current->set_value(this->get_value()); + mwindow->sync_parameters(CHANGE_PARAMS); - mwindow->undo->update_undo_after(_("fade"), LOAD_AUTOMATION); + if( mwindow->edl->session->auto_conf->autos[AUTOMATION_FADE] ) { + mwindow->gui->draw_overlays(1); + } +} - return result; +AFadePatch::AFadePatch(APatchGUI *patch, int x, int y, int w, float v) + : BC_FSlider(x, y, 0, w, w, + patch->mwindow->edl->local_session->automation_mins[AUTOGROUPTYPE_AUDIO_FADE], + patch->mwindow->edl->local_session->automation_maxs[AUTOGROUPTYPE_AUDIO_FADE], + v) +{ + this->patch = patch; } int AFadePatch::handle_event() { - if(shift_down()) - { + if( shift_down() ) { update(0.0); 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_AUDIO, patch->track); - patch->change_source = 0; - - mwindow->sync_parameters(CHANGE_PARAMS); - - if(mwindow->edl->session->auto_conf->autos[AUTOMATION_FADE]) - { - mwindow->gui->draw_overlays(1); - } + patch->update_faders(get_value()); return 1; } AKeyFadePatch::AKeyFadePatch(MWindow *mwindow, APatchGUI *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; @@ -287,33 +229,65 @@ AKeyFadePatch::AKeyFadePatch(MWindow *mwindow, APatchGUI *patch, int x, int y) void AKeyFadePatch::create_objects() { - akey_fade_value = new AKeyFadeValue(this); - add_subwindow(akey_fade_value); - akey_fade_value->activate(); + int x = 0, y = 0; + float v = mwindow->get_float_auto(patch, AUTOMATION_FADE)->get_value(); + add_subwindow(akey_fade_text = new AKeyFadeText(this, x, y, 64, v)); + x += akey_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(akey_fade_slider = new AKeyFadeSlider(this, x, y, w1, v)); + x += akey_fade_slider->get_w(); + add_subwindow(akey_fade_ok = new AKeyFadeOK(this, x, y, lok_images)); + activate(); show_window(); } -AKeyFadeValue::AKeyFadeValue(AKeyFadePatch *akey_fade_patch) - : AFadePatch(akey_fade_patch->mwindow, akey_fade_patch->patch, - 0,0, akey_fade_patch->get_w()) +void AKeyFadePatch::update(float v) +{ + akey_fade_text->update(v); + akey_fade_slider->update(v); + patch->update_faders(v); +} + +AKeyFadeOK::AKeyFadeOK(AKeyFadePatch *akey_fade_patch, int x, int y, VFrame **images) + : BC_Button(x, y, images) { this->akey_fade_patch = akey_fade_patch; } -int AKeyFadeValue::button_release_event() +int AKeyFadeOK::handle_event() { - AFadePatch::button_release_event(); - return 0; + MWindowGUI *mgui = akey_fade_patch->mwindow->gui; + delete mgui->keyvalue_popup; + mgui->keyvalue_popup = 0; + return 1; } -int AKeyFadeValue::handle_event() +AKeyFadeText::AKeyFadeText(AKeyFadePatch *akey_fade_patch, int x, int y, int w, float v) + : BC_TextBox(x, y, w, 1, v, 1, MEDIUMFONT, 2) { - APatchGUI *patch = akey_fade_patch->patch; - int ret = AFadePatch::handle_event(); - AFadePatch *fade = patch->fade; - if( fade ) - fade->update(get_value()); - return ret; + this->akey_fade_patch = akey_fade_patch; +} + +int AKeyFadeText::handle_event() +{ + float v = atof(get_text()); + akey_fade_patch->update(v); + return get_keypress() != RETURN ? 1 : + akey_fade_patch->akey_fade_ok->handle_event(); +} + +AKeyFadeSlider::AKeyFadeSlider(AKeyFadePatch *akey_fade_patch, int x, int y, int w, float v) + : AFadePatch(akey_fade_patch->patch, x, y, w, v) +{ + this->akey_fade_patch = akey_fade_patch; +} + +int AKeyFadeSlider::handle_event() +{ + float v = get_value(); + akey_fade_patch->update(v); + return 1; } @@ -338,7 +312,7 @@ int APanPatch::handle_event() int need_undo = !pan_autos->auto_exists_for_editing(position); mwindow->undo->update_undo_before(_("pan"), need_undo ? 0 : this); - + current = (PanAuto*)pan_autos->get_auto_for_editing(position); current->handle_x = get_stick_x(); @@ -349,8 +323,7 @@ int APanPatch::handle_event() mwindow->sync_parameters(CHANGE_PARAMS); - if(need_undo && mwindow->edl->session->auto_conf->autos[AUTOMATION_PAN]) - { + if( need_undo && mwindow->edl->session->auto_conf->autos[AUTOMATION_PAN] ) { mwindow->gui->draw_overlays(1); } return 1; @@ -361,12 +334,6 @@ AKeyPanPatch::AKeyPanPatch(MWindow *mwindow, APatchGUI *patch) { } -int AKeyPanPatch::button_release_event() -{ - APanPatch::button_release_event(); - return 0; -} - int AKeyPanPatch::handle_event() { int ret = APanPatch::handle_event(); @@ -378,15 +345,9 @@ int AKeyPanPatch::handle_event() AMeterPatch::AMeterPatch(MWindow *mwindow, APatchGUI *patch, int x, int y) - : BC_Meter(x, - y, - METER_HORIZ, - patch->patchbay->get_w() - 10, - mwindow->edl->session->min_meter_db, - mwindow->edl->session->max_meter_db, - mwindow->edl->session->meter_format, - 0, - -1) + : BC_Meter(x, y, METER_HORIZ, patch->patchbay->get_w() - 10, + mwindow->edl->session->min_meter_db, mwindow->edl->session->max_meter_db, + mwindow->edl->session->meter_format, 0, -1) { this->mwindow = mwindow; this->patch = patch; @@ -396,8 +357,7 @@ AMeterPatch::AMeterPatch(MWindow *mwindow, APatchGUI *patch, int x, int y) int AMeterPatch::button_press_event() { - if(cursor_inside() && is_event_win() && get_buttonpress() == 1) - { + if( cursor_inside() && is_event_win() && get_buttonpress() == 1 ) { mwindow->reset_meters(); return 1; } @@ -405,3 +365,13 @@ int AMeterPatch::button_press_event() return 0; } +AMixPatch::AMixPatch(MWindow *mwindow, APatchGUI *patch, int x, int y) + : MixPatch(mwindow, patch, x, y) +{ + set_tooltip(_("Mixer")); +} + +AMixPatch::~AMixPatch() +{ +} +