From d8a19dca28268e3ac92f117d00c1064c0b06515c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 18 Feb 2016 17:42:58 +0000 Subject: [PATCH] Various improvements to the content properties dialogue (including #791). --- ChangeLog | 5 +++ src/lib/audio_content.cc | 45 ++++++++++++++++++++++++-- src/lib/audio_content.h | 2 +- src/lib/content.cc | 10 +++--- src/lib/content.h | 25 ++++++++++++-- src/lib/dcp_content.cc | 2 +- src/lib/dcp_content.h | 2 +- src/lib/ffmpeg_content.cc | 26 ++++++++------- src/lib/ffmpeg_content.h | 2 +- src/lib/single_stream_audio_content.cc | 8 ----- src/lib/single_stream_audio_content.h | 2 -- src/lib/video_content.cc | 8 ++--- src/lib/video_content.h | 2 +- src/wx/content_properties_dialog.cc | 22 ++++++++++--- src/wx/table_dialog.cc | 15 ++++++++- 15 files changed, 130 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e53166e9..dc5c28c11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-02-18 c.hetherington + + * Add some more information to the content properties + dialogue (#791). + 2016-02-17 Carl Hetherington * Store cinema / screen certificates in a separate diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 87a1d1803..c17893c5a 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -296,7 +296,48 @@ AudioContent::audio_channel_names () const } void -AudioContent::add_properties (list >& p) const +AudioContent::add_properties (list& p) const { - p.push_back (make_pair (_("DCP audio frame rate"), raw_convert (resampled_audio_frame_rate ()))); + shared_ptr stream; + if (audio_streams().size() == 1) { + stream = audio_streams().front (); + } + + if (stream) { + p.push_back (UserProperty (_("Audio"), _("Channels"), stream->channels ())); + p.push_back (UserProperty (_("Audio"), _("Content audio frame rate"), stream->frame_rate(), _("Hz"))); + } + + shared_ptr film = _film.lock (); + DCPOMATIC_ASSERT (film); + + FrameRateChange const frc = film->active_frame_rate_change (position ()); + ContentTime const c (full_length(), frc); + + p.push_back ( + UserProperty (_("Length"), _("Full length in video frames at content rate"), c.frames_round(frc.source)) + ); + + if (stream) { + p.push_back ( + UserProperty ( + _("Length"), + _("Full length in audio frames at content rate"), + c.frames_round (stream->frame_rate ()) + ) + ); + } + + p.push_back (UserProperty (_("Audio"), _("DCP frame rate"), resampled_audio_frame_rate ())); + p.push_back (UserProperty (_("Length"), _("Full length in video frames at DCP rate"), c.frames_round (frc.dcp))); + + if (stream) { + p.push_back ( + UserProperty ( + _("Length"), + _("Full length in audio frames at DCP rate"), + c.frames_round (resampled_audio_frame_rate ()) + ) + ); + } } diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h index 95231a7d7..33c52aa73 100644 --- a/src/lib/audio_content.h +++ b/src/lib/audio_content.h @@ -79,7 +79,7 @@ public: protected: - void add_properties (std::list > &) const; + void add_properties (std::list &) const; private: /** Gain to apply to audio in dB */ diff --git a/src/lib/content.cc b/src/lib/content.cc index 2c89f7c34..724cabb6c 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -277,13 +277,11 @@ Content::path_summary () const return s; } -/** @return a list of properties that might be interesting to the user; first string is the property name, - * second is the value. - */ -list > -Content::properties () const +/** @return a list of properties that might be interesting to the user */ +list +Content::user_properties () const { - list > p; + list p; add_properties (p); return p; } diff --git a/src/lib/content.h b/src/lib/content.h index 283889485..d87ae13d7 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -27,6 +27,7 @@ #include "types.h" #include "signaller.h" #include "dcpomatic_time.h" +#include "raw_convert.h" #include #include #include @@ -91,8 +92,6 @@ public: */ virtual std::list reel_split_points () const; - std::list > properties () const; - boost::shared_ptr clone () const; void set_path (boost::filesystem::path); @@ -162,11 +161,31 @@ public: boost::shared_ptr film () const; + class UserProperty + { + public: + template + UserProperty (std::string category_, std::string key_, T value_, std::string unit_ = "") + : category (category_) + , key (key_) + , value (raw_convert (value_)) + , unit (unit_) + {} + + std::string category; + std::string key; + std::string value; + std::string unit; + }; + + std::list user_properties () const; + boost::signals2::signal, int, bool)> Changed; protected: void signal_changed (int); - virtual void add_properties (std::list > &) const {} + + virtual void add_properties (std::list &) const {} boost::weak_ptr _film; diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 84c864d99..8698c4ecd 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -205,7 +205,7 @@ DCPContent::directory () const } void -DCPContent::add_properties (list >& p) const +DCPContent::add_properties (list& p) const { SingleStreamAudioContent::add_properties (p); } diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 78c97bec5..26c1802ba 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -125,7 +125,7 @@ public: bool can_reference_subtitle (std::list &) const; protected: - void add_properties (std::list >& p) const; + void add_properties (std::list& p) const; private: void read_directory (boost::filesystem::path); diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index f2fe06f36..9cd0395f2 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -392,7 +392,7 @@ FFmpegContent::audio_streams () const } void -FFmpegContent::add_properties (list >& p) const +FFmpegContent::add_properties (list& p) const { VideoContent::add_properties (p); AudioContent::add_properties (p); @@ -405,17 +405,21 @@ FFmpegContent::add_properties (list >& p) const case AVCOL_RANGE_UNSPECIFIED: /// TRANSLATORS: this means that the range of pixel values used in this /// file is unknown (not specified in the file). - p.push_back (make_pair (_("Colour range"), _("Unspecified"))); + p.push_back (UserProperty (_("Video"), _("Colour range"), _("Unspecified"))); break; case AVCOL_RANGE_MPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is limited, so that not all possible values are valid. - p.push_back (make_pair (_("Colour range"), String::compose (_("Limited (%1-%2)"), (total - sub) / 2, (total + sub) / 2))); + p.push_back ( + UserProperty ( + _("Video"), _("Colour range"), String::compose (_("Limited (%1-%2)"), (total - sub) / 2, (total + sub) / 2) + ) + ); break; case AVCOL_RANGE_JPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is full, so that all possible pixel values are valid. - p.push_back (make_pair (_("Colour range"), String::compose (_("Full (0-%1)"), total))); + p.push_back (UserProperty (_("Video"), _("Colour range"), String::compose (_("Full (0-%1)"), total))); break; default: DCPOMATIC_ASSERT (false); @@ -425,17 +429,17 @@ FFmpegContent::add_properties (list >& p) const case AVCOL_RANGE_UNSPECIFIED: /// TRANSLATORS: this means that the range of pixel values used in this /// file is unknown (not specified in the file). - p.push_back (make_pair (_("Colour range"), _("Unspecified"))); + p.push_back (UserProperty (_("Video"), _("Colour range"), _("Unspecified"))); break; case AVCOL_RANGE_MPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is limited, so that not all possible values are valid. - p.push_back (make_pair (_("Colour range"), _("Limited"))); + p.push_back (UserProperty (_("Video"), _("Colour range"), _("Limited"))); break; case AVCOL_RANGE_JPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is full, so that all possible pixel values are valid. - p.push_back (make_pair (_("Colour range"), _("Full"))); + p.push_back (UserProperty (_("Video"), _("Colour range"), _("Full"))); break; default: DCPOMATIC_ASSERT (false); @@ -456,7 +460,7 @@ FFmpegContent::add_properties (list >& p) const }; DCPOMATIC_ASSERT (AVCOL_PRI_NB == 10); - p.push_back (make_pair (_("Colour primaries"), primaries[_color_primaries])); + p.push_back (UserProperty (_("Video"), _("Colour primaries"), primaries[_color_primaries])); char const * transfers[] = { _("Unspecified"), @@ -478,7 +482,7 @@ FFmpegContent::add_properties (list >& p) const }; DCPOMATIC_ASSERT (AVCOL_TRC_NB == 16); - p.push_back (make_pair (_("Colour transfer characteristic"), transfers[_color_trc])); + p.push_back (UserProperty (_("Video"), _("Colour transfer characteristic"), transfers[_color_trc])); char const * spaces[] = { _("RGB / sRGB (IEC61966-2-1)"), @@ -495,9 +499,9 @@ FFmpegContent::add_properties (list >& p) const }; DCPOMATIC_ASSERT (AVCOL_SPC_NB == 11); - p.push_back (make_pair (_("Colourspace"), spaces[_colorspace])); + p.push_back (UserProperty (_("Video"), _("Colourspace"), spaces[_colorspace])); if (_bits_per_pixel) { - p.push_back (make_pair (_("Bits per pixel"), raw_convert (_bits_per_pixel.get ()))); + p.push_back (UserProperty (_("Video"), _("Bits per pixel"), raw_convert (_bits_per_pixel.get ()))); } } diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index 8bd84c144..c7dc374fd 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -106,7 +106,7 @@ public: std::list text_subtitles_during (ContentTimePeriod, bool starting) const; protected: - void add_properties (std::list > &) const; + void add_properties (std::list &) const; private: friend struct ffmpeg_pts_offset_test; diff --git a/src/lib/single_stream_audio_content.cc b/src/lib/single_stream_audio_content.cc index b3c74d901..b1291df45 100644 --- a/src/lib/single_stream_audio_content.cc +++ b/src/lib/single_stream_audio_content.cc @@ -85,11 +85,3 @@ SingleStreamAudioContent::audio_streams () const return s; } -void -SingleStreamAudioContent::add_properties (list >& p) const -{ - p.push_back (make_pair (_("Audio channels"), raw_convert (audio_stream()->channels ()))); - p.push_back (make_pair (_("Content audio frame rate"), raw_convert (audio_stream()->frame_rate ()))); - - AudioContent::add_properties (p); -} diff --git a/src/lib/single_stream_audio_content.h b/src/lib/single_stream_audio_content.h index ad4de46ea..7ae6dbaa4 100644 --- a/src/lib/single_stream_audio_content.h +++ b/src/lib/single_stream_audio_content.h @@ -49,8 +49,6 @@ public: void take_from_audio_examiner (boost::shared_ptr); protected: - void add_properties (std::list > &) const; - boost::shared_ptr _audio_stream; }; diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 514ecae2e..0fbcba7e0 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -579,11 +579,11 @@ VideoContent::processing_description () const } void -VideoContent::add_properties (list >& p) const +VideoContent::add_properties (list& p) const { - p.push_back (make_pair (_("Video length"), raw_convert (video_length ()) + " " + _("video frames"))); - p.push_back (make_pair (_("Video size"), raw_convert (video_size().width) + "x" + raw_convert (video_size().height))); - p.push_back (make_pair (_("Video frame rate"), raw_convert (video_frame_rate()) + " " + _("frames per second"))); + p.push_back (UserProperty (_("Video"), _("Length"), raw_convert (video_length ()), _("video frames"))); + p.push_back (UserProperty (_("Video"), _("Size"), raw_convert (video_size().width) + "x" + raw_convert (video_size().height))); + p.push_back (UserProperty (_("Video"), _("Frame rate"), raw_convert (video_frame_rate()), _("frames per second"))); } double diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 0e58bd1b1..f672e37b5 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -174,7 +174,7 @@ public: protected: void take_from_video_examiner (boost::shared_ptr); - void add_properties (std::list > &) const; + void add_properties (std::list &) const; Frame _video_length; /** Video frame rate, or not set if this content should use the DCP's frame rate */ diff --git a/src/wx/content_properties_dialog.cc b/src/wx/content_properties_dialog.cc index 0b9bd0bb8..8920ad913 100644 --- a/src/wx/content_properties_dialog.cc +++ b/src/wx/content_properties_dialog.cc @@ -25,10 +25,12 @@ #include "lib/audio_content.h" #include "lib/single_stream_audio_content.h" #include +#include using std::string; using std::list; using std::pair; +using std::map; using boost::shared_ptr; using boost::dynamic_pointer_cast; @@ -40,10 +42,22 @@ ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr > properties = content->properties (); - for (list >::const_iterator i = properties.begin(); i != properties.end(); ++i) { - add (std_to_wx (i->first), true); - add (new wxStaticText (this, wxID_ANY, std_to_wx (i->second))); + map > grouped; + BOOST_FOREACH (Content::UserProperty i, content->user_properties()) { + if (grouped.find(i.category) == grouped.end()) { + grouped[i.category] = list (); + } + grouped[i.category].push_back (i); + } + + for (map >::const_iterator i = grouped.begin(); i != grouped.end(); ++i) { + add (std_to_wx ("" + i->first + ""), false); + add_spacer (); + + BOOST_FOREACH (Content::UserProperty j, i->second) { + add (std_to_wx (j.key), true); + add (new wxStaticText (this, wxID_ANY, std_to_wx (j.value + " " + j.unit))); + } } layout (); diff --git a/src/wx/table_dialog.cc b/src/wx/table_dialog.cc index 3c5d9d3d5..3f8d10fe1 100644 --- a/src/wx/table_dialog.cc +++ b/src/wx/table_dialog.cc @@ -50,9 +50,22 @@ TableDialog::layout () } void +#ifdef DCPOMATIC_OSX TableDialog::add (wxString text, bool label) +#else +TableDialog::add (wxString text, bool) +#endif { - add_label_to_sizer (_table, this, text, label); + int flags = wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT; +#ifdef __WXOSX__ + if (label) { + flags |= wxALIGN_RIGHT; + t += wxT (":"); + } +#endif + wxStaticText* m = new wxStaticText (this, wxID_ANY, wxT ("")); + m->SetLabelMarkup (text); + _table->Add (m, 0, flags, 6); } void -- 2.30.2