Separate audio panel out.
[dcpomatic.git] / src / wx / film_editor.cc
index 83e8c619fddbd92d7eadbb16644c00ac8e7712fe..94aea9b1a4512bfdcf6e079b3ae76ae6a4687585 100644 (file)
 #include "filter_dialog.h"
 #include "wx_util.h"
 #include "film_editor.h"
-#include "gain_calculator_dialog.h"
 #include "dci_metadata_dialog.h"
-#include "audio_dialog.h"
-#include "still_image_content_dialog.h"
 #include "timeline_dialog.h"
-#include "audio_mapping_view.h"
+#include "timing_panel.h"
+#include "subtitle_panel.h"
+#include "audio_panel.h"
 
 using std::string;
 using std::cout;
@@ -69,8 +68,8 @@ using boost::lexical_cast;
 /** @param f Film to edit */
 FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
        : wxPanel (parent)
+       , _menu (f, this)
        , _generally_sensitive (true)
-       , _audio_dialog (0)
        , _timeline_dialog (0)
 {
        wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
@@ -211,6 +210,7 @@ FilmEditor::connect_to_widgets ()
        _ratio->Connect                  (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::ratio_changed), 0, this);
        _content->Connect                (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED,   wxListEventHandler    (FilmEditor::content_selection_changed), 0, this);
        _content->Connect                (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler    (FilmEditor::content_selection_changed), 0, this);
+       _content->Connect                (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,wxListEventHandler    (FilmEditor::content_right_click), 0, this);
        _content_add->Connect            (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this);
        _content_remove->Connect         (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_remove_clicked), 0, this);
        _content_timeline->Connect       (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_timeline_clicked), 0, this);
@@ -224,23 +224,9 @@ FilmEditor::connect_to_widgets ()
        _dcp_frame_rate->Connect         (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::dcp_frame_rate_changed), 0, this);
        _best_dcp_frame_rate->Connect    (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::best_dcp_frame_rate_clicked), 0, this);
        _dcp_audio_channels->Connect     (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::dcp_audio_channels_changed), 0, this);
-       _with_subtitles->Connect         (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this);
-       _subtitle_offset->Connect        (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::subtitle_offset_changed), 0, this);
-       _subtitle_scale->Connect         (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this);
        _j2k_bandwidth->Connect          (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::j2k_bandwidth_changed), 0, this);
-       _audio_gain->Connect             (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this);
-       _audio_gain_calculate_button->Connect (
-               wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::audio_gain_calculate_button_clicked), 0, this
-               );
-       _show_audio->Connect             (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::show_audio_clicked), 0, this);
-       _audio_delay->Connect            (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
-       _audio_stream->Connect           (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this);
-       _subtitle_stream->Connect        (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this);
        _dcp_resolution->Connect         (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::dcp_resolution_changed), 0, this);
-               
-       _audio_mapping->Changed.connect  (boost::bind (&FilmEditor::audio_mapping_changed, this, _1));
-       _start->Changed.connect          (boost::bind (&FilmEditor::start_changed, this));
-       _length->Changed.connect         (boost::bind (&FilmEditor::length_changed, this));
+       _sequence_video->Connect         (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::sequence_video_changed), 0, this);
 }
 
 void
@@ -334,133 +320,19 @@ FilmEditor::make_content_panel ()
                _content_sizer->Add (s, 0.75, wxEXPAND | wxALL, 6);
        }
 
+       _sequence_video = new wxCheckBox (_content_panel, wxID_ANY, _("Keep video in sequence"));
+       _content_sizer->Add (_sequence_video);
+
        _content_notebook = new wxNotebook (_content_panel, wxID_ANY);
        _content_sizer->Add (_content_notebook, 1, wxEXPAND | wxTOP, 6);
 
        make_video_panel ();
        _content_notebook->AddPage (_video_panel, _("Video"), false);
-       make_audio_panel ();
-       _content_notebook->AddPage (_audio_panel, _("Audio"), false);
-       make_subtitle_panel ();
-       _content_notebook->AddPage (_subtitle_panel, _("Subtitles"), false);
-       make_timing_panel ();
-       _content_notebook->AddPage (_timing_panel, _("Timing"), false);
-}
-
-void
-FilmEditor::make_audio_panel ()
-{
-       _audio_panel = new wxPanel (_content_notebook);
-       wxBoxSizer* audio_sizer = new wxBoxSizer (wxVERTICAL);
-       _audio_panel->SetSizer (audio_sizer);
-       
-       wxFlexGridSizer* grid = new wxFlexGridSizer (3, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
-       audio_sizer->Add (grid, 0, wxALL, 8);
-
-       _show_audio = new wxButton (_audio_panel, wxID_ANY, _("Show Audio..."));
-       grid->Add (_show_audio, 1);
-       grid->AddSpacer (0);
-       grid->AddSpacer (0);
-
-       add_label_to_sizer (grid, _audio_panel, _("Audio Gain"), true);
-       {
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _audio_gain = new wxSpinCtrl (_audio_panel);
-               s->Add (_audio_gain, 1);
-               add_label_to_sizer (s, _audio_panel, _("dB"), false);
-               grid->Add (s, 1);
-       }
-       
-       _audio_gain_calculate_button = new wxButton (_audio_panel, wxID_ANY, _("Calculate..."));
-       grid->Add (_audio_gain_calculate_button);
-
-       add_label_to_sizer (grid, _audio_panel, _("Audio Delay"), false);
-       {
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _audio_delay = new wxSpinCtrl (_audio_panel);
-               s->Add (_audio_delay, 1);
-               /// TRANSLATORS: this is an abbreviation for milliseconds, the unit of time
-               add_label_to_sizer (s, _audio_panel, _("ms"), false);
-               grid->Add (s);
-       }
-
-       grid->AddSpacer (0);
-
-       add_label_to_sizer (grid, _audio_panel, _("Audio Stream"), true);
-       _audio_stream = new wxChoice (_audio_panel, wxID_ANY);
-       grid->Add (_audio_stream, 1, wxEXPAND);
-       _audio_description = new wxStaticText (_audio_panel, wxID_ANY, wxT (""));
-       grid->AddSpacer (0);
-       
-       grid->Add (_audio_description, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 8);
-       grid->AddSpacer (0);
-       grid->AddSpacer (0);
-       
-       _audio_mapping = new AudioMappingView (_audio_panel);
-       audio_sizer->Add (_audio_mapping, 1, wxEXPAND | wxALL, 6);
-
-       _audio_gain->SetRange (-60, 60);
-       _audio_delay->SetRange (-1000, 1000);
-}
-
-void
-FilmEditor::make_subtitle_panel ()
-{
-       _subtitle_panel = new wxPanel (_content_notebook);
-       wxBoxSizer* subtitle_sizer = new wxBoxSizer (wxVERTICAL);
-       _subtitle_panel->SetSizer (subtitle_sizer);
-       wxFlexGridSizer* grid = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
-       subtitle_sizer->Add (grid, 0, wxALL, 8);
-
-       _with_subtitles = new wxCheckBox (_subtitle_panel, wxID_ANY, _("With Subtitles"));
-       grid->Add (_with_subtitles, 1);
-       grid->AddSpacer (0);
-       
-       {
-               add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Offset"), true);
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _subtitle_offset = new wxSpinCtrl (_subtitle_panel);
-               s->Add (_subtitle_offset);
-               add_label_to_sizer (s, _subtitle_panel, _("%"), false);
-               grid->Add (s);
-       }
-
-       {
-               add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Scale"), true);
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _subtitle_scale = new wxSpinCtrl (_subtitle_panel);
-               s->Add (_subtitle_scale);
-               add_label_to_sizer (s, _subtitle_panel, _("%"), false);
-               grid->Add (s);
-       }
-
-       add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Stream"), true);
-       _subtitle_stream = new wxChoice (_subtitle_panel, wxID_ANY);
-       grid->Add (_subtitle_stream, 1, wxEXPAND);
-       
-       _subtitle_offset->SetRange (-100, 100);
-       _subtitle_scale->SetRange (1, 1000);
-       _subtitle_scale->SetValue (100);
+       _audio_panel = new AudioPanel (this);
+       _subtitle_panel = new SubtitlePanel (this);
+       _timing_panel = new TimingPanel (this);
 }
 
-void
-FilmEditor::make_timing_panel ()
-{
-       _timing_panel = new wxPanel (_content_notebook);
-       wxBoxSizer* timing_sizer = new wxBoxSizer (wxVERTICAL);
-       _timing_panel->SetSizer (timing_sizer);
-       wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4);
-       timing_sizer->Add (grid, 0, wxALL, 8);
-
-       add_label_to_sizer (grid, _timing_panel, _("Start time"), true);
-       _start = new Timecode (_timing_panel);
-       grid->Add (_start);
-       add_label_to_sizer (grid, _timing_panel, _("Length"), true);
-       _length = new Timecode (_timing_panel);
-       grid->Add (_length);
-}
-
-
 /** Called when the left crop widget has been changed */
 void
 FilmEditor::left_crop_changed (wxCommandEvent &)
@@ -520,28 +392,6 @@ FilmEditor::name_changed (wxCommandEvent &)
        _film->set_name (string (_name->GetValue().mb_str()));
 }
 
-void
-FilmEditor::subtitle_offset_changed (wxCommandEvent &)
-{
-       shared_ptr<SubtitleContent> c = selected_subtitle_content ();
-       if (!c) {
-               return;
-       }
-
-       c->set_subtitle_offset (_subtitle_offset->GetValue() / 100.0);
-}
-
-void
-FilmEditor::subtitle_scale_changed (wxCommandEvent &)
-{
-       shared_ptr<SubtitleContent> c = selected_subtitle_content ();
-       if (!c) {
-               return;
-       }
-
-       c->set_subtitle_scale (_subtitle_scale->GetValue() / 100.0);
-}
-
 void
 FilmEditor::j2k_bandwidth_changed (wxCommandEvent &)
 {
@@ -601,14 +451,16 @@ FilmEditor::film_changed (Film::Property p)
        }
 
        stringstream s;
+
+       _audio_panel->film_changed (p);
+       _subtitle_panel->film_changed (p);
+       _timing_panel->film_changed (p);
                
        switch (p) {
        case Film::NONE:
                break;
        case Film::CONTENT:
                setup_content ();
-               setup_subtitle_control_sensitivity ();
-               setup_show_audio_sensitivity ();
                break;
        case Film::CONTAINER:
                setup_container ();
@@ -617,6 +469,9 @@ FilmEditor::film_changed (Film::Property p)
                checked_set (_name, _film->name());
                setup_dcp_name ();
                break;
+       case Film::WITH_SUBTITLES:
+               setup_dcp_name ();
+               break;
        case Film::DCP_CONTENT_TYPE:
                checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
                setup_dcp_name ();
@@ -624,11 +479,6 @@ FilmEditor::film_changed (Film::Property p)
        case Film::SCALER:
                checked_set (_scaler, Scaler::as_index (_film->scaler ()));
                break;
-       case Film::WITH_SUBTITLES:
-               checked_set (_with_subtitles, _film->with_subtitles ());
-               setup_subtitle_control_sensitivity ();
-               setup_dcp_name ();
-               break;
        case Film::RESOLUTION:
                checked_set (_dcp_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
                setup_dcp_name ();
@@ -663,9 +513,11 @@ FilmEditor::film_changed (Film::Property p)
        }
        case Film::DCP_AUDIO_CHANNELS:
                _dcp_audio_channels->SetValue (_film->dcp_audio_channels ());
-               _audio_mapping->set_channels (_film->dcp_audio_channels ());
                setup_dcp_name ();
                break;
+       case Film::SEQUENCE_VIDEO:
+               checked_set (_sequence_video, _film->sequence_video ());
+               break;
        }
 }
 
@@ -682,6 +534,10 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
        }
 
        shared_ptr<Content> content = weak_content.lock ();
+       if (content != selected_content ()) {
+               return;
+       }
+       
        shared_ptr<VideoContent> video_content;
        shared_ptr<AudioContent> audio_content;
        shared_ptr<SubtitleContent> subtitle_content;
@@ -693,21 +549,13 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
                ffmpeg_content = dynamic_pointer_cast<FFmpegContent> (content);
        }
 
+       _audio_panel->film_content_changed    (content, audio_content, subtitle_content, ffmpeg_content, property);
+       _subtitle_panel->film_content_changed (content, audio_content, subtitle_content, ffmpeg_content, property);
+       _timing_panel->film_content_changed   (content, audio_content, subtitle_content, ffmpeg_content, property);
+
        /* We can't use case {} here */
        
-       if (property == ContentProperty::START) {
-               if (content) {
-                       _start->set (content->start (), _film->dcp_video_frame_rate ());
-               } else {
-                       _start->set (0, 24);
-               }
-       } else if (property == ContentProperty::LENGTH) {
-               if (content) {
-                       _length->set (content->length (), _film->dcp_video_frame_rate ());
-               } else {
-                       _length->set (0, 24);
-               }
-       } else if (property == VideoContentProperty::VIDEO_CROP) {
+       if (property == VideoContentProperty::VIDEO_CROP) {
                checked_set (_left_crop,   video_content ? video_content->crop().left   : 0);
                checked_set (_right_crop,  video_content ? video_content->crop().right  : 0);
                checked_set (_top_crop,    video_content ? video_content->crop().top    : 0);
@@ -732,43 +580,8 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
                        checked_set (_ratio, -1);
                }
                setup_scaling_description ();
-       } else if (property == AudioContentProperty::AUDIO_GAIN) {
-               checked_set (_audio_gain, audio_content ? audio_content->audio_gain() : 0);
-       } else if (property == AudioContentProperty::AUDIO_DELAY) {
-               checked_set (_audio_delay, audio_content ? audio_content->audio_delay() : 0);
-       } else if (property == AudioContentProperty::AUDIO_MAPPING) {
-               _audio_mapping->set (audio_content ? audio_content->audio_mapping () : AudioMapping ());
-       } else if (property == FFmpegContentProperty::SUBTITLE_STREAMS) {
-               _subtitle_stream->Clear ();
-               if (ffmpeg_content) {
-                       vector<shared_ptr<FFmpegSubtitleStream> > s = ffmpeg_content->subtitle_streams ();
-                       for (vector<shared_ptr<FFmpegSubtitleStream> >::iterator i = s.begin(); i != s.end(); ++i) {
-                               _subtitle_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
-                       }
-                       
-                       if (ffmpeg_content->subtitle_stream()) {
-                               checked_set (_subtitle_stream, lexical_cast<string> (ffmpeg_content->subtitle_stream()->id));
-                       } else {
-                               _subtitle_stream->SetSelection (wxNOT_FOUND);
-                       }
-               }
-               setup_subtitle_control_sensitivity ();
-       } else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
-               _audio_stream->Clear ();
-               if (ffmpeg_content) {
-                       vector<shared_ptr<FFmpegAudioStream> > a = ffmpeg_content->audio_streams ();
-                       for (vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin(); i != a.end(); ++i) {
-                               _audio_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
-                       }
-                       
-                       if (ffmpeg_content->audio_stream()) {
-                               checked_set (_audio_stream, lexical_cast<string> (ffmpeg_content->audio_stream()->id));
-                       }
-               }
-               setup_show_audio_sensitivity ();
        } else if (property == FFmpegContentProperty::AUDIO_STREAM) {
                setup_dcp_name ();
-               setup_show_audio_sensitivity ();
        } else if (property == FFmpegContentProperty::FILTERS) {
                if (ffmpeg_content) {
                        pair<string, string> p = Filter::ffmpeg_strings (ffmpeg_content->filters ());
@@ -780,10 +593,6 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
                        }
                        _dcp_sizer->Layout ();
                }
-       } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET) {
-               checked_set (_subtitle_offset, subtitle_content ? (subtitle_content->subtitle_offset() * 100) : 0);
-       } else if (property == SubtitleContentProperty::SUBTITLE_SCALE) {
-               checked_set (_subtitle_scale, subtitle_content ? (subtitle_content->subtitle_scale() * 100) : 100);
        }
 }
 
@@ -873,6 +682,7 @@ FilmEditor::set_film (shared_ptr<Film> f)
        film_changed (Film::DCI_METADATA);
        film_changed (Film::DCP_VIDEO_FRAME_RATE);
        film_changed (Film::DCP_AUDIO_CHANNELS);
+       film_changed (Film::SEQUENCE_VIDEO);
 
        if (!_film->content().empty ()) {
                set_selection (_film->content().front ());
@@ -893,26 +703,15 @@ FilmEditor::set_things_sensitive (bool s)
        _name->Enable (s);
        _use_dci_name->Enable (s);
        _edit_dci_button->Enable (s);
-       _ratio->Enable (s);
        _content->Enable (s);
-       _left_crop->Enable (s);
-       _right_crop->Enable (s);
-       _top_crop->Enable (s);
-       _bottom_crop->Enable (s);
-       _filters_button->Enable (s);
-       _scaler->Enable (s);
        _dcp_content_type->Enable (s);
        _dcp_frame_rate->Enable (s);
        _dcp_audio_channels->Enable (s);
        _j2k_bandwidth->Enable (s);
-       _audio_gain->Enable (s);
-       _audio_gain_calculate_button->Enable (s);
-       _show_audio->Enable (s);
-       _audio_delay->Enable (s);
        _container->Enable (s);
 
-       setup_subtitle_control_sensitivity ();
-       setup_show_audio_sensitivity ();
+       _subtitle_panel->setup_control_sensitivity ();
+       _audio_panel->setup_sensitivity ();
        setup_content_sensitivity ();
        _best_dcp_frame_rate->Enable (s && _film && _film->best_dcp_video_frame_rate () != _film->dcp_video_frame_rate ());
 }
@@ -951,55 +750,6 @@ FilmEditor::scaler_changed (wxCommandEvent &)
        }
 }
 
-void
-FilmEditor::audio_gain_changed (wxCommandEvent &)
-{
-       shared_ptr<AudioContent> ac = selected_audio_content ();
-       if (!ac) {
-               return;
-       }
-
-       ac->set_audio_gain (_audio_gain->GetValue ());
-}
-
-void
-FilmEditor::audio_delay_changed (wxCommandEvent &)
-{
-       shared_ptr<AudioContent> ac = selected_audio_content ();
-       if (!ac) {
-               return;
-       }
-
-       ac->set_audio_delay (_audio_delay->GetValue ());
-}
-
-void
-FilmEditor::audio_gain_calculate_button_clicked (wxCommandEvent &)
-{
-       GainCalculatorDialog* d = new GainCalculatorDialog (this);
-       d->ShowModal ();
-
-       if (d->wanted_fader() == 0 || d->actual_fader() == 0) {
-               d->Destroy ();
-               return;
-       }
-       
-       _audio_gain->SetValue (
-               Config::instance()->sound_processor()->db_for_fader_change (
-                       d->wanted_fader (),
-                       d->actual_fader ()
-                       )
-               );
-
-       /* This appears to be necessary, as the change is not signalled,
-          I think.
-       */
-       wxCommandEvent dummy;
-       audio_gain_changed (dummy);
-       
-       d->Destroy ();
-}
-
 void
 FilmEditor::setup_ratios ()
 {
@@ -1013,36 +763,6 @@ FilmEditor::setup_ratios ()
        _dcp_sizer->Layout ();
 }
 
-void
-FilmEditor::with_subtitles_toggled (wxCommandEvent &)
-{
-       if (!_film) {
-               return;
-       }
-
-       _film->set_with_subtitles (_with_subtitles->GetValue ());
-}
-
-void
-FilmEditor::setup_subtitle_control_sensitivity ()
-{
-       bool h = false;
-       if (_generally_sensitive && _film) {
-               h = _film->has_subtitles ();
-       }
-       
-       _with_subtitles->Enable (h);
-
-       bool j = false;
-       if (_film) {
-               j = _film->with_subtitles ();
-       }
-       
-       _subtitle_offset->Enable (j);
-       _subtitle_scale->Enable (j);
-       _subtitle_stream->Enable (j);
-}
-
 void
 FilmEditor::use_dci_name_toggled (wxCommandEvent &)
 {
@@ -1084,29 +804,6 @@ FilmEditor::setup_dcp_name ()
        }
 }
 
-void
-FilmEditor::show_audio_clicked (wxCommandEvent &)
-{
-       if (_audio_dialog) {
-               _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_content (ac);
-}
-
 void
 FilmEditor::best_dcp_frame_rate_clicked (wxCommandEvent &)
 {
@@ -1117,12 +814,6 @@ FilmEditor::best_dcp_frame_rate_clicked (wxCommandEvent &)
        _film->set_dcp_video_frame_rate (_film->best_dcp_video_frame_rate ());
 }
 
-void
-FilmEditor::setup_show_audio_sensitivity ()
-{
-       _show_audio->Enable (_film);
-}
-
 void
 FilmEditor::setup_content ()
 {
@@ -1197,11 +888,9 @@ 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));
-       }
 
+       _audio_panel->content_selection_changed ();
+       
        film_content_changed (s, ContentProperty::START);
        film_content_changed (s, ContentProperty::LENGTH);
        film_content_changed (s, VideoContentProperty::VIDEO_CROP);
@@ -1359,112 +1048,6 @@ FilmEditor::content_timeline_clicked (wxCommandEvent &)
        _timeline_dialog->Show ();
 }
 
-void
-FilmEditor::audio_stream_changed (wxCommandEvent &)
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-       
-       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
-       if (!fc) {
-               return;
-       }
-       
-       vector<shared_ptr<FFmpegAudioStream> > a = fc->audio_streams ();
-       vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin ();
-       string const s = string_client_data (_audio_stream->GetClientObject (_audio_stream->GetSelection ()));
-       while (i != a.end() && lexical_cast<string> ((*i)->id) != s) {
-               ++i;
-       }
-
-       if (i != a.end ()) {
-               fc->set_audio_stream (*i);
-       }
-
-       if (!fc->audio_stream ()) {
-               _audio_description->SetLabel (wxT (""));
-       } else {
-               wxString s;
-               if (fc->audio_channels() == 1) {
-                       s << _("1 channel");
-               } else {
-                       s << fc->audio_channels() << wxT (" ") << _("channels");
-               }
-               s << wxT (", ") << fc->content_audio_frame_rate() << _("Hz");
-               _audio_description->SetLabel (s);
-       }
-}
-
-
-
-void
-FilmEditor::subtitle_stream_changed (wxCommandEvent &)
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-       
-       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
-       if (!fc) {
-               return;
-       }
-       
-       vector<shared_ptr<FFmpegSubtitleStream> > a = fc->subtitle_streams ();
-       vector<shared_ptr<FFmpegSubtitleStream> >::iterator i = a.begin ();
-       string const s = string_client_data (_subtitle_stream->GetClientObject (_subtitle_stream->GetSelection ()));
-       while (i != a.end() && lexical_cast<string> ((*i)->id) != s) {
-               ++i;
-       }
-
-       if (i != a.end ()) {
-               fc->set_subtitle_stream (*i);
-       }
-}
-
-void
-FilmEditor::audio_mapping_changed (AudioMapping m)
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-       
-       shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c);
-       if (!ac) {
-               return;
-       }
-
-       ac->set_audio_mapping (m);
-}
-
-void
-FilmEditor::start_changed ()
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-
-       c->set_start (_start->get (_film->dcp_video_frame_rate ()));
-}
-
-void
-FilmEditor::length_changed ()
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-
-       shared_ptr<StillImageContent> ic = dynamic_pointer_cast<StillImageContent> (c);
-       if (ic) {
-               ic->set_video_length (_length->get(_film->dcp_video_frame_rate()) * ic->video_frame_rate() / TIME_HZ);
-       }
-}
-
 void
 FilmEditor::set_selection (weak_ptr<Content> wc)
 {
@@ -1502,3 +1085,17 @@ FilmEditor::ratio_changed (wxCommandEvent &)
                vc->set_ratio (ratios[n]);
        }
 }
+
+void
+FilmEditor::sequence_video_changed (wxCommandEvent &)
+{
+       _film->set_sequence_video (_sequence_video->GetValue ());
+}
+
+void
+FilmEditor::content_right_click (wxListEvent& ev)
+{
+       ContentList cl;
+       cl.push_back (selected_content ());
+       _menu.popup (cl, ev.GetPoint ());
+}