Merge 1.0 in.
[dcpomatic.git] / src / wx / film_editor.cc
index 050b0c3e203b32f9a2d3c08cf07bc32cf7e1e9dd..56b6973757e0f7be59a52f892060a4223b4123a9 100644 (file)
@@ -1,7 +1,5 @@
-/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
-
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 #include <boost/thread.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/lexical_cast.hpp>
-#include "lib/format.h"
 #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"
 #include "lib/config.h"
-#include "lib/ffmpeg_decoder.h"
-#include "lib/imagemagick_content.h"
+#include "lib/still_image_content.h"
+#include "lib/moving_image_content.h"
+#include "lib/ffmpeg_content.h"
 #include "lib/sndfile_content.h"
 #include "lib/dcp_content_type.h"
-#include "filter_dialog.h"
+#include "lib/sound_processor.h"
+#include "lib/scaler.h"
+#include "timecode.h"
 #include "wx_util.h"
 #include "film_editor.h"
-#include "gain_calculator_dialog.h"
-#include "sound_processor.h"
 #include "dci_metadata_dialog.h"
-#include "scaler.h"
-#include "audio_dialog.h"
-#include "imagemagick_content_dialog.h"
 #include "timeline_dialog.h"
-#include "audio_mapping_view.h"
-#include "container.h"
+#include "timing_panel.h"
+#include "subtitle_panel.h"
+#include "audio_panel.h"
+#include "video_panel.h"
 
 using std::string;
 using std::cout;
@@ -73,8 +70,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);
@@ -87,8 +84,6 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
        make_dcp_panel ();
        _main_notebook->AddPage (_dcp_panel, _("DCP"), false);
        
-       setup_formats ();
-
        set_film (f);
        connect_to_widgets ();
 
@@ -106,61 +101,89 @@ FilmEditor::make_dcp_panel ()
        _dcp_sizer = new wxBoxSizer (wxVERTICAL);
        _dcp_panel->SetSizer (_dcp_sizer);
 
-       wxGridBagSizer* grid = new wxGridBagSizer (4, 4);
+       wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
        _dcp_sizer->Add (grid, 0, wxEXPAND | wxALL, 8);
 
        int r = 0;
        
-       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Name"), wxGBPosition (r, 0));
+       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Name"), true, wxGBPosition (r, 0));
        _name = new wxTextCtrl (_dcp_panel, wxID_ANY);
-       grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND);
+       grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxLEFT | wxRIGHT);
        ++r;
        
-       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("DCP Name"), wxGBPosition (r, 0));
+       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("DCP Name"), true, wxGBPosition (r, 0));
        _dcp_name = new wxStaticText (_dcp_panel, wxID_ANY, wxT (""));
        grid->Add (_dcp_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
        ++r;
 
+       int flags = wxALIGN_CENTER_VERTICAL;
+#ifdef __WXOSX__
+       flags |= wxALIGN_RIGHT;
+#endif 
+
        _use_dci_name = new wxCheckBox (_dcp_panel, wxID_ANY, _("Use DCI name"));
-       grid->Add (_use_dci_name, wxGBPosition (r, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
+       grid->Add (_use_dci_name, wxGBPosition (r, 0), wxDefaultSpan, flags);
        _edit_dci_button = new wxButton (_dcp_panel, wxID_ANY, _("Details..."));
        grid->Add (_edit_dci_button, wxGBPosition (r, 1), wxDefaultSpan);
        ++r;
 
-       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Container"), wxGBPosition (r, 0));
+       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Container"), true, wxGBPosition (r, 0));
        _container = new wxChoice (_dcp_panel, wxID_ANY);
-       grid->Add (_container, wxGBPosition (r, 1));
+       grid->Add (_container, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
        ++r;
 
-       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Content Type"), wxGBPosition (r, 0));
+       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Content Type"), true, wxGBPosition (r, 0));
        _dcp_content_type = new wxChoice (_dcp_panel, wxID_ANY);
        grid->Add (_dcp_content_type, wxGBPosition (r, 1));
        ++r;
 
        {
-               add_label_to_grid_bag_sizer (grid, _dcp_panel, _("DCP Frame Rate"), wxGBPosition (r, 0));
+               add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Frame Rate"), true, wxGBPosition (r, 0));
                wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _dcp_frame_rate = new wxChoice (_dcp_panel, wxID_ANY);
-               s->Add (_dcp_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
-               _best_dcp_frame_rate = new wxButton (_dcp_panel, wxID_ANY, _("Use best"));
-               s->Add (_best_dcp_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND);
+               _frame_rate = new wxChoice (_dcp_panel, wxID_ANY);
+               s->Add (_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
+               _best_frame_rate = new wxButton (_dcp_panel, wxID_ANY, _("Use best"));
+               s->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND);
                grid->Add (s, wxGBPosition (r, 1));
        }
        ++r;
 
+       _encrypted = new wxCheckBox (_dcp_panel, wxID_ANY, wxT ("Encrypted"));
+       grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
+       ++r;
+
+       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Audio channels"), true, wxGBPosition (r, 0));
+       _audio_channels = new wxSpinCtrl (_dcp_panel, wxID_ANY);
+       grid->Add (_audio_channels, wxGBPosition (r, 1));
+       ++r;
+
+       _three_d = new wxCheckBox (_dcp_panel, wxID_ANY, _("3D"));
+       grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
+       ++r;
+
+       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Resolution"), true, wxGBPosition (r, 0));
+       _resolution = new wxChoice (_dcp_panel, wxID_ANY);
+       grid->Add (_resolution, wxGBPosition (r, 1));
+       ++r;
+
        {
-               add_label_to_grid_bag_sizer (grid, _dcp_panel, _("JPEG2000 bandwidth"), wxGBPosition (r, 0));
+               add_label_to_grid_bag_sizer (grid, _dcp_panel, _("JPEG2000 bandwidth"), true, wxGBPosition (r, 0));
                wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
                _j2k_bandwidth = new wxSpinCtrl (_dcp_panel, wxID_ANY);
                s->Add (_j2k_bandwidth, 1);
-               add_label_to_sizer (s, _dcp_panel, _("MBps"));
+               add_label_to_sizer (s, _dcp_panel, _("MBps"), false);
                grid->Add (s, wxGBPosition (r, 1));
        }
        ++r;
 
-       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Scaler"), wxGBPosition (r, 0));
+       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Standard"), true, wxGBPosition (r, 0));
+       _standard = new wxChoice (_dcp_panel, wxID_ANY);
+       grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
+       ++r;
+
+       add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Scaler"), true, wxGBPosition (r, 0));
        _scaler = new wxChoice (_dcp_panel, wxID_ANY);
-       grid->Add (_scaler, wxGBPosition (r, 1));
+       grid->Add (_scaler, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
        ++r;
 
        vector<Scaler const *> const sc = Scaler::all ();
@@ -168,9 +191,9 @@ FilmEditor::make_dcp_panel ()
                _scaler->Append (std_to_wx ((*i)->name()));
        }
 
-       vector<Container const *> const co = Container::all ();
-       for (vector<Container const *>::const_iterator i = co.begin(); i != co.end(); ++i) {
-               _container->Append (std_to_wx ((*i)->name ()));
+       vector<Ratio const *> const ratio = Ratio::all ();
+       for (vector<Ratio const *>::const_iterator i = ratio.begin(); i != ratio.end(); ++i) {
+               _container->Append (std_to_wx ((*i)->nickname ()));
        }
 
        vector<DCPContentType const *> const ct = DCPContentType::all ();
@@ -180,121 +203,43 @@ FilmEditor::make_dcp_panel ()
 
        list<int> const dfr = Config::instance()->allowed_dcp_frame_rates ();
        for (list<int>::const_iterator i = dfr.begin(); i != dfr.end(); ++i) {
-               _dcp_frame_rate->Append (std_to_wx (boost::lexical_cast<string> (*i)));
+               _frame_rate->Append (std_to_wx (boost::lexical_cast<string> (*i)));
        }
 
-       _j2k_bandwidth->SetRange (50, 250);
+       _audio_channels->SetRange (0, MAX_AUDIO_CHANNELS);
+       _j2k_bandwidth->SetRange (1, 250);
+
+       _resolution->Append (_("2K"));
+       _resolution->Append (_("4K"));
+
+       _standard->Append (_("SMPTE"));
+       _standard->Append (_("Interop"));
 }
 
 void
 FilmEditor::connect_to_widgets ()
 {
-       _name->Connect                   (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED,         wxCommandEventHandler (FilmEditor::name_changed), 0, this);
-       _use_dci_name->Connect           (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::use_dci_name_toggled), 0, this);
-       _edit_dci_button->Connect        (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this);
-       _container->Connect              (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::container_changed), 0, this);
-//     _format->Connect                 (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::format_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_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);
-       _loop_content->Connect           (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::loop_content_toggled), 0, this);
-       _loop_count->Connect             (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::loop_count_changed), 0, this);
-       _left_crop->Connect              (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this);
-       _right_crop->Connect             (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::right_crop_changed), 0, this);
-       _top_crop->Connect               (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this);
-       _bottom_crop->Connect            (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::bottom_crop_changed), 0, this);
-       _filters_button->Connect         (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::edit_filters_clicked), 0, this);
-       _scaler->Connect                 (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::scaler_changed), 0, this);
-       _dcp_content_type->Connect       (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this);
-       _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);
-       _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);
-       _colour_lut->Connect             (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::colour_lut_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);
-       _audio_mapping->Changed.connect  (bind (&FilmEditor::audio_mapping_changed, this, _1));
-}
-
-void
-FilmEditor::make_video_panel ()
-{
-       _video_panel = new wxPanel (_content_notebook);
-       _video_sizer = new wxBoxSizer (wxVERTICAL);
-       _video_panel->SetSizer (_video_sizer);
-       
-       wxGridBagSizer* grid = new wxGridBagSizer (4, 4);
-       _video_sizer->Add (grid, 0, wxALL, 8);
-
-       int r = 0;
-       add_label_to_grid_bag_sizer (grid, _video_panel, _("Format"), wxGBPosition (r, 0));
-       _format = new wxChoice (_video_panel, wxID_ANY);
-       grid->Add (_format, wxGBPosition (r, 1));
-       ++r;
-
-       add_label_to_grid_bag_sizer (grid, _video_panel, _("Left crop"), wxGBPosition (r, 0));
-       _left_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
-       grid->Add (_left_crop, wxGBPosition (r, 1));
-       ++r;
-
-       add_label_to_grid_bag_sizer (grid, _video_panel, _("Right crop"), wxGBPosition (r, 0));
-       _right_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
-       grid->Add (_right_crop, wxGBPosition (r, 1));
-       ++r;
-       
-       add_label_to_grid_bag_sizer (grid, _video_panel, _("Top crop"), wxGBPosition (r, 0));
-       _top_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
-       grid->Add (_top_crop, wxGBPosition (r, 1));
-       ++r;
-       
-       add_label_to_grid_bag_sizer (grid, _video_panel, _("Bottom crop"), wxGBPosition (r, 0));
-       _bottom_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
-       grid->Add (_bottom_crop, wxGBPosition (r, 1));
-       ++r;
-
-       _scaling_description = new wxStaticText (_video_panel, wxID_ANY, wxT ("\n \n \n \n"), wxDefaultPosition, wxDefaultSize);
-       grid->Add (_scaling_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
-       wxFont font = _scaling_description->GetFont();
-       font.SetStyle(wxFONTSTYLE_ITALIC);
-       font.SetPointSize(font.GetPointSize() - 1);
-       _scaling_description->SetFont(font);
-       ++r;
-
-       /* VIDEO-only stuff */
-       {
-               add_label_to_grid_bag_sizer (grid, _video_panel, _("Filters"), wxGBPosition (r, 0));
-               wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _filters = new wxStaticText (_video_panel, wxID_ANY, _("None"));
-               s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
-               _filters_button = new wxButton (_video_panel, wxID_ANY, _("Edit..."));
-               s->Add (_filters_button, 0);
-               grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
-       }
-       ++r;
-
-       add_label_to_grid_bag_sizer (grid, _video_panel, _("Colour look-up table"), wxGBPosition (r, 0));
-       _colour_lut = new wxChoice (_video_panel, wxID_ANY);
-       for (int i = 0; i < 2; ++i) {
-               _colour_lut->Append (std_to_wx (colour_lut_index_to_name (i)));
-       }
-       _colour_lut->SetSelection (0);
-       grid->Add (_colour_lut, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
-       ++r;
-
-       _left_crop->SetRange (0, 1024);
-       _top_crop->SetRange (0, 1024);
-       _right_crop->SetRange (0, 1024);
-       _bottom_crop->SetRange (0, 1024);
+       _name->Bind             (wxEVT_COMMAND_TEXT_UPDATED,          boost::bind (&FilmEditor::name_changed, this));
+       _use_dci_name->Bind     (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::use_dci_name_toggled, this));
+       _edit_dci_button->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::edit_dci_button_clicked, this));
+       _container->Bind        (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::container_changed, this));
+       _content->Bind          (wxEVT_COMMAND_LIST_ITEM_SELECTED,    boost::bind (&FilmEditor::content_selection_changed, this));
+       _content->Bind          (wxEVT_COMMAND_LIST_ITEM_DESELECTED,  boost::bind (&FilmEditor::content_selection_changed, this));
+       _content->Bind          (wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, boost::bind (&FilmEditor::content_right_click, this, _1));
+       _content_add_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_add_file_clicked, this));
+       _content_add_folder->Bind (wxEVT_COMMAND_BUTTON_CLICKED,      boost::bind (&FilmEditor::content_add_folder_clicked, this));
+       _content_remove->Bind   (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_remove_clicked, this));
+       _content_timeline->Bind (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::content_timeline_clicked, this));
+       _scaler->Bind           (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::scaler_changed, this));
+       _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::dcp_content_type_changed, this));
+       _frame_rate->Bind       (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::frame_rate_changed, this));
+       _best_frame_rate->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::best_frame_rate_clicked, this));
+       _audio_channels->Bind   (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&FilmEditor::audio_channels_changed, this));
+       _j2k_bandwidth->Bind    (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&FilmEditor::j2k_bandwidth_changed, this));
+       _resolution->Bind       (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::resolution_changed, this));
+       _sequence_video->Bind   (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::sequence_video_changed, this));
+       _three_d->Bind          (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::three_d_changed, this));
+       _standard->Bind         (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::standard_changed, this));
 }
 
 void
@@ -304,259 +249,122 @@ FilmEditor::make_content_panel ()
        _content_sizer = new wxBoxSizer (wxVERTICAL);
        _content_panel->SetSizer (_content_sizer);
 
-        {
-                wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-                
-                _content = new wxListCtrl (_content_panel, wxID_ANY, wxDefaultPosition, wxSize (320, 160), wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL);
-                s->Add (_content, 1, wxEXPAND | wxTOP | wxBOTTOM, 6);
+       {
+               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+               
+               _content = new wxListCtrl (_content_panel, wxID_ANY, wxDefaultPosition, wxSize (320, 160), wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL);
+               s->Add (_content, 1, wxEXPAND | wxTOP | wxBOTTOM, 6);
 
-                _content->InsertColumn (0, wxT(""));
+               _content->InsertColumn (0, wxT(""));
                _content->SetColumnWidth (0, 512);
 
-                wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
-                _content_add = new wxButton (_content_panel, wxID_ANY, _("Add..."));
-                b->Add (_content_add, 1, wxEXPAND | wxLEFT | wxRIGHT);
-                _content_remove = new wxButton (_content_panel, wxID_ANY, _("Remove"));
-                b->Add (_content_remove, 1, wxEXPAND | wxLEFT | wxRIGHT);
+               wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
+               _content_add_file = new wxButton (_content_panel, wxID_ANY, _("Add file(s)..."));
+               b->Add (_content_add_file, 1, wxEXPAND | wxLEFT | wxRIGHT);
+               _content_add_folder = new wxButton (_content_panel, wxID_ANY, _("Add folder..."));
+               b->Add (_content_add_folder, 1, wxEXPAND | wxLEFT | wxRIGHT);
+               _content_remove = new wxButton (_content_panel, wxID_ANY, _("Remove"));
+               b->Add (_content_remove, 1, wxEXPAND | wxLEFT | wxRIGHT);
                _content_timeline = new wxButton (_content_panel, wxID_ANY, _("Timeline..."));
                b->Add (_content_timeline, 1, wxEXPAND | wxLEFT | wxRIGHT);
 
-                s->Add (b, 0, wxALL, 4);
-
-                _content_sizer->Add (s, 0.75, wxEXPAND | wxALL, 6);
-        }
-
-       wxBoxSizer* h = new wxBoxSizer (wxHORIZONTAL);
-       _loop_content = new wxCheckBox (_content_panel, wxID_ANY, _("Loop everything"));
-       h->Add (_loop_content, 0, wxALL, 6);
-       _loop_count = new wxSpinCtrl (_content_panel, wxID_ANY);
-       h->Add (_loop_count, 0, wxALL, 6);
-       add_label_to_sizer (h, _content_panel, _("times"));
-       _content_sizer->Add (h, 0, wxALL, 6);
-
-       _content_notebook = new wxNotebook (_content_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_LEFT);
-       _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);
-
-       _loop_count->SetRange (2, 1024);
-}
-
-void
-FilmEditor::make_audio_panel ()
-{
-       _audio_panel = new wxPanel (_content_notebook);
-       _audio_sizer = new wxBoxSizer (wxVERTICAL);
-       _audio_panel->SetSizer (_audio_sizer);
-       
-       wxFlexGridSizer* grid = new wxFlexGridSizer (3, 4, 4);
-       _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"));
-       {
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _audio_gain = new wxSpinCtrl (_audio_panel);
-               s->Add (_audio_gain, 1);
-               add_label_to_sizer (s, _audio_panel, _("dB"));
-               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"));
-       {
-               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"));
-               grid->Add (s);
-       }
-
-       grid->AddSpacer (0);
-
-       add_label_to_sizer (grid, _audio_panel, _("Audio Stream"));
-       _audio_stream = new wxChoice (_audio_panel, wxID_ANY);
-       grid->Add (_audio_stream, 1);
-       _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);
-       _subtitle_sizer = new wxBoxSizer (wxVERTICAL);
-       _subtitle_panel->SetSizer (_subtitle_sizer);
-       wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4);
-       _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"));
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _subtitle_offset = new wxSpinCtrl (_subtitle_panel);
-               s->Add (_subtitle_offset);
-               add_label_to_sizer (s, _subtitle_panel, _("pixels"));
-               grid->Add (s);
-       }
-
-       {
-               add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Scale"));
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _subtitle_scale = new wxSpinCtrl (_subtitle_panel);
-               s->Add (_subtitle_scale);
-               add_label_to_sizer (s, _subtitle_panel, _("%"));
-               grid->Add (s);
-       }
-
-       add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Stream"));
-       _subtitle_stream = new wxChoice (_subtitle_panel, wxID_ANY);
-       grid->Add (_subtitle_stream, 1, wxEXPAND | wxALL, 6);
-       grid->AddSpacer (0);
-       
-       _subtitle_offset->SetRange (-1024, 1024);
-       _subtitle_scale->SetRange (1, 1000);
-}
+               s->Add (b, 0, wxALL, 4);
 
-/** Called when the left crop widget has been changed */
-void
-FilmEditor::left_crop_changed (wxCommandEvent &)
-{
-       shared_ptr<VideoContent> c = selected_video_content ();
-       if (!c) {
-               return;
+               _content_sizer->Add (s, 0.75, wxEXPAND | wxALL, 6);
        }
 
-       c->set_left_crop (_left_crop->GetValue ());
-}
+       _sequence_video = new wxCheckBox (_content_panel, wxID_ANY, _("Keep video in sequence"));
+       _content_sizer->Add (_sequence_video);
 
-/** Called when the right crop widget has been changed */
-void
-FilmEditor::right_crop_changed (wxCommandEvent &)
-{
-       shared_ptr<VideoContent> c = selected_video_content ();
-       if (!c) {
-               return;
-       }
+       _content_notebook = new wxNotebook (_content_panel, wxID_ANY);
+       _content_sizer->Add (_content_notebook, 1, wxEXPAND | wxTOP, 6);
 
-       c->set_right_crop (_right_crop->GetValue ());
+       _video_panel = new VideoPanel (this);
+       _panels.push_back (_video_panel);
+       _audio_panel = new AudioPanel (this);
+       _panels.push_back (_audio_panel);
+       _subtitle_panel = new SubtitlePanel (this);
+       _panels.push_back (_subtitle_panel);
+       _timing_panel = new TimingPanel (this);
+       _panels.push_back (_timing_panel);
 }
 
-/** Called when the top crop widget has been changed */
+/** Called when the name widget has been changed */
 void
-FilmEditor::top_crop_changed (wxCommandEvent &)
+FilmEditor::name_changed ()
 {
-       shared_ptr<VideoContent> c = selected_video_content ();
-       if (!c) {
+       if (!_film) {
                return;
        }
 
-       c->set_top_crop (_top_crop->GetValue ());
+       _film->set_name (string (_name->GetValue().mb_str()));
 }
 
-/** Called when the bottom crop value has been changed */
 void
-FilmEditor::bottom_crop_changed (wxCommandEvent &)
+FilmEditor::j2k_bandwidth_changed ()
 {
-       shared_ptr<VideoContent> c = selected_video_content ();
-       if (!c) {
+       if (!_film) {
                return;
        }
-
-       c->set_bottom_crop (_bottom_crop->GetValue ());
+       
+       _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1e6);
 }
 
-/** Called when the name widget has been changed */
 void
-FilmEditor::name_changed (wxCommandEvent &)
+FilmEditor::encrypted_toggled ()
 {
        if (!_film) {
                return;
        }
 
-       _film->set_name (string (_name->GetValue().mb_str()));
+       _film->set_encrypted (_encrypted->GetValue ());
 }
-
+                              
+/** Called when the name widget has been changed */
 void
-FilmEditor::subtitle_offset_changed (wxCommandEvent &)
+FilmEditor::frame_rate_changed ()
 {
        if (!_film) {
                return;
        }
 
-       _film->set_subtitle_offset (_subtitle_offset->GetValue ());
+       _film->set_video_frame_rate (
+               boost::lexical_cast<int> (
+                       wx_to_std (_frame_rate->GetString (_frame_rate->GetSelection ()))
+                       )
+               );
 }
 
 void
-FilmEditor::subtitle_scale_changed (wxCommandEvent &)
+FilmEditor::audio_channels_changed ()
 {
        if (!_film) {
                return;
        }
 
-       _film->set_subtitle_scale (_subtitle_scale->GetValue() / 100.0);
+       _film->set_audio_channels (_audio_channels->GetValue ());
 }
 
 void
-FilmEditor::colour_lut_changed (wxCommandEvent &)
+FilmEditor::resolution_changed ()
 {
        if (!_film) {
                return;
        }
-       
-       _film->set_colour_lut (_colour_lut->GetSelection ());
-}
 
-void
-FilmEditor::j2k_bandwidth_changed (wxCommandEvent &)
-{
-       if (!_film) {
-               return;
-       }
-       
-       _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1e6);
+       _film->set_resolution (_resolution->GetSelection() == 0 ? RESOLUTION_2K : RESOLUTION_4K);
 }
 
 void
-FilmEditor::dcp_frame_rate_changed (wxCommandEvent &)
+FilmEditor::standard_changed ()
 {
        if (!_film) {
                return;
        }
 
-       _film->set_dcp_video_frame_rate (
-               boost::lexical_cast<int> (
-                       wx_to_std (_dcp_frame_rate->GetString (_dcp_frame_rate->GetSelection ()))
-                       )
-               );
+       _film->set_interop (_standard->GetSelection() == 1);
 }
 
-
 /** Called when the metadata stored in the Film object has changed;
  *  so that we can update the GUI.
  *  @param p Property of the Film that has changed.
@@ -571,41 +379,27 @@ FilmEditor::film_changed (Film::Property p)
        }
 
        stringstream s;
+
+       for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
+               (*i)->film_changed (p);
+       }
                
        switch (p) {
        case Film::NONE:
                break;
        case Film::CONTENT:
                setup_content ();
-               setup_formats ();
-//             setup_format ();
-               setup_subtitle_control_sensitivity ();
-               setup_show_audio_sensitivity ();
-               break;
-       case Film::LOOP:
-               checked_set (_loop_content, _film->loop() > 1);
-               checked_set (_loop_count, _film->loop());
-               setup_loop_sensitivity ();
                break;
        case Film::CONTAINER:
                setup_container ();
                break;
-       case Film::FILTERS:
-       {
-               pair<string, string> p = Filter::ffmpeg_strings (_film->filters ());
-               if (p.first.empty () && p.second.empty ()) {
-                       _filters->SetLabel (_("None"));
-               } else {
-                       string const b = p.first + " " + p.second;
-                       _filters->SetLabel (std_to_wx (b));
-               }
-               _dcp_sizer->Layout ();
-               break;
-       }
        case Film::NAME:
                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 ();
@@ -613,19 +407,12 @@ 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::SUBTITLE_OFFSET:
-               checked_set (_subtitle_offset, _film->subtitle_offset ());
-               break;
-       case Film::SUBTITLE_SCALE:
-               checked_set (_subtitle_scale, _film->subtitle_scale() * 100);
+       case Film::ENCRYPTED:
+               checked_set (_encrypted, _film->encrypted ());
                break;
-       case Film::COLOUR_LUT:
-               checked_set (_colour_lut, _film->colour_lut ());
+       case Film::RESOLUTION:
+               checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
+               setup_dcp_name ();
                break;
        case Film::J2K_BANDWIDTH:
                checked_set (_j2k_bandwidth, double (_film->j2k_bandwidth()) / 1e6);
@@ -637,30 +424,46 @@ FilmEditor::film_changed (Film::Property p)
        case Film::DCI_METADATA:
                setup_dcp_name ();
                break;
-       case Film::DCP_VIDEO_FRAME_RATE:
+       case Film::VIDEO_FRAME_RATE:
        {
                bool done = false;
-               for (unsigned int i = 0; i < _dcp_frame_rate->GetCount(); ++i) {
-                       if (wx_to_std (_dcp_frame_rate->GetString(i)) == boost::lexical_cast<string> (_film->dcp_video_frame_rate())) {
-                               checked_set (_dcp_frame_rate, i);
+               for (unsigned int i = 0; i < _frame_rate->GetCount(); ++i) {
+                       if (wx_to_std (_frame_rate->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
+                               checked_set (_frame_rate, i);
                                done = true;
                                break;
                        }
                }
 
                if (!done) {
-                       checked_set (_dcp_frame_rate, -1);
+                       checked_set (_frame_rate, -1);
                }
 
-               _best_dcp_frame_rate->Enable (_film->best_dcp_video_frame_rate () != _film->dcp_video_frame_rate ());
+               _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
                break;
        }
+       case Film::AUDIO_CHANNELS:
+               _audio_channels->SetValue (_film->audio_channels ());
+               setup_dcp_name ();
+               break;
+       case Film::SEQUENCE_VIDEO:
+               checked_set (_sequence_video, _film->sequence_video ());
+               break;
+       case Film::THREE_D:
+               checked_set (_three_d, _film->three_d ());
+               setup_dcp_name ();
+               break;
+       case Film::INTEROP:
+               checked_set (_standard, _film->interop() ? 1 : 0);
+               break;
        }
 }
 
 void
 FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
 {
+       ensure_ui_thread ();
+       
        if (!_film) {
                /* We call this method ourselves (as well as using it as a signal handler)
                   so _film can be 0.
@@ -669,30 +472,16 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
        }
 
        shared_ptr<Content> content = weak_content.lock ();
-       shared_ptr<VideoContent> video_content;
-       shared_ptr<AudioContent> audio_content;
-       if (content) {
-               video_content = dynamic_pointer_cast<VideoContent> (content);
-               audio_content = dynamic_pointer_cast<AudioContent> (content);
+       if (!content || content != selected_content ()) {
+               return;
        }
 
-       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);
-               checked_set (_bottom_crop, video_content ? video_content->crop().bottom : 0);
-               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 == FFmpegContentProperty::SUBTITLE_STREAMS) {
-               setup_subtitle_control_sensitivity ();
-       } else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
-               setup_show_audio_sensitivity ();
-       } else if (property == FFmpegContentProperty::AUDIO_STREAM) {
+       for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
+               (*i)->film_content_changed (content, property);
+       }
+
+       if (property == FFmpegContentProperty::AUDIO_STREAM) {
                setup_dcp_name ();
-               setup_show_audio_sensitivity ();
        }
 }
 
@@ -700,26 +489,25 @@ void
 FilmEditor::setup_container ()
 {
        int n = 0;
-       vector<Container const *> containers = Container::all ();
-       vector<Container const *>::iterator i = containers.begin ();
-       while (i != containers.end() && *i != _film->container ()) {
+       vector<Ratio const *> ratios = Ratio::all ();
+       vector<Ratio const *>::iterator i = ratios.begin ();
+       while (i != ratios.end() && *i != _film->container ()) {
                ++i;
                ++n;
        }
        
-       if (i == containers.end()) {
+       if (i == ratios.end()) {
                checked_set (_container, -1);
        } else {
                checked_set (_container, n);
        }
        
        setup_dcp_name ();
-       setup_scaling_description ();
 }      
 
 /** Called when the container widget has been changed */
 void
-FilmEditor::container_changed (wxCommandEvent &)
+FilmEditor::container_changed ()
 {
        if (!_film) {
                return;
@@ -727,15 +515,15 @@ FilmEditor::container_changed (wxCommandEvent &)
 
        int const n = _container->GetSelection ();
        if (n >= 0) {
-               vector<Container const *> containers = Container::all ();
-               assert (n < int (containers.size()));
-               _film->set_container (containers[n]);
+               vector<Ratio const *> ratios = Ratio::all ();
+               assert (n < int (ratios.size()));
+               _film->set_container (ratios[n]);
        }
 }
 
 /** Called when the DCP content type widget has been changed */
 void
-FilmEditor::dcp_content_type_changed (wxCommandEvent &)
+FilmEditor::dcp_content_type_changed ()
 {
        if (!_film) {
                return;
@@ -751,7 +539,7 @@ FilmEditor::dcp_content_type_changed (wxCommandEvent &)
 void
 FilmEditor::set_film (shared_ptr<Film> f)
 {
-       set_things_sensitive (f != 0);
+       set_general_sensitivity (f != 0);
 
        if (_film == f) {
                return;
@@ -770,83 +558,66 @@ 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);
-       film_changed (Film::LOOP);
        film_changed (Film::DCP_CONTENT_TYPE);
        film_changed (Film::CONTAINER);
-       film_changed (Film::FILTERS);
+       film_changed (Film::RESOLUTION);
        film_changed (Film::SCALER);
        film_changed (Film::WITH_SUBTITLES);
-       film_changed (Film::SUBTITLE_OFFSET);
-       film_changed (Film::SUBTITLE_SCALE);
-       film_changed (Film::COLOUR_LUT);
+       film_changed (Film::ENCRYPTED);
        film_changed (Film::J2K_BANDWIDTH);
        film_changed (Film::DCI_METADATA);
-       film_changed (Film::DCP_VIDEO_FRAME_RATE);
-
-       film_content_changed (boost::shared_ptr<Content> (), VideoContentProperty::VIDEO_CROP);
-       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> (), 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_changed (Film::VIDEO_FRAME_RATE);
+       film_changed (Film::AUDIO_CHANNELS);
+       film_changed (Film::SEQUENCE_VIDEO);
+       film_changed (Film::THREE_D);
+       film_changed (Film::INTEROP);
+
+       if (!_film->content().empty ()) {
+               set_selection (_film->content().front ());
+       }
+
+       content_selection_changed ();
 }
 
-/** Updates the sensitivity of lots of widgets to a given value.
- *  @param s true to make sensitive, false to make insensitive.
- */
 void
-FilmEditor::set_things_sensitive (bool s)
+FilmEditor::set_general_sensitivity (bool s)
 {
        _generally_sensitive = s;
-       
+
+       /* Stuff in the Content / DCP tabs */
        _name->Enable (s);
        _use_dci_name->Enable (s);
        _edit_dci_button->Enable (s);
-       _format->Enable (s);
-       _content->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);
+       _content_add_file->Enable (s);
+       _content_add_folder->Enable (s);
+       _content_remove->Enable (s);
+       _content_timeline->Enable (s);
        _dcp_content_type->Enable (s);
-       _best_dcp_frame_rate->Enable (s);
-       _dcp_frame_rate->Enable (s);
-       _colour_lut->Enable (s);
+       _encrypted->Enable (s);
+       _frame_rate->Enable (s);
+       _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);
-
-       setup_subtitle_control_sensitivity ();
-       setup_show_audio_sensitivity ();
-       setup_content_sensitivity ();
-}
+       _container->Enable (s);
+       _best_frame_rate->Enable (s && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
+       _sequence_video->Enable (s);
+       _resolution->Enable (s);
+       _scaler->Enable (s);
+       _three_d->Enable (s);
+       _standard->Enable (s);
 
-/** Called when the `Edit filters' button has been clicked */
-void
-FilmEditor::edit_filters_clicked (wxCommandEvent &)
-{
-       FilterDialog* d = new FilterDialog (this, _film->filters());
-       d->ActiveChanged.connect (bind (&Film::set_filters, _film, _1));
-       d->ShowModal ();
-       d->Destroy ();
+       /* Set the panels in the content notebook */
+       for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
+               (*i)->Enable (s);
+       }
 }
 
 /** Called when the scaler widget has been changed */
 void
-FilmEditor::scaler_changed (wxCommandEvent &)
+FilmEditor::scaler_changed ()
 {
        if (!_film) {
                return;
@@ -859,112 +630,7 @@ 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::setup_main_notebook_size ()
-{
-       _main_notebook->InvalidateBestSize ();
-
-       _content_sizer->Layout ();
-       _content_sizer->SetSizeHints (_content_panel);
-       _dcp_sizer->Layout ();
-       _dcp_sizer->SetSizeHints (_dcp_panel);
-
-       _main_notebook->Fit ();
-       Fit ();
-}
-
-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_formats ()
-{
-       _formats = Format::all ();
-
-       _format->Clear ();
-       for (vector<Format const *>::iterator i = _formats.begin(); i != _formats.end(); ++i) {
-               _format->Append (std_to_wx ((*i)->name ()));
-       }
-
-       _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);
-}
-
-void
-FilmEditor::use_dci_name_toggled (wxCommandEvent &)
+FilmEditor::use_dci_name_toggled ()
 {
        if (!_film) {
                return;
@@ -974,7 +640,7 @@ FilmEditor::use_dci_name_toggled (wxCommandEvent &)
 }
 
 void
-FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
+FilmEditor::edit_dci_button_clicked ()
 {
        if (!_film) {
                return;
@@ -989,7 +655,7 @@ FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
 void
 FilmEditor::active_jobs_changed (bool a)
 {
-       set_things_sensitive (!a);
+       set_general_sensitivity (!a);
 }
 
 void
@@ -1005,32 +671,13 @@ FilmEditor::setup_dcp_name ()
 }
 
 void
-FilmEditor::show_audio_clicked (wxCommandEvent &)
-{
-       if (_audio_dialog) {
-               _audio_dialog->Destroy ();
-               _audio_dialog = 0;
-       }
-       
-       _audio_dialog = new AudioDialog (this);
-       _audio_dialog->Show ();
-       _audio_dialog->set_film (_film);
-}
-
-void
-FilmEditor::best_dcp_frame_rate_clicked (wxCommandEvent &)
+FilmEditor::best_frame_rate_clicked ()
 {
        if (!_film) {
                return;
        }
        
-       _film->set_dcp_video_frame_rate (_film->best_dcp_video_frame_rate ());
-}
-
-void
-FilmEditor::setup_show_audio_sensitivity ()
-{
-       _show_audio->Enable (_film);
+       _film->set_video_frame_rate (_film->best_video_frame_rate ());
 }
 
 void
@@ -1044,8 +691,8 @@ FilmEditor::setup_content ()
        
        _content->DeleteAllItems ();
 
-       Playlist::ContentList content = _film->content ();
-       for (Playlist::ContentList::iterator i = content.begin(); i != content.end(); ++i) {
+       ContentList content = _film->content ();
+       for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
                int const t = _content->GetItemCount ();
                _content->InsertItem (t, std_to_wx ((*i)->summary ()));
                if ((*i)->summary() == selected_summary) {
@@ -1054,13 +701,13 @@ 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);
        }
 }
 
 void
-FilmEditor::content_add_clicked (wxCommandEvent &)
+FilmEditor::content_add_file_clicked ()
 {
        wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE);
        int const r = d->ShowModal ();
@@ -1073,47 +720,99 @@ FilmEditor::content_add_clicked (wxCommandEvent &)
        wxArrayString paths;
        d->GetPaths (paths);
 
+       /* XXX: check for lots of files here and do something */
+
        for (unsigned int i = 0; i < paths.GetCount(); ++i) {
                boost::filesystem::path p (wx_to_std (paths[i]));
 
-               if (ImageMagickContent::valid_file (p)) {
-                       _film->add_content (shared_ptr<ImageMagickContent> (new ImageMagickContent (_film, p)));
+               shared_ptr<Content> c;
+
+               if (valid_image_file (p)) {
+                       c.reset (new StillImageContent (_film, p));
                } else if (SndfileContent::valid_file (p)) {
-                       _film->add_content (shared_ptr<SndfileContent> (new SndfileContent (_film, p)));
+                       c.reset (new SndfileContent (_film, p));
                } else {
-                       _film->add_content (shared_ptr<FFmpegContent> (new FFmpegContent (_film, p)));
+                       c.reset (new FFmpegContent (_film, p));
                }
+
+               _film->examine_and_add_content (c);
        }
 }
 
 void
-FilmEditor::content_remove_clicked (wxCommandEvent &)
+FilmEditor::content_add_folder_clicked ()
+{
+       wxDirDialog* d = new wxDirDialog (this, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST);
+       int const r = d->ShowModal ();
+       d->Destroy ();
+       
+       if (r != wxID_OK) {
+               return;
+       }
+
+       _film->examine_and_add_content (
+               shared_ptr<MovingImageContent> (
+                       new MovingImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ())))
+                       )
+               );
+}
+
+void
+FilmEditor::content_remove_clicked ()
 {
        shared_ptr<Content> c = selected_content ();
        if (c) {
                _film->remove_content (c);
        }
+
+       content_selection_changed ();
 }
 
 void
-FilmEditor::content_selection_changed (wxListEvent &)
+FilmEditor::content_selection_changed ()
 {
-        setup_content_sensitivity ();
-}
+       setup_content_sensitivity ();
+       shared_ptr<Content> s = selected_content ();
 
+       /* All other sensitivity in content panels should be triggered by
+          one of these.
+       */
+       film_content_changed (s, ContentProperty::POSITION);
+       film_content_changed (s, ContentProperty::LENGTH);
+       film_content_changed (s, ContentProperty::TRIM_START);
+       film_content_changed (s, ContentProperty::TRIM_END);
+       film_content_changed (s, VideoContentProperty::VIDEO_CROP);
+       film_content_changed (s, VideoContentProperty::VIDEO_RATIO);
+       film_content_changed (s, VideoContentProperty::VIDEO_FRAME_TYPE);
+       film_content_changed (s, VideoContentProperty::COLOUR_CONVERSION);
+       film_content_changed (s, AudioContentProperty::AUDIO_GAIN);
+       film_content_changed (s, AudioContentProperty::AUDIO_DELAY);
+       film_content_changed (s, AudioContentProperty::AUDIO_MAPPING);
+       film_content_changed (s, FFmpegContentProperty::AUDIO_STREAM);
+       film_content_changed (s, FFmpegContentProperty::AUDIO_STREAMS);
+       film_content_changed (s, FFmpegContentProperty::SUBTITLE_STREAM);
+       film_content_changed (s, FFmpegContentProperty::SUBTITLE_STREAMS);
+       film_content_changed (s, FFmpegContentProperty::FILTERS);
+       film_content_changed (s, SubtitleContentProperty::SUBTITLE_OFFSET);
+       film_content_changed (s, SubtitleContentProperty::SUBTITLE_SCALE);
+}
+
+/** Set up broad sensitivity based on the type of content that is selected */
 void
 FilmEditor::setup_content_sensitivity ()
 {
-        _content_add->Enable (_generally_sensitive);
+       _content_add_file->Enable (_generally_sensitive);
+       _content_add_folder->Enable (_generally_sensitive);
 
        shared_ptr<Content> selection = selected_content ();
 
-        _content_remove->Enable (selection && _generally_sensitive);
+       _content_remove->Enable (selection && _generally_sensitive);
        _content_timeline->Enable (_generally_sensitive);
 
-       _video_panel->Enable (selection && _generally_sensitive);
-       _audio_panel->Enable (selection && _generally_sensitive);
-       _subtitle_panel->Enable (selection && _generally_sensitive);
+       _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>
@@ -1124,7 +823,7 @@ FilmEditor::selected_content ()
                return shared_ptr<Content> ();
        }
 
-       Playlist::ContentList c = _film->content ();
+       ContentList c = _film->content ();
        if (s < 0 || size_t (s) >= c.size ()) {
                return shared_ptr<Content> ();
        }
@@ -1154,91 +853,19 @@ FilmEditor::selected_audio_content ()
        return dynamic_pointer_cast<AudioContent> (c);
 }
 
-void
-FilmEditor::setup_scaling_description ()
-{
-       wxString d;
-
-#if 0  
-XXX
-       int lines = 0;
-
-       if (_film->video_size().width && _film->video_size().height) {
-               d << wxString::Format (
-                       _("Original video is %dx%d (%.2f:1)\n"),
-                       _film->video_size().width, _film->video_size().height,
-                       float (_film->video_size().width) / _film->video_size().height
-                       );
-               ++lines;
-       }
-
-       Crop const crop = _film->crop ();
-       if (crop.left || crop.right || crop.top || crop.bottom) {
-               libdcp::Size const cropped = _film->cropped_size (_film->video_size ());
-               d << wxString::Format (
-                       _("Cropped to %dx%d (%.2f:1)\n"),
-                       cropped.width, cropped.height,
-                       float (cropped.width) / cropped.height
-                       );
-               ++lines;
-       }
-
-       Format const * format = _film->format ();
-       if (format) {
-               int const padding = format->dcp_padding (_film);
-               libdcp::Size scaled = format->dcp_size ();
-               scaled.width -= padding * 2;
-               d << wxString::Format (
-                       _("Scaled to %dx%d (%.2f:1)\n"),
-                       scaled.width, scaled.height,
-                       float (scaled.width) / scaled.height
-                       );
-               ++lines;
-
-               if (padding) {
-                       d << wxString::Format (
-                               _("Padded with black to %dx%d (%.2f:1)\n"),
-                               format->dcp_size().width, format->dcp_size().height,
-                               float (format->dcp_size().width) / format->dcp_size().height
-                               );
-                       ++lines;
-               }
-       }
-
-       for (int i = lines; i < 4; ++i) {
-               d << wxT ("\n ");
-       }
-
-#endif 
-       _scaling_description->SetLabel (d);
-}
-
-void
-FilmEditor::loop_content_toggled (wxCommandEvent &)
+shared_ptr<SubtitleContent>
+FilmEditor::selected_subtitle_content ()
 {
-       if (_loop_content->GetValue ()) {
-               _film->set_loop (_loop_count->GetValue ());
-       } else {
-               _film->set_loop (1);
+       shared_ptr<Content> c = selected_content ();
+       if (!c) {
+               return shared_ptr<SubtitleContent> ();
        }
-               
-       setup_loop_sensitivity ();
-}
 
-void
-FilmEditor::loop_count_changed (wxCommandEvent &)
-{
-       _film->set_loop (_loop_count->GetValue ());
+       return dynamic_pointer_cast<SubtitleContent> (c);
 }
 
 void
-FilmEditor::setup_loop_sensitivity ()
-{
-       _loop_count->Enable (_loop_content->GetValue ());
-}
-
-void
-FilmEditor::content_timeline_clicked (wxCommandEvent &)
+FilmEditor::content_timeline_clicked ()
 {
        if (_timeline_dialog) {
                _timeline_dialog->Destroy ();
@@ -1250,125 +877,42 @@ FilmEditor::content_timeline_clicked (wxCommandEvent &)
 }
 
 void
-FilmEditor::setup_content_properties ()
+FilmEditor::set_selection (weak_ptr<Content> wc)
 {
-       _audio_stream->Clear ();
-       _subtitle_stream->Clear ();
-
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-
-       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
-       if (fc) {
-               
-               vector<shared_ptr<FFmpegAudioStream> > a = fc->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 (fc->audio_stream()) {
-                       checked_set (_audio_stream, lexical_cast<string> (fc->audio_stream()->id));
-               }
-               
-               vector<shared_ptr<FFmpegSubtitleStream> > s = fc->subtitle_streams ();
-               if (s.empty ()) {
-                       _subtitle_stream->Enable (false);
-               }
-               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 (fc->subtitle_stream()) {
-                       checked_set (_subtitle_stream, lexical_cast<string> (fc->subtitle_stream()->id));
+       ContentList content = _film->content ();
+       for (size_t i = 0; i < content.size(); ++i) {
+               if (content[i] == wc.lock ()) {
+                       _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
                } else {
-                       _subtitle_stream->SetSelection (wxNOT_FOUND);
+                       _content->SetItemState (i, 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
                }
-
-               /* XXX: should be general audiocontent */
-               _audio_mapping->set_mapping (fc->audio_mapping ());
        }
 }
 
 void
-FilmEditor::audio_stream_changed (wxCommandEvent &)
+FilmEditor::sequence_video_changed ()
 {
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-       
-       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
-       if (!fc) {
+       if (!_film) {
                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);
-       }
+       _film->set_sequence_video (_sequence_video->GetValue ());
 }
 
-
-
 void
-FilmEditor::subtitle_stream_changed (wxCommandEvent &)
+FilmEditor::content_right_click (wxListEvent& ev)
 {
-       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);
-       }
+       ContentList cl;
+       cl.push_back (selected_content ());
+       _menu.popup (cl, ev.GetPoint ());
 }
 
 void
-FilmEditor::audio_mapping_changed (AudioMapping m)
+FilmEditor::three_d_changed ()
 {
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-       
-       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
-       if (!fc) {
+       if (!_film) {
                return;
        }
 
-       /* XXX: should be general to audiocontent */
-       fc->audio_stream()->mapping = m;
+       _film->set_three_d (_three_d->GetValue ());
 }