Fix merge; other tweaks.
[dcpomatic.git] / src / wx / properties_dialog.cc
index e6c6c9f81bd418d64045b0686b5b4dfea52e732b..61e1f34f0ab1d8513d18a464dae7cd4fb835e5ef 100644 (file)
 #include "properties_dialog.h"
 #include "wx_util.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::stringstream;
+using std::fixed;
+using std::setprecision;
+using boost::shared_ptr;
+using boost::lexical_cast;
 
-PropertiesDialog::PropertiesDialog (wxWindow* parent, Film* film)
+PropertiesDialog::PropertiesDialog (wxWindow* parent, shared_ptr<Film> film)
        : wxDialog (parent, wxID_ANY, _("Film Properties"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
        , _film (film)
 {
@@ -47,21 +51,26 @@ PropertiesDialog::PropertiesDialog (wxWindow* parent, Film* film)
        table->Add (_total_disk, 1, wxALIGN_CENTER_VERTICAL);
 
        add_label_to_sizer (table, this, "Frames already encoded");
-       _encoded = new ThreadedStaticText (this, "calculating...", boost::bind (&PropertiesDialog::frames_already_encoded, this));
+       _encoded = new ThreadedStaticText (this, "counting...", boost::bind (&PropertiesDialog::frames_already_encoded, this));
        table->Add (_encoded, 1, wxALIGN_CENTER_VERTICAL);
-       
-       _frames->SetLabel (std_to_wx (lexical_cast<string> (_film->length ())));
-       double const disk = ((double) Config::instance()->j2k_bandwidth() / 8) * _film->length() / (_film->frames_per_second () * 1073741824);
-       stringstream s;
-       s << fixed << setprecision (1) << disk << "Gb";
-       _disk_for_frames->SetLabel (std_to_wx (s.str ()));
 
-       stringstream t;
-       t << fixed << setprecision (1) << (disk * 2) << "Gb";
-       _total_disk->SetLabel (std_to_wx (t.str ()));
+       if (_film->length()) {
+               _frames->SetLabel (std_to_wx (lexical_cast<string> (_film->length().get())));
+               double const disk = ((double) Config::instance()->j2k_bandwidth() / 8) * _film->length().get() / (_film->frames_per_second () * 1073741824);
+               stringstream s;
+               s << fixed << setprecision (1) << disk << "Gb";
+               _disk_for_frames->SetLabel (std_to_wx (s.str ()));
+               stringstream t;
+               t << fixed << setprecision (1) << (disk * 2) << "Gb";
+               _total_disk->SetLabel (std_to_wx (t.str ()));
+       } else {
+               _frames->SetLabel (_("unknown"));
+               _disk_for_frames->SetLabel (_("unknown"));
+               _total_disk->SetLabel (_("unknown"));
+       }
 
        wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
-       overall_sizer->Add (table, 0, wxALL, 8);
+       overall_sizer->Add (table, 0, wxALL, 6);
        
        wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
        if (buttons) {
@@ -78,12 +87,13 @@ PropertiesDialog::frames_already_encoded () const
        stringstream u;
        try {
                u << _film->encoded_frames ();
-       } catch (thread_interrupted &) {
+       } catch (boost::thread_interrupted &) {
                return "";
        }
        
-       if (_film->length()) {
-               u << " (" << (_film->encoded_frames() * 100 / _film->length()) << "%)";
+       if (_film->dcp_length()) {
+               /* XXX: encoded_frames() should check which frames have been encoded */
+               u << " (" << ((_film->encoded_frames() - _film->dcp_trim_start()) * 100 / _film->dcp_length().get()) << "%)";
        }
        return u.str ();
 }