diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-08 00:20:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-08 00:20:10 +0100 |
| commit | d7801f3fe5a5ac46aa2c512bcd00be2bee39ed17 (patch) | |
| tree | fcffa66cf84fb08c55e5547c5551d604df03dcec /src | |
| parent | 7c798f9e215282afb078da53b1d41d4c99e11f5d (diff) | |
Present fixed formats with video content and variable formats with stills.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/format.cc | 41 | ||||
| -rw-r--r-- | src/lib/format.h | 2 | ||||
| -rw-r--r-- | src/wx/film_editor.cc | 49 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 5 |
4 files changed, 47 insertions, 50 deletions
diff --git a/src/lib/format.cc b/src/lib/format.cc index 115e03691..aaf5211f9 100644 --- a/src/lib/format.cc +++ b/src/lib/format.cc @@ -123,34 +123,6 @@ Format::from_metadata (string m) return from_id (m); } -/** @param f A Format. - * @return Index of f within our static list, or -1. - */ -int -Format::as_index (Format const * f) -{ - vector<Format*>::size_type i = 0; - while (i < _formats.size() && _formats[i] != f) { - ++i; - } - - if (i == _formats.size ()) { - return -1; - } - - return i; -} - -/** @param i An index returned from as_index(). - * @return Corresponding Format. - */ -Format const * -Format::from_index (int i) -{ - assert (i >= 0 && i < int(_formats.size ())); - return _formats[i]; -} - /** @return All available formats */ vector<Format const *> Format::all () @@ -205,16 +177,5 @@ VariableFormat::ratio_as_float (Film const * f) const string VariableFormat::name () const { - stringstream s; - if (!_nickname.empty ()) { - s << _nickname << " ("; - } - - s << "without stretching"; - - if (!_nickname.empty ()) { - s << ")"; - } - - return s.str (); + return _nickname; } diff --git a/src/lib/format.h b/src/lib/format.h index 6172dc57d..fd6cdbece 100644 --- a/src/lib/format.h +++ b/src/lib/format.h @@ -71,9 +71,7 @@ public: static Format const * from_nickname (std::string n); static Format const * from_metadata (std::string m); - static Format const * from_index (int i); static Format const * from_id (std::string i); - static int as_index (Format const * f); static std::vector<Format const *> all (); static void setup_formats (); diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 9171daa5c..3b26a5537 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -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 */ @@ -295,6 +291,7 @@ FilmEditor::content_changed (wxCommandEvent &) _ignore_changes = Film::NONE; setup_visibility (); + setup_formats (); } /** Called when the DCP A/B switch has been toggled */ @@ -342,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); @@ -445,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; } @@ -667,3 +674,31 @@ FilmEditor::audio_gain_calculate_button_clicked (wxCommandEvent &) 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 (); +} diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index ac9a5fb31..c599cd285 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -68,7 +68,8 @@ private: void change_dcp_range_clicked (wxCommandEvent &); void set_things_sensitive (bool); - + void setup_formats (); + wxControl* video_control (wxControl *); wxControl* still_control (wxControl *); @@ -125,5 +126,7 @@ private: std::list<wxControl*> _video_controls; std::list<wxControl*> _still_controls; + std::vector<Format const *> _formats; + wxSizer* _sizer; }; |
