Add basic content information, and some other bits.
authorCarl Hetherington <cth@carlh.net>
Tue, 2 Apr 2013 22:33:46 +0000 (23:33 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 2 Apr 2013 22:33:46 +0000 (23:33 +0100)
src/lib/content.h
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/film.cc
src/lib/imagemagick_content.cc
src/lib/sndfile_content.cc
src/lib/sndfile_content.h
src/lib/video_content.cc
src/lib/video_content.h
src/wx/film_editor.cc
src/wx/film_editor.h

index 3f348ca91c15d824f3b9a72efae101425cc71907..11c7438a66493ee3f4a79fa8344b2df27bf671df 100644 (file)
@@ -41,6 +41,7 @@ public:
        
        virtual void examine (boost::shared_ptr<Film>, boost::shared_ptr<Job>, bool);
        virtual std::string summary () const = 0;
+       virtual std::string information () const = 0;
        virtual void as_xml (xmlpp::Node *) const;
        virtual boost::shared_ptr<Content> clone () const = 0;
        
index 5bff1cecc0768eecdb0f44d5c9c022b0828b16fd..c6344d5671488a294e2465669e32fe83f9f92a12 100644 (file)
@@ -28,6 +28,7 @@
 #include "i18n.h"
 
 using std::string;
+using std::stringstream;
 using std::vector;
 using std::list;
 using boost::shared_ptr;
@@ -162,6 +163,17 @@ FFmpegContent::summary () const
        return String::compose (_("Movie: %1"), file().filename ());
 }
 
+string
+FFmpegContent::information () const
+{
+       stringstream s;
+       
+       s << String::compose (_("%1 frames; %2 frames per second"), video_length(), video_frame_rate()) << "\n";
+       s << VideoContent::information ();
+
+       return s.str ();
+}
+
 void
 FFmpegContent::set_subtitle_stream (FFmpegSubtitleStream s)
 {
index 598ebf4849d7d3eb6ff26af2a5950efd70b036be..3d69a2f994029f38e935d3c57bfc34ecb7f7e3e6 100644 (file)
@@ -86,6 +86,7 @@ public:
        
        void examine (boost::shared_ptr<Film>, boost::shared_ptr<Job>, bool);
        std::string summary () const;
+       std::string information () const;
        void as_xml (xmlpp::Node *) const;
        boost::shared_ptr<Content> clone () const;
 
index d58f7fd53cea1fea535d8fe216441e242f5fad22..f71180157e5c251d2656da8e09df74c0cbbad0f9 100644 (file)
@@ -95,7 +95,7 @@ Film::Film (string d, bool must_exist)
        , _use_dci_name (true)
        , _trust_content_headers (true)
        , _dcp_content_type (0)
-       , _format (0)
+       , _format (Format::from_id ("185"))
        , _scaler (Scaler::from_id ("bicubic"))
        , _trim_start (0)
        , _trim_end (0)
index 5ad94db45f0e5609983d1b99d8e98f0c1500e500..f7c76a34d4a202b04f8f62cf70a73c0c0eac6ba7 100644 (file)
@@ -25,6 +25,7 @@
 #include "i18n.h"
 
 using std::string;
+using std::stringstream;
 using boost::shared_ptr;
 
 ImageMagickContent::ImageMagickContent (boost::filesystem::path f)
index 657e7d519c3b5ac5779b580e6ff40728d5248628..cf7921a93b88b84f9310ea9f6aa3dd8df0db61d3 100644 (file)
@@ -27,6 +27,12 @@ SndfileContent::summary () const
        return String::compose (_("Sound file: %1"), file().filename ());
 }
 
+string
+SndfileContent::information () const
+{
+       return "";
+}
+
 int
 SndfileContent::audio_channels () const
 {
index 81a964ec8a1d909875139aab465b828b72bdb467..ab8a04e4d96baee9949daa3fbfbe9dd141567805 100644 (file)
@@ -11,6 +11,7 @@ public:
        SndfileContent (boost::shared_ptr<const cxml::Node>);
        
        std::string summary () const;
+       std::string information () const;
        boost::shared_ptr<Content> clone () const;
 
         /* AudioContent */
index f48813f601a84086a83373b519054a584d51bc96..edb713466237384928c96f81483c04baa4fca9dc 100644 (file)
@@ -2,11 +2,15 @@
 #include "video_content.h"
 #include "video_decoder.h"
 
+#include "i18n.h"
+
 int const VideoContentProperty::VIDEO_LENGTH = 0;
 int const VideoContentProperty::VIDEO_SIZE = 1;
 int const VideoContentProperty::VIDEO_FRAME_RATE = 2;
 
 using std::string;
+using std::stringstream;
+using std::setprecision;
 using boost::shared_ptr;
 using boost::lexical_cast;
 
@@ -61,3 +65,19 @@ VideoContent::take_from_video_decoder (shared_ptr<VideoDecoder> d)
         Changed (VideoContentProperty::VIDEO_SIZE);
         Changed (VideoContentProperty::VIDEO_FRAME_RATE);
 }
+
+
+string
+VideoContent::information () const
+{
+       stringstream s;
+
+       s << String::compose (
+               _("%1x%2 pixels (%3:1)"),
+               video_size().width,
+               video_size().height,
+               setprecision (3), float (video_size().width) / video_size().height
+               );
+       
+       return s.str ();
+}
index 25cb289384fad94d3ad3374ef30e50ae687f9272..19b49e926c581168eec493529b91cff94bce5a97 100644 (file)
@@ -22,6 +22,7 @@ public:
        VideoContent (VideoContent const &);
 
        void as_xml (xmlpp::Node *) const;
+       virtual std::string information () const;
 
        ContentVideoFrame video_length () const {
                boost::mutex::scoped_lock lm (_mutex);
index 67ebf49d088e410686ab032fa2e6ecca2df95399..d354e6e5ae04cecaf71533430cc5e0c25c27922e 100644 (file)
@@ -331,11 +331,6 @@ FilmEditor::make_content_panel ()
        _content_sizer = new wxBoxSizer (wxVERTICAL);
        _content_panel->SetSizer (_content_sizer);
        
-       wxGridBagSizer* grid = new wxGridBagSizer (4, 4);
-       _content_sizer->Add (grid, 0, wxALL, 8);
-
-       int r = 0;
-
         {
                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
                 
@@ -357,9 +352,11 @@ FilmEditor::make_content_panel ()
 
                 s->Add (b, 0, wxALL, 4);
 
-                grid->Add (s, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND);
-               ++r;
+                _content_sizer->Add (s, 1, wxEXPAND | wxALL, 6);
         }
+
+       _content_information = new wxTextCtrl (_content_panel, wxID_ANY, wxT ("\n\n\n\n"), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_MULTILINE);
+       _content_sizer->Add (_content_information, 1, wxEXPAND | wxALL, 6);
 }
 
 void
@@ -585,35 +582,18 @@ FilmEditor::film_changed (Film::Property p)
        case Film::CONTENT:
                setup_content ();
                setup_formats ();
+               setup_format ();
                setup_subtitle_control_sensitivity ();
                setup_streams ();
                setup_show_audio_sensitivity ();
+               setup_length ();
                break;
        case Film::TRUST_CONTENT_HEADERS:
                checked_set (_trust_content_headers, _film->trust_content_headers ());
                break;
        case Film::FORMAT:
-       {
-               int n = 0;
-               vector<Format const *>::iterator i = _formats.begin ();
-               while (i != _formats.end() && *i != _film->format ()) {
-                       ++i;
-                       ++n;
-               }
-               if (i == _formats.end()) {
-                       checked_set (_format, -1);
-               } else {
-                       checked_set (_format, n);
-               }
-               setup_dcp_name ();
-
-               if (_film->format ()) {
-                       _format_description->SetLabel (std_to_wx (_film->format()->description ()));
-               } else {
-                       _format_description->SetLabel (wxT (""));
-               }
+               setup_format ();
                break;
-       }
        case Film::CROP:
                checked_set (_left_crop, _film->crop().left);
                checked_set (_right_crop, _film->crop().right);
@@ -737,22 +717,51 @@ FilmEditor::film_content_changed (int p)
                setup_streams ();
                setup_show_audio_sensitivity ();
        } else if (p == VideoContentProperty::VIDEO_LENGTH) {
-               stringstream s;
-               if (_film->video_frame_rate() > 0 && _film->video_length()) {
-                       s << _film->video_length() << " "
-                         << wx_to_std (_("frames")) << "; " << seconds_to_hms (_film->video_length() / _film->video_frame_rate());
-               } else if (_film->video_length()) {
-                       s << _film->video_length() << " "
-                         << wx_to_std (_("frames"));
-               } 
-               _length->SetLabel (std_to_wx (s.str ()));
-               if (_film->video_length()) {
-                       _trim_start->SetRange (0, _film->video_length());
-                       _trim_end->SetRange (0, _film->video_length());
-               }
+               setup_length ();
        }
 }
 
+void
+FilmEditor::setup_format ()
+{
+       int n = 0;
+       vector<Format const *>::iterator i = _formats.begin ();
+       while (i != _formats.end() && *i != _film->format ()) {
+               ++i;
+               ++n;
+       }
+       if (i == _formats.end()) {
+               checked_set (_format, -1);
+       } else {
+               checked_set (_format, n);
+       }
+       setup_dcp_name ();
+       
+       if (_film->format ()) {
+               _format_description->SetLabel (std_to_wx (_film->format()->description ()));
+       } else {
+               _format_description->SetLabel (wxT (""));
+       }
+}      
+
+void
+FilmEditor::setup_length ()
+{
+       stringstream s;
+       if (_film->video_frame_rate() > 0 && _film->video_length()) {
+               s << _film->video_length() << " "
+                 << wx_to_std (_("frames")) << "; " << seconds_to_hms (_film->video_length() / _film->video_frame_rate());
+       } else if (_film->video_length()) {
+               s << _film->video_length() << " "
+                 << wx_to_std (_("frames"));
+       } 
+       _length->SetLabel (std_to_wx (s.str ()));
+       if (_film->video_length()) {
+               _trim_start->SetRange (0, _film->video_length());
+               _trim_end->SetRange (0, _film->video_length());
+       }
+}      
+
 
 /** Called when the format widget has been changed */
 void
@@ -1227,6 +1236,16 @@ void
 FilmEditor::content_item_selected (wxListEvent &)
 {
         setup_content_button_sensitivity ();
+
+       int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+       if (s == -1) {
+               _content_information->SetValue ("");
+               return;
+       }
+
+       ContentList c = _film->content ();
+       assert (s >= 0 && size_t (s) < c.size ());
+       _content_information->SetValue (std_to_wx (c[s]->information ()));
 }
 
 void
index e01ab8ccc92453dbaa681585f5f103ae78b247e9..311f8ceaadbb4cd2faae89092fb5ddd05b21ea3d 100644 (file)
@@ -104,6 +104,8 @@ private:
        void setup_show_audio_sensitivity ();
        void setup_content ();
        void setup_content_button_sensitivity ();
+       void setup_length ();
+       void setup_format ();
        
        void active_jobs_changed (bool);
 
@@ -130,6 +132,7 @@ private:
        wxButton* _content_remove;
        wxButton* _content_earlier;
        wxButton* _content_later;
+       wxTextCtrl* _content_information;
        wxButton* _edit_dci_button;
        wxChoice* _format;
        wxStaticText* _format_description;