From 3c14c6f57600b3e7bd0a84ee976b3fd333746477 Mon Sep 17 00:00:00 2001 From: Pierre Dumuid Date: Mon, 25 Sep 2006 15:43:35 +0000 Subject: [PATCH] r901: Automation::fit_autos() now works and automation_{min,max} variable removed --- cinelerra/automation.C | 18 +++++++++++++-- cinelerra/automation.h | 4 +++- cinelerra/automation.inc | 1 + cinelerra/editpanel.C | 11 ++++++--- cinelerra/localsession.C | 23 ++++--------------- cinelerra/localsession.h | 2 -- cinelerra/mwindow.h | 2 +- cinelerra/mwindowmove.C | 59 ++++++++++++++++++++++++++++++++++++------------ cinelerra/tracks.C | 6 +++-- cinelerra/tracks.h | 3 ++- doc/cinelerra.texi | 9 +++++--- 11 files changed, 90 insertions(+), 48 deletions(-) diff --git a/cinelerra/automation.C b/cinelerra/automation.C index 2a3c46f8..8255e04d 100644 --- a/cinelerra/automation.C +++ b/cinelerra/automation.C @@ -12,6 +12,18 @@ #include "transportque.inc" +int Automation::autogrouptypes_fixedrange[] = +{ + 0, + 0, + 0, + 0, + 0, + 1 +}; + + + Automation::Automation(EDL *edl, Track *track) { this->edl = edl; @@ -314,13 +326,15 @@ void Automation::get_extents(float *min, float *max, int *coords_undefined, int64_t unit_start, - int64_t unit_end) + int64_t unit_end, + int autogrouptype) { for(int i = 0; i < AUTOMATION_TOTAL; i++) { if(autos[i] && edl->session->auto_conf->autos[i]) { - autos[i]->get_extents(min, max, coords_undefined, unit_start, unit_end); + if (autos[i]->autogrouptype == autogrouptype) + autos[i]->get_extents(min, max, coords_undefined, unit_start, unit_end); } } } diff --git a/cinelerra/automation.h b/cinelerra/automation.h index 194e7fe8..983670a4 100644 --- a/cinelerra/automation.h +++ b/cinelerra/automation.h @@ -16,6 +16,7 @@ class Automation { public: + static int autogrouptypes_fixedrange[]; Automation(EDL *edl, Track *track); virtual ~Automation(); @@ -75,7 +76,8 @@ public: float *max, int *coords_undefined, int64_t unit_start, - int64_t unit_end); + int64_t unit_end, + int autogrouptype); diff --git a/cinelerra/automation.inc b/cinelerra/automation.inc index d3e3afa8..8a2dbb9a 100644 --- a/cinelerra/automation.inc +++ b/cinelerra/automation.inc @@ -32,6 +32,7 @@ enum // These must match the following arrays: // xml_autogrouptypes_* in localsession.C +// autogrouptypes_* in automation_statics.h enum { AUTOGROUPTYPE_AUDIO_FADE, diff --git a/cinelerra/editpanel.C b/cinelerra/editpanel.C index 4cb5f9f1..aa176627 100644 --- a/cinelerra/editpanel.C +++ b/cinelerra/editpanel.C @@ -974,16 +974,21 @@ EditFitAutos::~EditFitAutos() } int EditFitAutos::keypress_event() { - if(alt_down() && get_keypress() == 'f') + if(!ctrl_down() && alt_down() && get_keypress() == 'f') { - handle_event(); + mwindow->fit_autos(0); + return 1; + } + if(ctrl_down() && alt_down() && get_keypress() == 'f') + { + mwindow->fit_autos(1); return 1; } return 0; } int EditFitAutos::handle_event() { - mwindow->fit_autos(); + mwindow->fit_autos(0); return 1; } diff --git a/cinelerra/localsession.C b/cinelerra/localsession.C index 884edfd2..ca9fda50 100644 --- a/cinelerra/localsession.C +++ b/cinelerra/localsession.C @@ -1,4 +1,4 @@ -#include "automation.inc" +#include "automation.h" #include "clip.h" #include "bchash.h" #include "edl.h" @@ -26,15 +26,6 @@ static char *xml_autogrouptypes_titlesmin[] = "AUTOGROUPTYPE_INT255_MIN" }; -static int xml_autogrouptypes_save[] = -{ - 1, - 1, - 1, - 1, - 1, - 0 -}; LocalSession::LocalSession(EDL *edl) { @@ -74,8 +65,6 @@ LocalSession::LocalSession(EDL *edl) automation_mins[AUTOGROUPTYPE_INT255] = 0; automation_maxs[AUTOGROUPTYPE_INT255] = 255; - automation_min = -10; - automation_max = 10; zoombar_showautotype = AUTOGROUPTYPE_AUDIO_FADE; red = green = blue = 0; } @@ -109,8 +98,6 @@ void LocalSession::copy_from(LocalSession *that) automation_mins[i] = that->automation_mins[i]; automation_maxs[i] = that->automation_maxs[i]; } - automation_min = that->automation_min; - automation_max = that->automation_max; blue = that->blue; } @@ -148,7 +135,7 @@ void LocalSession::save_xml(FileXML *file, double start) file->tag.set_property("BLUE", blue); for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) { - if (xml_autogrouptypes_save[i]) { + if (!Automation::autogrouptypes_fixedrange[i]) { file->tag.set_property(xml_autogrouptypes_titlesmin[i],automation_mins[i]); file->tag.set_property(xml_autogrouptypes_titlesmax[i],automation_maxs[i]); } @@ -199,7 +186,7 @@ void LocalSession::load_xml(FileXML *file, unsigned long load_flags) blue = file->tag.get_property("BLUE", blue); for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) { - if (xml_autogrouptypes_save[i]) { + if (!Automation::autogrouptypes_fixedrange[i]) { automation_mins[i] = file->tag.get_property(xml_autogrouptypes_titlesmin[i],automation_mins[i]); automation_maxs[i] = file->tag.get_property(xml_autogrouptypes_titlesmax[i],automation_maxs[i]); } @@ -246,7 +233,7 @@ int LocalSession::load_defaults(BC_Hash *defaults) blue = defaults->get("BLUE", 0.0); for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) { - if (xml_autogrouptypes_save[i]) { + if (!Automation::autogrouptypes_fixedrange[i]) { automation_mins[i] = defaults->get(xml_autogrouptypes_titlesmin[i], automation_mins[i]); automation_maxs[i] = defaults->get(xml_autogrouptypes_titlesmax[i], automation_maxs[i]); } @@ -272,7 +259,7 @@ int LocalSession::save_defaults(BC_Hash *defaults) defaults->update("BLUE", blue); for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) { - if (xml_autogrouptypes_save[i]) { + if (!Automation::autogrouptypes_fixedrange[i]) { defaults->update(xml_autogrouptypes_titlesmin[i], automation_mins[i]); defaults->update(xml_autogrouptypes_titlesmax[i], automation_maxs[i]); } diff --git a/cinelerra/localsession.h b/cinelerra/localsession.h index acece97f..54abe398 100644 --- a/cinelerra/localsession.h +++ b/cinelerra/localsession.h @@ -77,8 +77,6 @@ public: // Vertical automation scale float automation_mins[6]; float automation_maxs[6]; - float automation_min; - float automation_max; int zoombar_showautotype; // Eye dropper diff --git a/cinelerra/mwindow.h b/cinelerra/mwindow.h index 93e369df..c9b7d3eb 100644 --- a/cinelerra/mwindow.h +++ b/cinelerra/mwindow.h @@ -132,7 +132,7 @@ public: // Fit selected time to horizontal display range void fit_selection(); // Fit selected autos to the vertical display range - void fit_autos(); + void fit_autos(int doall); void change_currentautorange(int autogrouptype, int increment, int changemax); void expand_autos(int changeall, int domin, int domax); void shrink_autos(int changeall, int domin, int domax); diff --git a/cinelerra/mwindowmove.C b/cinelerra/mwindowmove.C index 48cdf7fc..a3afc1bd 100644 --- a/cinelerra/mwindowmove.C +++ b/cinelerra/mwindowmove.C @@ -1,3 +1,4 @@ +#include "automation.h" #include "clip.h" #include "cplayback.h" #include "cwindow.h" @@ -157,7 +158,7 @@ void MWindow::fit_selection() } -void MWindow::fit_autos() +void MWindow::fit_autos(int doall) { float min = 0, max = 0; double start, end; @@ -176,23 +177,51 @@ void MWindow::fit_autos() end = edl->local_session->get_selectionend(1); } -// Adjust min and max - edl->tracks->get_automation_extents(&min, &max, start, end); -//printf("MWindow::fit_autos %f %f\n", min, max); + int forstart = edl->local_session->zoombar_showautotype; + int forend = edl->local_session->zoombar_showautotype + 1; + + if (doall) { + forstart = 0; + forstart = AUTOGROUPTYPE_COUNT; + } -// Pad - float range = max - min; -// No automation visible - if(range < 0.001) + for (int i = forstart; i < forend; i++) { - min -= 1; - max += 1; +// Adjust min and max + edl->tracks->get_automation_extents(&min, &max, start, end, i); +//printf("MWindow::fit_autos %d %f %f results in ", i, min, max); + + float range = max - min; + switch (i) + { + case AUTOGROUPTYPE_AUDIO_FADE: + case AUTOGROUPTYPE_VIDEO_FADE: + if (range < 0.1) { + min = MIN(min, edl->local_session->automation_mins[i]); + max = MAX(max, edl->local_session->automation_maxs[i]); + } + break; + case AUTOGROUPTYPE_ZOOM: + if (range < 0.001) { + min = floor(min*50)/100; + max = floor(max*200)/100; + } + break; + case AUTOGROUPTYPE_X: + case AUTOGROUPTYPE_Y: + if (range < 5) { + min = floor((min+max)/2) - 50; + max = floor((min+max)/2) + 50; + } + break; + } +//printf("%f %f\n", min, max); + if (!Automation::autogrouptypes_fixedrange[i]) + { + edl->local_session->automation_mins[i] = min; + edl->local_session->automation_maxs[i] = max; + } } - float pad = range * 0.33; - min -= pad; - max += pad; - edl->local_session->automation_min = min; - edl->local_session->automation_max = max; // Show range in zoombar gui->zoombar->update(); diff --git a/cinelerra/tracks.C b/cinelerra/tracks.C index 53aa2aa6..ee54639d 100644 --- a/cinelerra/tracks.C +++ b/cinelerra/tracks.C @@ -116,7 +116,8 @@ void Tracks::get_affected_edits(ArrayList *drag_edits, double position, T void Tracks::get_automation_extents(float *min, float *max, double start, - double end) + double end, + int autogrouptype) { *min = 0; *max = 0; @@ -129,7 +130,8 @@ void Tracks::get_automation_extents(float *min, max, &coords_undefined, current->to_units(start, 1), - current->to_units(end, 1)); + current->to_units(end, 1), + autogrouptype); } } } diff --git a/cinelerra/tracks.h b/cinelerra/tracks.h index bf6c6022..876140b2 100644 --- a/cinelerra/tracks.h +++ b/cinelerra/tracks.h @@ -44,7 +44,8 @@ public: void get_automation_extents(float *min, float *max, double start, - double end); + double end, + int autogrouptype); void equivalent_output(Tracks *tracks, double *result); diff --git a/doc/cinelerra.texi b/doc/cinelerra.texi index e6cc7297..3fe2ce78 100644 --- a/doc/cinelerra.texi +++ b/doc/cinelerra.texi @@ -8899,12 +8899,15 @@ Right arrow Move right* Left arrow Move left* Up arrow Zoom out* Down arrow Zoom in* -Ctrl Up Expand waveform amplitude -Ctrl Dn Shrink waveform amplitude +Ctrl Up Expand current curve amplitude +Ctrl Dn Shrink current curve amplitude +Ctrl Alt Up Expand all curve amplitude +Ctrl Alt Dn Shrink all curve amplitude Alt Up Expand curve amplitude Alt Dn Shrink curve amplitude f Fit time displayed to selection -Alt f Fit curve amplitude to highlighted section of curves +Alt f Fit current curve amplitude to highlighted section of curves +Ctrl Alt f Fit all curve amplitudes to highlighted section of curves Alt Left Move left one edit Alt Right Move right one edit Page Up Move up* -- 2.11.4.GIT