Remove unused variable.
[dcpomatic.git] / src / wx / film_editor.cc
index f35996644dd71d8c30f1c5e06b9a2618a7911f22..3b26a5537e3bf3327f80e42bb048bcb20e9e065c 100644 (file)
@@ -132,7 +132,7 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent)
 
        video_control (add_label_to_sizer (_sizer, this, "Frames Per Second"));
        _frames_per_second = new wxStaticText (this, wxID_ANY, wxT (""));
-       _sizer->Add (video_control (_frames_per_second));
+       _sizer->Add (video_control (_frames_per_second), 1, wxALIGN_CENTER_VERTICAL);
        
        video_control (add_label_to_sizer (_sizer, this, "Original Size"));
        _original_size = new wxStaticText (this, wxID_ANY, wxT (""));
@@ -182,11 +182,6 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent)
        _audio_delay->SetRange (-1000, 1000);
        _still_duration->SetRange (0, 60 * 60);
 
-       vector<Format const *> fmt = Format::all ();
-       for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
-               _format->Append (std_to_wx ((*i)->name ()));
-       }
-
        vector<DCPContentType const *> const ct = DCPContentType::all ();
        for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
                _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
@@ -221,6 +216,7 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent)
        _change_dcp_range_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::change_dcp_range_clicked), 0, this);
 
        setup_visibility ();
+       setup_formats ();
 }
 
 /** Called when the left crop widget has been changed */
@@ -289,14 +285,13 @@ FilmEditor::content_changed (wxCommandEvent &)
                _film->set_content (wx_to_std (_content->GetPath ()));
        } catch (std::exception& e) {
                _content->SetPath (std_to_wx (_film->directory ()));
-               stringstream m;
-               m << "Could not set content: " << e.what() << ".";
-               error_dialog (this, m.str ());
+               error_dialog (this, String::compose ("Could not set content: %1", e.what ()));
        }
 
        _ignore_changes = Film::NONE;
 
        setup_visibility ();
+       setup_formats ();
 }
 
 /** Called when the DCP A/B switch has been toggled */
@@ -344,10 +339,19 @@ FilmEditor::film_changed (Film::Property p)
        case Film::CONTENT:
                _content->SetPath (std_to_wx (_film->content ()));
                setup_visibility ();
+               setup_formats ();
                break;
        case Film::FORMAT:
-               _format->SetSelection (Format::as_index (_film->format ()));
+       {
+               int n = 0;
+               vector<Format const *>::iterator i = _formats.begin ();
+               while (i != _formats.end() && *i != _film->format ()) {
+                       ++i;
+                       ++n;
+               }
+               _format->SetSelection (n);
                break;
+       }
        case Film::CROP:
                _left_crop->SetValue (_film->crop().left);
                _right_crop->SetValue (_film->crop().right);
@@ -447,7 +451,8 @@ FilmEditor::format_changed (wxCommandEvent &)
        _ignore_changes = Film::FORMAT;
        int const n = _format->GetSelection ();
        if (n >= 0) {
-               _film->set_format (Format::from_index (n));
+               assert (n < int (_formats.size()));
+               _film->set_format (_formats[n]);
        }
        _ignore_changes = Film::NONE;
 }
@@ -648,11 +653,52 @@ 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 ()
+{
+       ContentType c = VIDEO;
+
+       if (_film) {
+               c = _film->content_type ();
+       }
+       
+       _formats.clear ();
+
+       vector<Format const *> fmt = Format::all ();
+       for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
+               if (c == VIDEO && dynamic_cast<FixedFormat const *> (*i)) {
+                       _formats.push_back (*i);
+               } else if (c == STILL && dynamic_cast<VariableFormat const *> (*i)) {
+                       _formats.push_back (*i);
+               }
+       }
+
+       _format->Clear ();
+       for (vector<Format const *>::iterator i = _formats.begin(); i != _formats.end(); ++i) {
+               _format->Append (std_to_wx ((*i)->name ()));
+       }
+
+       _sizer->Layout ();
+}