Split video panel.
authorCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 22:37:30 +0000 (23:37 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 22:37:30 +0000 (23:37 +0100)
13 files changed:
src/wx/audio_panel.cc
src/wx/audio_panel.h
src/wx/film_editor.cc
src/wx/film_editor.h
src/wx/film_editor_panel.h
src/wx/filter_dialog.h
src/wx/subtitle_panel.cc
src/wx/subtitle_panel.h
src/wx/timing_panel.cc
src/wx/timing_panel.h
src/wx/video_panel.cc [new file with mode: 0644]
src/wx/video_panel.h [new file with mode: 0644]
src/wx/wscript

index c27e51b61203e2b092a09e2a5bb661962689064f..b4845233f796fb58792ff5cb274ebee667c392d3 100644 (file)
@@ -111,30 +111,27 @@ AudioPanel::film_changed (Film::Property property)
 }
 
 void
-AudioPanel::film_content_changed (
-       shared_ptr<Content>,
-       shared_ptr<AudioContent> audio_content,
-       shared_ptr<SubtitleContent>,
-       shared_ptr<FFmpegContent> ffmpeg_content,
-       int property
-       )
+AudioPanel::film_content_changed (shared_ptr<Content> c, int property)
 {
+       shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c);
+       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+       
        if (property == AudioContentProperty::AUDIO_GAIN) {
-               checked_set (_gain, audio_content ? audio_content->audio_gain() : 0);
+               checked_set (_gain, ac ? ac->audio_gain() : 0);
        } else if (property == AudioContentProperty::AUDIO_DELAY) {
-               checked_set (_delay, audio_content ? audio_content->audio_delay() : 0);
+               checked_set (_delay, ac ? ac->audio_delay() : 0);
        } else if (property == AudioContentProperty::AUDIO_MAPPING) {
-               _mapping->set (audio_content ? audio_content->audio_mapping () : AudioMapping ());
+               _mapping->set (ac ? ac->audio_mapping () : AudioMapping ());
        } else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
                _stream->Clear ();
-               if (ffmpeg_content) {
-                       vector<shared_ptr<FFmpegAudioStream> > a = ffmpeg_content->audio_streams ();
+               if (fc) {
+                       vector<shared_ptr<FFmpegAudioStream> > a = fc->audio_streams ();
                        for (vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin(); i != a.end(); ++i) {
                                _stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
                        }
                        
-                       if (ffmpeg_content->audio_stream()) {
-                               checked_set (_stream, lexical_cast<string> (ffmpeg_content->audio_stream()->id));
+                       if (fc->audio_stream()) {
+                               checked_set (_stream, lexical_cast<string> (fc->audio_stream()->id));
                        }
                }
                setup_sensitivity ();
index 69f606385dd8bc38b3700f3c1e88dfdddeff25ff..f4a595f3278087d344cf4dd32afaed056c2c1e13 100644 (file)
@@ -32,12 +32,7 @@ public:
        AudioPanel (FilmEditor *);
 
        void film_changed (Film::Property);
-       void film_content_changed (
-               boost::shared_ptr<Content>,
-               boost::shared_ptr<AudioContent>,
-               boost::shared_ptr<SubtitleContent>,
-               boost::shared_ptr<FFmpegContent>,
-               int);
+       void film_content_changed (boost::shared_ptr<Content>, int);
        void content_selection_changed ();
 
        void setup_sensitivity ();
index 94aea9b1a4512bfdcf6e079b3ae76ae6a4687585..ea1afd22092d3dcd5cf71939133d0b25c5a3877a 100644 (file)
@@ -42,7 +42,6 @@
 #include "lib/sound_processor.h"
 #include "lib/scaler.h"
 #include "timecode.h"
-#include "filter_dialog.h"
 #include "wx_util.h"
 #include "film_editor.h"
 #include "dci_metadata_dialog.h"
@@ -50,6 +49,7 @@
 #include "timing_panel.h"
 #include "subtitle_panel.h"
 #include "audio_panel.h"
+#include "video_panel.h"
 
 using std::string;
 using std::cout;
@@ -82,8 +82,6 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
        make_dcp_panel ();
        _main_notebook->AddPage (_dcp_panel, _("DCP"), false);
        
-       setup_ratios ();
-
        set_film (f);
        connect_to_widgets ();
 
@@ -207,18 +205,12 @@ FilmEditor::connect_to_widgets ()
        _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);
-       _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);
-       _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);
@@ -229,68 +221,6 @@ FilmEditor::connect_to_widgets ()
        _sequence_video->Connect         (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::sequence_video_changed), 0, this);
 }
 
-void
-FilmEditor::make_video_panel ()
-{
-       _video_panel = new wxPanel (_content_notebook);
-       wxBoxSizer* video_sizer = new wxBoxSizer (wxVERTICAL);
-       _video_panel->SetSizer (video_sizer);
-       
-       wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
-       video_sizer->Add (grid, 0, wxALL, 8);
-
-       int r = 0;
-       add_label_to_grid_bag_sizer (grid, _video_panel, _("Left crop"), true, 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"), true, 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"), true, 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"), true, wxGBPosition (r, 0));
-       _bottom_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
-       grid->Add (_bottom_crop, wxGBPosition (r, 1));
-       ++r;
-
-       add_label_to_grid_bag_sizer (grid, _video_panel, _("Scale to"), true, wxGBPosition (r, 0));
-       _ratio = new wxChoice (_video_panel, wxID_ANY);
-       grid->Add (_ratio, 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"), true, 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, wxALIGN_CENTER_VERTICAL);
-               grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
-       }
-       ++r;
-
-       _left_crop->SetRange (0, 1024);
-       _top_crop->SetRange (0, 1024);
-       _right_crop->SetRange (0, 1024);
-       _bottom_crop->SetRange (0, 1024);
-}
-
 void
 FilmEditor::make_content_panel ()
 {
@@ -326,61 +256,11 @@ FilmEditor::make_content_panel ()
        _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);
+       _video_panel = new VideoPanel (this);
        _audio_panel = new AudioPanel (this);
        _subtitle_panel = new SubtitlePanel (this);
        _timing_panel = new TimingPanel (this);
 }
-
-/** 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;
-       }
-
-       c->set_left_crop (_left_crop->GetValue ());
-}
-
-/** 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;
-       }
-
-       c->set_right_crop (_right_crop->GetValue ());
-}
-
-/** Called when the top crop widget has been changed */
-void
-FilmEditor::top_crop_changed (wxCommandEvent &)
-{
-       shared_ptr<VideoContent> c = selected_video_content ();
-       if (!c) {
-               return;
-       }
-
-       c->set_top_crop (_top_crop->GetValue ());
-}
-
-/** Called when the bottom crop value has been changed */
-void
-FilmEditor::bottom_crop_changed (wxCommandEvent &)
-{
-       shared_ptr<VideoContent> c = selected_video_content ();
-       if (!c) {
-               return;
-       }
-
-       c->set_bottom_crop (_bottom_crop->GetValue ());
-}
-
 /** Called when the name widget has been changed */
 void
 FilmEditor::name_changed (wxCommandEvent &)
@@ -452,6 +332,7 @@ FilmEditor::film_changed (Film::Property p)
 
        stringstream s;
 
+       _video_panel->film_changed (p);
        _audio_panel->film_changed (p);
        _subtitle_panel->film_changed (p);
        _timing_panel->film_changed (p);
@@ -549,50 +430,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 == 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 == VideoContentProperty::VIDEO_RATIO) {
-               if (video_content) {
-                       int n = 0;
-                       vector<Ratio const *> ratios = Ratio::all ();
-                       vector<Ratio const *>::iterator i = ratios.begin ();
-                       while (i != ratios.end() && *i != video_content->ratio()) {
-                               ++i;
-                               ++n;
-                       }
+       _video_panel->film_content_changed    (content, property);
+       _audio_panel->film_content_changed    (content, property);
+       _subtitle_panel->film_content_changed (content, property);
+       _timing_panel->film_content_changed   (content, property);
 
-                       if (i == ratios.end()) {
-                               checked_set (_ratio, -1);
-                       } else {
-                               checked_set (_ratio, n);
-                       }
-               } else {
-                       checked_set (_ratio, -1);
-               }
-               setup_scaling_description ();
-       } else if (property == FFmpegContentProperty::AUDIO_STREAM) {
+       if (property == FFmpegContentProperty::AUDIO_STREAM) {
                setup_dcp_name ();
-       } else if (property == FFmpegContentProperty::FILTERS) {
-               if (ffmpeg_content) {
-                       pair<string, string> p = Filter::ffmpeg_strings (ffmpeg_content->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 ();
-               }
        }
 }
 
@@ -614,7 +458,7 @@ FilmEditor::setup_container ()
        }
        
        setup_dcp_name ();
-       setup_scaling_description ();
+       _video_panel->setup_scaling_description ();
 }      
 
 /** Called when the container widget has been changed */
@@ -716,26 +560,6 @@ FilmEditor::set_things_sensitive (bool s)
        _best_dcp_frame_rate->Enable (s && _film && _film->best_dcp_video_frame_rate () != _film->dcp_video_frame_rate ());
 }
 
-/** Called when the `Edit filters' button has been clicked */
-void
-FilmEditor::edit_filters_clicked (wxCommandEvent &)
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-
-       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
-       if (!fc) {
-               return;
-       }
-       
-       FilterDialog* d = new FilterDialog (this, fc->filters());
-       d->ActiveChanged.connect (bind (&FFmpegContent::set_filters, fc, _1));
-       d->ShowModal ();
-       d->Destroy ();
-}
-
 /** Called when the scaler widget has been changed */
 void
 FilmEditor::scaler_changed (wxCommandEvent &)
@@ -750,19 +574,6 @@ FilmEditor::scaler_changed (wxCommandEvent &)
        }
 }
 
-void
-FilmEditor::setup_ratios ()
-{
-       _ratios = Ratio::all ();
-
-       _ratio->Clear ();
-       for (vector<Ratio const *>::iterator i = _ratios.begin(); i != _ratios.end(); ++i) {
-               _ratio->Append (std_to_wx ((*i)->nickname ()));
-       }
-
-       _dcp_sizer->Layout ();
-}
-
 void
 FilmEditor::use_dci_name_toggled (wxCommandEvent &)
 {
@@ -972,70 +783,6 @@ FilmEditor::selected_subtitle_content ()
        return dynamic_pointer_cast<SubtitleContent> (c);
 }
 
-void
-FilmEditor::setup_scaling_description ()
-{
-       shared_ptr<VideoContent> vc = selected_video_content ();
-       if (!vc) {
-               _scaling_description->SetLabel ("");
-               return;
-       }
-
-       wxString d;
-
-       int lines = 0;
-
-       if (vc->video_size().width && vc->video_size().height) {
-               d << wxString::Format (
-                       _("Original video is %dx%d (%.2f:1)\n"),
-                       vc->video_size().width, vc->video_size().height,
-                       float (vc->video_size().width) / vc->video_size().height
-                       );
-               ++lines;
-       }
-
-       Crop const crop = vc->crop ();
-       if ((crop.left || crop.right || crop.top || crop.bottom) && vc->video_size() != libdcp::Size (0, 0)) {
-               libdcp::Size cropped = vc->video_size ();
-               cropped.width -= crop.left + crop.right;
-               cropped.height -= crop.top + crop.bottom;
-               d << wxString::Format (
-                       _("Cropped to %dx%d (%.2f:1)\n"),
-                       cropped.width, cropped.height,
-                       float (cropped.width) / cropped.height
-                       );
-               ++lines;
-       }
-
-       Ratio const * ratio = vc->ratio ();
-       if (ratio) {
-               libdcp::Size container_size = _film->container()->size (_film->full_frame ());
-               
-               libdcp::Size const scaled = ratio->size (container_size);
-               d << wxString::Format (
-                       _("Scaled to %dx%d (%.2f:1)\n"),
-                       scaled.width, scaled.height,
-                       float (scaled.width) / scaled.height
-                       );
-               ++lines;
-
-               if (scaled != container_size) {
-                       d << wxString::Format (
-                               _("Padded with black to %dx%d (%.2f:1)\n"),
-                               container_size.width, container_size.height,
-                               float (container_size.width) / container_size.height
-                               );
-                       ++lines;
-               }
-       }
-
-       for (int i = lines; i < 4; ++i) {
-               d << wxT ("\n ");
-       }
-
-       _scaling_description->SetLabel (d);
-}
-
 void
 FilmEditor::content_timeline_clicked (wxCommandEvent &)
 {
@@ -1061,31 +808,6 @@ FilmEditor::set_selection (weak_ptr<Content> wc)
        }
 }
 
-void
-FilmEditor::ratio_changed (wxCommandEvent &)
-{
-       if (!_film) {
-               return;
-       }
-
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-
-       shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (c);
-       if (!vc) {
-               return;
-       }
-       
-       int const n = _ratio->GetSelection ();
-       if (n >= 0) {
-               vector<Ratio const *> ratios = Ratio::all ();
-               assert (n < int (ratios.size()));
-               vc->set_ratio (ratios[n]);
-       }
-}
-
 void
 FilmEditor::sequence_video_changed (wxCommandEvent &)
 {
index ff9198be42a60fc910110ea88b52ca054596097b..751ed0890790ce72d32a7ed4647d219df00ced3d 100644 (file)
@@ -39,6 +39,7 @@ class Timecode;
 class TimingPanel;
 class SubtitlePanel;
 class AudioPanel;
+class VideoPanel;
 
 /** @class FilmEditor
  *  @brief A wx widget to edit a film's metadata, and perform various functions.
@@ -75,31 +76,22 @@ public:
 private:
        void make_dcp_panel ();
        void make_content_panel ();
-       void make_video_panel ();
        void connect_to_widgets ();
        
        /* Handle changes to the view */
        void name_changed (wxCommandEvent &);
        void use_dci_name_toggled (wxCommandEvent &);
        void edit_dci_button_clicked (wxCommandEvent &);
-       void left_crop_changed (wxCommandEvent &);
-       void right_crop_changed (wxCommandEvent &);
-       void top_crop_changed (wxCommandEvent &);
-       void bottom_crop_changed (wxCommandEvent &);
-       void trust_content_headers_changed (wxCommandEvent &);
        void content_selection_changed (wxListEvent &);
        void content_add_clicked (wxCommandEvent &);
        void content_remove_clicked (wxCommandEvent &);
-       void imagemagick_video_length_changed (wxCommandEvent &);
        void container_changed (wxCommandEvent &);
        void dcp_content_type_changed (wxCommandEvent &);
        void scaler_changed (wxCommandEvent &);
        void j2k_bandwidth_changed (wxCommandEvent &);
        void dcp_frame_rate_changed (wxCommandEvent &);
        void best_dcp_frame_rate_clicked (wxCommandEvent &);
-       void edit_filters_clicked (wxCommandEvent &);
        void content_timeline_clicked (wxCommandEvent &);
-       void ratio_changed (wxCommandEvent &);
        void dcp_audio_channels_changed (wxCommandEvent &);
        void dcp_resolution_changed (wxCommandEvent &);
        void sequence_video_changed (wxCommandEvent &);
@@ -110,15 +102,14 @@ private:
        void film_content_changed (boost::weak_ptr<Content>, int);
 
        void set_things_sensitive (bool);
-       void setup_ratios ();
        void setup_dcp_name ();
-       void setup_scaling_description ();
        void setup_content ();
        void setup_container ();
        void setup_content_sensitivity ();
        
        void active_jobs_changed (bool);
 
+       VideoPanel* _video_panel;
        AudioPanel* _audio_panel;
        SubtitlePanel* _subtitle_panel;
        TimingPanel* _timing_panel;
@@ -129,7 +120,6 @@ private:
        wxSizer* _dcp_sizer;
        wxPanel* _content_panel;
        wxSizer* _content_sizer;
-       wxPanel* _video_panel;
 
        /** The film we are editing */
        boost::shared_ptr<Film> _film;
@@ -145,15 +135,6 @@ private:
        wxButton* _content_timeline;
        wxCheckBox* _sequence_video;
        wxButton* _edit_dci_button;
-       wxChoice* _ratio;
-       wxStaticText* _ratio_description;
-       wxStaticText* _scaling_description;
-       wxSpinCtrl* _left_crop;
-       wxSpinCtrl* _right_crop;
-       wxSpinCtrl* _top_crop;
-       wxSpinCtrl* _bottom_crop;
-       wxStaticText* _filters;
-       wxButton* _filters_button;
        wxChoice* _scaler;
        wxSpinCtrl* _j2k_bandwidth;
        wxChoice* _dcp_content_type;
index 1ef4d9fc50f8c842b00a833c70fa2c4c94469414..8bfe94f8d688ffedb00f7724955debf161333786 100644 (file)
@@ -33,12 +33,7 @@ public:
        FilmEditorPanel (FilmEditor *, wxString);
 
        virtual void film_changed (Film::Property) {}
-       virtual void film_content_changed (
-               boost::shared_ptr<Content>,
-               boost::shared_ptr<AudioContent>,
-               boost::shared_ptr<SubtitleContent>,
-               boost::shared_ptr<FFmpegContent>,
-               int) = 0;
+       virtual void film_content_changed (boost::shared_ptr<Content>, int) = 0;
        virtual void content_selection_changed () {}
 
 protected:
index e76f8536bfa3c17c52c6d012bf8ea2535973be2e..6f8b1dd1caf06497c13af4d304d5fa736f7988b4 100644 (file)
@@ -26,6 +26,7 @@
 
 class Film;
 class FilterView;
+class Filter;
 
 /** @class FilterDialog
  *  @brief A dialog to select FFmpeg filters.
index 22e3ae7cc3917c1bab70e37fc0edfb1b0b97045a..e410120221fb5b887f8314cf840fd173135d6058 100644 (file)
@@ -88,33 +88,30 @@ SubtitlePanel::film_changed (Film::Property property)
 }
 
 void
-SubtitlePanel::film_content_changed (
-       shared_ptr<Content>,
-       shared_ptr<AudioContent>,
-       shared_ptr<SubtitleContent> subtitle_content,
-       shared_ptr<FFmpegContent> ffmpeg_content,
-       int property
-       )
+SubtitlePanel::film_content_changed (shared_ptr<Content> c, int property)
 {
+       shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c);
+       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+       
        if (property == FFmpegContentProperty::SUBTITLE_STREAMS) {
                _stream->Clear ();
-               if (ffmpeg_content) {
-                       vector<shared_ptr<FFmpegSubtitleStream> > s = ffmpeg_content->subtitle_streams ();
+               if (fc) {
+                       vector<shared_ptr<FFmpegSubtitleStream> > s = fc->subtitle_streams ();
                        for (vector<shared_ptr<FFmpegSubtitleStream> >::iterator i = s.begin(); i != s.end(); ++i) {
                                _stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
                        }
                        
-                       if (ffmpeg_content->subtitle_stream()) {
-                               checked_set (_stream, lexical_cast<string> (ffmpeg_content->subtitle_stream()->id));
+                       if (fc->subtitle_stream()) {
+                               checked_set (_stream, lexical_cast<string> (fc->subtitle_stream()->id));
                        } else {
                                _stream->SetSelection (wxNOT_FOUND);
                        }
                }
                setup_control_sensitivity ();
        } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET) {
-               checked_set (_offset, subtitle_content ? (subtitle_content->subtitle_offset() * 100) : 0);
+               checked_set (_offset, sc ? (sc->subtitle_offset() * 100) : 0);
        } else if (property == SubtitleContentProperty::SUBTITLE_SCALE) {
-               checked_set (_scale, subtitle_content ? (subtitle_content->subtitle_scale() * 100) : 100);
+               checked_set (_scale, sc ? (sc->subtitle_scale() * 100) : 100);
        }
 
 }
index 98c82b7c5463c7e4ff50225995bbdd45ef4e97cd..ec684d7ad888e37e82ff80169b482a166bcee72b 100644 (file)
@@ -28,12 +28,7 @@ public:
        SubtitlePanel (FilmEditor *);
 
        void film_changed (Film::Property);
-       void film_content_changed (
-               boost::shared_ptr<Content>,
-               boost::shared_ptr<AudioContent>,
-               boost::shared_ptr<SubtitleContent>,
-               boost::shared_ptr<FFmpegContent>,
-               int);
+       void film_content_changed (boost::shared_ptr<Content>, int);
 
        void setup_control_sensitivity ();
        
index 88d6fffbc80ebaea50d489acf40998cc8f99b900..da62aabdfab0c8e88de1f217f2711e28048b99d1 100644 (file)
@@ -45,13 +45,7 @@ TimingPanel::TimingPanel (FilmEditor* e)
 }
 
 void
-TimingPanel::film_content_changed (
-       shared_ptr<Content> content,
-       shared_ptr<AudioContent>,
-       shared_ptr<SubtitleContent>,
-       shared_ptr<FFmpegContent>,
-       int property
-       )
+TimingPanel::film_content_changed (shared_ptr<Content> content, int property)
 {
        if (property == ContentProperty::START) {
                if (content) {
index 0aaabcc659acc51fc2d66f7ccf47a41c5bec6609..b5c9ef026b5130581428cc596d91d5a77ef92e10 100644 (file)
@@ -26,12 +26,7 @@ class TimingPanel : public FilmEditorPanel
 public:
        TimingPanel (FilmEditor *);
 
-       void film_content_changed (
-               boost::shared_ptr<Content>,
-               boost::shared_ptr<AudioContent>,
-               boost::shared_ptr<SubtitleContent>,
-               boost::shared_ptr<FFmpegContent>,
-               int);
+       void film_content_changed (boost::shared_ptr<Content>, int);
        
 private:
        void start_changed ();
diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc
new file mode 100644 (file)
index 0000000..09fa8db
--- /dev/null
@@ -0,0 +1,297 @@
+/*
+    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
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <wx/spinctrl.h>
+#include "lib/ratio.h"
+#include "lib/filter.h"
+#include "filter_dialog.h"
+#include "video_panel.h"
+#include "wx_util.h"
+#include "film_editor.h"
+
+using std::vector;
+using std::string;
+using std::pair;
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
+
+VideoPanel::VideoPanel (FilmEditor* e)
+       : FilmEditorPanel (e, _("Video"))
+{
+       wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+       _sizer->Add (grid, 0, wxALL, 8);
+
+       int r = 0;
+       add_label_to_grid_bag_sizer (grid, this, _("Left crop"), true, wxGBPosition (r, 0));
+       _left_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
+       grid->Add (_left_crop, wxGBPosition (r, 1));
+       ++r;
+
+       add_label_to_grid_bag_sizer (grid, this, _("Right crop"), true, wxGBPosition (r, 0));
+       _right_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
+       grid->Add (_right_crop, wxGBPosition (r, 1));
+       ++r;
+       
+       add_label_to_grid_bag_sizer (grid, this, _("Top crop"), true, wxGBPosition (r, 0));
+       _top_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
+       grid->Add (_top_crop, wxGBPosition (r, 1));
+       ++r;
+       
+       add_label_to_grid_bag_sizer (grid, this, _("Bottom crop"), true, wxGBPosition (r, 0));
+       _bottom_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
+       grid->Add (_bottom_crop, wxGBPosition (r, 1));
+       ++r;
+
+       add_label_to_grid_bag_sizer (grid, this, _("Scale to"), true, wxGBPosition (r, 0));
+       _ratio = new wxChoice (this, wxID_ANY);
+       grid->Add (_ratio, wxGBPosition (r, 1));
+       ++r;
+
+       _scaling_description = new wxStaticText (this, 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;
+
+       {
+               add_label_to_grid_bag_sizer (grid, this, _("Filters"), true, wxGBPosition (r, 0));
+               wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+               _filters = new wxStaticText (this, wxID_ANY, _("None"));
+               s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
+               _filters_button = new wxButton (this, wxID_ANY, _("Edit..."));
+               s->Add (_filters_button, 0, wxALIGN_CENTER_VERTICAL);
+               grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
+       }
+       ++r;
+
+       _left_crop->SetRange (0, 1024);
+       _top_crop->SetRange (0, 1024);
+       _right_crop->SetRange (0, 1024);
+       _bottom_crop->SetRange (0, 1024);
+
+       vector<Ratio const *> ratios = Ratio::all ();
+       _ratio->Clear ();
+       for (vector<Ratio const *>::iterator i = ratios.begin(); i != ratios.end(); ++i) {
+               _ratio->Append (std_to_wx ((*i)->nickname ()));
+       }
+
+       _ratio->Connect          (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,  wxCommandEventHandler (VideoPanel::ratio_changed), 0, this);
+       _left_crop->Connect      (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::left_crop_changed), 0, this);
+       _right_crop->Connect     (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::right_crop_changed), 0, this);
+       _top_crop->Connect       (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::top_crop_changed), 0, this);
+       _bottom_crop->Connect    (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::bottom_crop_changed), 0, this);
+       _filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,   wxCommandEventHandler (VideoPanel::edit_filters_clicked), 0, this);
+}
+
+
+/** Called when the left crop widget has been changed */
+void
+VideoPanel::left_crop_changed (wxCommandEvent &)
+{
+       shared_ptr<VideoContent> c = _editor->selected_video_content ();
+       if (!c) {
+               return;
+       }
+
+       c->set_left_crop (_left_crop->GetValue ());
+}
+
+/** Called when the right crop widget has been changed */
+void
+VideoPanel::right_crop_changed (wxCommandEvent &)
+{
+       shared_ptr<VideoContent> c = _editor->selected_video_content ();
+       if (!c) {
+               return;
+       }
+
+       c->set_right_crop (_right_crop->GetValue ());
+}
+
+/** Called when the top crop widget has been changed */
+void
+VideoPanel::top_crop_changed (wxCommandEvent &)
+{
+       shared_ptr<VideoContent> c = _editor->selected_video_content ();
+       if (!c) {
+               return;
+       }
+
+       c->set_top_crop (_top_crop->GetValue ());
+}
+
+/** Called when the bottom crop value has been changed */
+void
+VideoPanel::bottom_crop_changed (wxCommandEvent &)
+{
+       shared_ptr<VideoContent> c = _editor->selected_video_content ();
+       if (!c) {
+               return;
+       }
+
+       c->set_bottom_crop (_bottom_crop->GetValue ());
+}
+
+void
+VideoPanel::film_content_changed (shared_ptr<Content> c, int property)
+{
+       shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (c);
+       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+       
+       if (property == VideoContentProperty::VIDEO_CROP) {
+               checked_set (_left_crop,   vc ? vc->crop().left : 0);
+               checked_set (_right_crop,  vc ? vc->crop().right        : 0);
+               checked_set (_top_crop,    vc ? vc->crop().top  : 0);
+               checked_set (_bottom_crop, vc ? vc->crop().bottom : 0);
+               setup_scaling_description ();
+       } else if (property == VideoContentProperty::VIDEO_RATIO) {
+               if (vc) {
+                       int n = 0;
+                       vector<Ratio const *> ratios = Ratio::all ();
+                       vector<Ratio const *>::iterator i = ratios.begin ();
+                       while (i != ratios.end() && *i != vc->ratio()) {
+                               ++i;
+                               ++n;
+                       }
+
+                       if (i == ratios.end()) {
+                               checked_set (_ratio, -1);
+                       } else {
+                               checked_set (_ratio, n);
+                       }
+               } else {
+                       checked_set (_ratio, -1);
+               }
+               setup_scaling_description ();
+       } else if (property == FFmpegContentProperty::FILTERS) {
+               if (fc) {
+                       pair<string, string> p = Filter::ffmpeg_strings (fc->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));
+                       }
+               }
+       }
+}
+
+/** Called when the `Edit filters' button has been clicked */
+void
+VideoPanel::edit_filters_clicked (wxCommandEvent &)
+{
+       shared_ptr<Content> c = _editor->selected_content ();
+       if (!c) {
+               return;
+       }
+
+       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+       if (!fc) {
+               return;
+       }
+       
+       FilterDialog* d = new FilterDialog (this, fc->filters());
+       d->ActiveChanged.connect (bind (&FFmpegContent::set_filters, fc, _1));
+       d->ShowModal ();
+       d->Destroy ();
+}
+
+void
+VideoPanel::setup_scaling_description ()
+{
+       shared_ptr<VideoContent> vc = _editor->selected_video_content ();
+       if (!vc) {
+               _scaling_description->SetLabel ("");
+               return;
+       }
+
+       wxString d;
+
+       int lines = 0;
+
+       if (vc->video_size().width && vc->video_size().height) {
+               d << wxString::Format (
+                       _("Original video is %dx%d (%.2f:1)\n"),
+                       vc->video_size().width, vc->video_size().height,
+                       float (vc->video_size().width) / vc->video_size().height
+                       );
+               ++lines;
+       }
+
+       Crop const crop = vc->crop ();
+       if ((crop.left || crop.right || crop.top || crop.bottom) && vc->video_size() != libdcp::Size (0, 0)) {
+               libdcp::Size cropped = vc->video_size ();
+               cropped.width -= crop.left + crop.right;
+               cropped.height -= crop.top + crop.bottom;
+               d << wxString::Format (
+                       _("Cropped to %dx%d (%.2f:1)\n"),
+                       cropped.width, cropped.height,
+                       float (cropped.width) / cropped.height
+                       );
+               ++lines;
+       }
+
+       Ratio const * ratio = vc->ratio ();
+       if (ratio) {
+               libdcp::Size container_size = _editor->film()->container()->size (_editor->film()->full_frame ());
+               
+               libdcp::Size const scaled = ratio->size (container_size);
+               d << wxString::Format (
+                       _("Scaled to %dx%d (%.2f:1)\n"),
+                       scaled.width, scaled.height,
+                       float (scaled.width) / scaled.height
+                       );
+               ++lines;
+
+               if (scaled != container_size) {
+                       d << wxString::Format (
+                               _("Padded with black to %dx%d (%.2f:1)\n"),
+                               container_size.width, container_size.height,
+                               float (container_size.width) / container_size.height
+                               );
+                       ++lines;
+               }
+       }
+
+       for (int i = lines; i < 4; ++i) {
+               d << wxT ("\n ");
+       }
+
+       _scaling_description->SetLabel (d);
+}
+
+
+void
+VideoPanel::ratio_changed (wxCommandEvent &)
+{
+       if (!_editor->film ()) {
+               return;
+       }
+
+       shared_ptr<VideoContent> vc = _editor->selected_video_content ();
+       
+       int const n = _ratio->GetSelection ();
+       if (n >= 0) {
+               vector<Ratio const *> ratios = Ratio::all ();
+               assert (n < int (ratios.size()));
+               vc->set_ratio (ratios[n]);
+       }
+}
diff --git a/src/wx/video_panel.h b/src/wx/video_panel.h
new file mode 100644 (file)
index 0000000..a373f09
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+    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
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "film_editor_panel.h"
+
+class wxChoice;
+class wxStaticText;
+class wxSpinCtrl;
+class wxButton;
+
+class VideoPanel : public FilmEditorPanel
+{
+public:
+       VideoPanel (FilmEditor *);
+
+       void film_content_changed (boost::shared_ptr<Content>, int);
+
+       void setup_scaling_description ();
+       
+private:
+       void left_crop_changed (wxCommandEvent &);
+       void right_crop_changed (wxCommandEvent &);
+       void top_crop_changed (wxCommandEvent &);
+       void bottom_crop_changed (wxCommandEvent &);
+       void edit_filters_clicked (wxCommandEvent &);
+       void ratio_changed (wxCommandEvent &);
+
+       wxChoice* _ratio;
+       wxStaticText* _ratio_description;
+       wxStaticText* _scaling_description;
+       wxSpinCtrl* _left_crop;
+       wxSpinCtrl* _right_crop;
+       wxSpinCtrl* _top_crop;
+       wxSpinCtrl* _bottom_crop;
+       wxStaticText* _filters;
+       wxButton* _filters_button;
+};
index 3e750bb917b642ecb1e39630fe3130a2e348e2e8..18eb46f82aed6b619f2f785cf4a7897a3344b233 100644 (file)
@@ -30,6 +30,7 @@ sources = """
           timeline.cc
           timeline_dialog.cc
           timing_panel.cc
+          video_panel.cc
           wx_util.cc
           wx_ui_signaller.cc
           """