Various fixes to make audio analysis sort-of work.
[dcpomatic.git] / src / wx / film_editor.cc
index aab2a61474a83882145bd6c2b211891baa099b3d..27803fb9a7e2464778a2eae26f0fb76c811d8d7d 100644 (file)
@@ -32,7 +32,6 @@
 #include "lib/film.h"
 #include "lib/transcode_job.h"
 #include "lib/exceptions.h"
-#include "lib/ab_transcode_job.h"
 #include "lib/job_manager.h"
 #include "lib/filter.h"
 #include "lib/ratio.h"
@@ -596,8 +595,6 @@ FilmEditor::film_changed (Film::Property p)
                break;
        case Film::CONTENT:
                setup_content ();
-               setup_ratios ();
-//             setup_ratio ();
                setup_subtitle_control_sensitivity ();
                setup_show_audio_sensitivity ();
                break;
@@ -714,7 +711,7 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
                                ++i;
                                ++n;
                        }
-                       
+
                        if (i == ratios.end()) {
                                checked_set (_ratio, -1);
                        } else {
@@ -851,10 +848,6 @@ FilmEditor::set_film (shared_ptr<Film> f)
                FileChanged ("");
        }
 
-       if (_audio_dialog) {
-               _audio_dialog->set_film (_film);
-       }
-       
        film_changed (Film::NAME);
        film_changed (Film::USE_DCI_NAME);
        film_changed (Film::CONTENT);
@@ -870,18 +863,8 @@ FilmEditor::set_film (shared_ptr<Film> f)
        film_changed (Film::DCI_METADATA);
        film_changed (Film::DCP_VIDEO_FRAME_RATE);
 
-       film_content_changed (boost::shared_ptr<Content> (), ContentProperty::START);
-       film_content_changed (boost::shared_ptr<Content> (), ContentProperty::LENGTH);
-       film_content_changed (boost::shared_ptr<Content> (), VideoContentProperty::VIDEO_CROP);
-       film_content_changed (boost::shared_ptr<Content> (), VideoContentProperty::VIDEO_RATIO);
-       film_content_changed (boost::shared_ptr<Content> (), AudioContentProperty::AUDIO_GAIN);
-       film_content_changed (boost::shared_ptr<Content> (), AudioContentProperty::AUDIO_DELAY);
-       film_content_changed (boost::shared_ptr<Content> (), AudioContentProperty::AUDIO_MAPPING);
-       film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::SUBTITLE_STREAMS);
-       film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::SUBTITLE_STREAM);
-       film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::AUDIO_STREAMS);
-       film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::AUDIO_STREAM);
-       film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::FILTERS);
+       wxListEvent ev;
+       content_selection_changed (ev);
 }
 
 /** Updates the sensitivity of lots of widgets to a given value.
@@ -912,6 +895,9 @@ FilmEditor::set_things_sensitive (bool s)
        _audio_gain_calculate_button->Enable (s);
        _show_audio->Enable (s);
        _audio_delay->Enable (s);
+       _container->Enable (s);
+       _loop_content->Enable (s);
+       _loop_count->Enable (s);
 
        setup_subtitle_control_sensitivity ();
        setup_show_audio_sensitivity ();
@@ -1105,10 +1091,20 @@ FilmEditor::show_audio_clicked (wxCommandEvent &)
                _audio_dialog->Destroy ();
                _audio_dialog = 0;
        }
+
+       shared_ptr<Content> c = selected_content ();
+       if (!c) {
+               return;
+       }
+
+       shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c);
+       if (!ac) {
+               return;
+       }
        
        _audio_dialog = new AudioDialog (this);
        _audio_dialog->Show ();
-       _audio_dialog->set_film (_film);
+       _audio_dialog->set_content (ac);
 }
 
 void
@@ -1148,7 +1144,7 @@ FilmEditor::setup_content ()
        }
 
        if (selected_summary.empty () && !content.empty ()) {
-               /* Select the item of content if non was selected before */
+               /* Select the item of content if none was selected before */
                _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
        }
 }
@@ -1198,6 +1194,11 @@ FilmEditor::content_selection_changed (wxListEvent &)
 {
         setup_content_sensitivity ();
        shared_ptr<Content> s = selected_content ();
+       
+       if (_audio_dialog && s && dynamic_pointer_cast<AudioContent> (s)) {
+               _audio_dialog->set_content (dynamic_pointer_cast<AudioContent> (s));
+       }
+       
        film_content_changed (s, ContentProperty::START);
        film_content_changed (s, ContentProperty::LENGTH);
        film_content_changed (s, VideoContentProperty::VIDEO_CROP);
@@ -1223,6 +1224,7 @@ FilmEditor::setup_content_sensitivity ()
        _video_panel->Enable    (selection && dynamic_pointer_cast<VideoContent>  (selection) && _generally_sensitive);
        _audio_panel->Enable    (selection && dynamic_pointer_cast<AudioContent>  (selection) && _generally_sensitive);
        _subtitle_panel->Enable (selection && dynamic_pointer_cast<FFmpegContent> (selection) && _generally_sensitive);
+       _timing_panel->Enable   (selection && _generally_sensitive);
 }
 
 shared_ptr<Content>