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 ()
string
VariableFormat::name () const
{
- stringstream s;
- if (!_nickname.empty ()) {
- s << _nickname << " (";
- }
-
- s << "without stretching";
-
- if (!_nickname.empty ()) {
- s << ")";
- }
-
- return s.str ();
+ return _nickname;
}
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 ();
_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 ()));
_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 */
_ignore_changes = Film::NONE;
setup_visibility ();
+ setup_formats ();
}
/** Called when the DCP A/B switch has been toggled */
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);
_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;
}
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 ();
+}
void change_dcp_range_clicked (wxCommandEvent &);
void set_things_sensitive (bool);
-
+ void setup_formats ();
+
wxControl* video_control (wxControl *);
wxControl* still_control (wxControl *);
std::list<wxControl*> _video_controls;
std::list<wxControl*> _still_controls;
+ std::vector<Format const *> _formats;
+
wxSizer* _sizer;
};