diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-12-03 10:12:35 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-12-03 10:12:35 +0000 |
| commit | c008066160d85b9ec9e5485375d7baaa5d27bda2 (patch) | |
| tree | cf2876d69549119bf22761c5f6eccb568242b647 /src/wx | |
| parent | 996fa2194581bf95113b9778849654893c414889 (diff) | |
Hand-apply 6a3cd511559433554ab40ed72ff94b7d8dc2c5bd from master;
Basics of an image sequence dialog that asks about frame rate and
digest calculation.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/content_menu.cc | 6 | ||||
| -rw-r--r-- | src/wx/content_panel.cc | 53 | ||||
| -rw-r--r-- | src/wx/image_sequence_dialog.cc | 55 | ||||
| -rw-r--r-- | src/wx/image_sequence_dialog.h | 34 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
5 files changed, 133 insertions, 16 deletions
diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 3e3c462b2..c528447ac 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -207,7 +207,7 @@ ContentMenu::find_missing () return; } - shared_ptr<Job> j (new ExamineContentJob (film, content)); + shared_ptr<Job> j (new ExamineContentJob (film, content, true)); j->Finished.connect ( bind ( @@ -231,7 +231,7 @@ ContentMenu::re_examine () } for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { - film->examine_content (*i); + film->examine_content (*i, true); } } @@ -269,7 +269,7 @@ ContentMenu::kdm () dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ())))); shared_ptr<Film> film = _film.lock (); assert (film); - film->examine_content (dcp); + film->examine_content (dcp, true); } d->Destroy (); diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 2932ee7c5..4d73a608d 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -35,6 +35,7 @@ #include "subtitle_panel.h" #include "timing_panel.h" #include "timeline_dialog.h" +#include "image_sequence_dialog.h" using std::list; using std::string; @@ -247,7 +248,7 @@ ContentPanel::add_file_clicked () /* XXX: check for lots of files here and do something */ for (unsigned int i = 0; i < paths.GetCount(); ++i) { - _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i]))); + _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i])), true); } d->Destroy (); @@ -257,7 +258,7 @@ void ContentPanel::add_folder_clicked () { wxDirDialog* d = new wxDirDialog (_panel, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST); - int const r = d->ShowModal (); + int r = d->ShowModal (); boost::filesystem::path const path (wx_to_std (d->GetPath ())); d->Destroy (); @@ -265,21 +266,47 @@ ContentPanel::add_folder_clicked () return; } - shared_ptr<Content> content; - - try { - content.reset (new ImageContent (_film, path)); - } catch (...) { + /* Guess if this is a DCP or a set of images: read the first ten filenames and if they + are all valid image files we assume it is a set of images. + */ + + bool is_dcp = false; + int read = 0; + for (boost::filesystem::directory_iterator i(path); i != boost::filesystem::directory_iterator() && read < 10; ++i, ++read) { + if (!boost::filesystem::is_regular_file (i->path()) || !valid_image_file (i->path())) { + is_dcp = true; + } + } + + if (is_dcp) { try { - content.reset (new DCPContent (_film, path)); + shared_ptr<DCPContent> content (new DCPContent (_film, path)); + _film->examine_and_add_content (content, true); } catch (...) { - error_dialog (_panel, _("Could not find any images nor a DCP in that folder")); + error_dialog (_panel, _("Could not find a DCP in that folder.")); + } + } else { + + ImageSequenceDialog* e = new ImageSequenceDialog (_panel); + r = e->ShowModal (); + float const frame_rate = e->frame_rate (); + bool const digest = e->digest (); + e->Destroy (); + + if (r != wxID_OK) { return; } - } - if (content) { - _film->examine_and_add_content (content); + shared_ptr<Content> content; + + try { + shared_ptr<ImageContent> content (new ImageContent (_film, path)); + content->set_video_frame_rate (frame_rate); + _film->examine_and_add_content (content, digest); + } catch (...) { + error_dialog (_panel, _("Could not find any images in that folder")); + return; + } } } @@ -464,6 +491,6 @@ ContentPanel::files_dropped (wxDropFilesEvent& event) wxString* paths = event.GetFiles (); for (int i = 0; i < event.GetNumberOfFiles(); i++) { - _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i]))); + _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i])), true); } } diff --git a/src/wx/image_sequence_dialog.cc b/src/wx/image_sequence_dialog.cc new file mode 100644 index 000000000..930ef8b67 --- /dev/null +++ b/src/wx/image_sequence_dialog.cc @@ -0,0 +1,55 @@ +/* + Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <libdcp/raw_convert.h> +#include "wx_util.h" +#include "image_sequence_dialog.h" + +using libdcp::raw_convert; + +ImageSequenceDialog::ImageSequenceDialog (wxWindow* parent) + : TableDialog (parent, _("Add image sequence"), 2, true) +{ + add (_("Frame rate"), true); + _frame_rate = add (new wxTextCtrl (this, wxID_ANY, N_("24"))); + _digest = new wxCheckBox (this, wxID_ANY, _("Calculate digests")); + _digest->SetValue (true); + _digest->SetToolTip (_("By default DCP-o-matic will calculate digests (hashes) of your image files so that it knows if they change. Turning this off will speed up import but you must not alter the image files after import or strange things may happen.")); + add (_digest); + + layout (); +} + +float +ImageSequenceDialog::frame_rate () const +{ + try { + return raw_convert<float> (wx_to_std (_frame_rate->GetValue ())); + } catch (...) { + + } + + return 0; +} + +bool +ImageSequenceDialog::digest () const +{ + return _digest->GetValue (); +} diff --git a/src/wx/image_sequence_dialog.h b/src/wx/image_sequence_dialog.h new file mode 100644 index 000000000..d3658b7b8 --- /dev/null +++ b/src/wx/image_sequence_dialog.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <wx/wx.h> +#include "table_dialog.h" + +class ImageSequenceDialog : public TableDialog +{ +public: + ImageSequenceDialog (wxWindow* parent); + + float frame_rate () const; + bool digest () const; + +private: + wxTextCtrl* _frame_rate; + wxCheckBox* _digest; +}; diff --git a/src/wx/wscript b/src/wx/wscript index 6a6021c22..6a72f858d 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -18,6 +18,7 @@ sources = """ content_panel.cc content_sub_panel.cc dcp_panel.cc + image_sequence_dialog.cc isdcf_metadata_dialog.cc dir_picker_ctrl.cc dolby_certificate_dialog.cc |
