diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-03-31 15:24:38 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-03-31 15:24:38 +0100 |
| commit | 5920000d247ab3ef7fb9ba29c6ba238b323cf909 (patch) | |
| tree | b4ca56096992df06dc2daad9e859165542f9443d /src | |
| parent | 127672223cca569986e35c91265e269ed5a6561c (diff) | |
Allow adding of content.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/imagemagick_content.cc | 25 | ||||
| -rw-r--r-- | src/lib/imagemagick_content.h | 4 | ||||
| -rw-r--r-- | src/lib/sndfile_content.cc | 16 | ||||
| -rw-r--r-- | src/lib/sndfile_content.h | 6 | ||||
| -rw-r--r-- | src/lib/util.cc | 13 | ||||
| -rw-r--r-- | src/lib/util.h | 6 | ||||
| -rw-r--r-- | src/wx/film_editor.cc | 51 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 4 |
8 files changed, 105 insertions, 20 deletions
diff --git a/src/lib/imagemagick_content.cc b/src/lib/imagemagick_content.cc index d0887c0aa..806c8ac5d 100644 --- a/src/lib/imagemagick_content.cc +++ b/src/lib/imagemagick_content.cc @@ -1,2 +1,27 @@ #include "imagemagick_content.h" +#include "compose.hpp" +#include "i18n.h" + +using std::string; + +ImageMagickContent::ImageMagickContent (boost::filesystem::path f) + : Content (f) + , VideoContent (f) +{ + +} + +string +ImageMagickContent::summary () const +{ + return String::compose (_("Image: %1"), file().filename ()); +} + +bool +ImageMagickContent::valid_file (boost::filesystem::path f) +{ + string ext = f.extension().string(); + transform (ext.begin(), ext.end(), ext.begin(), ::tolower); + return (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".bmp"); +} diff --git a/src/lib/imagemagick_content.h b/src/lib/imagemagick_content.h index 985aa0e8d..0dd5baba8 100644 --- a/src/lib/imagemagick_content.h +++ b/src/lib/imagemagick_content.h @@ -4,4 +4,8 @@ class ImageMagickContent : public VideoContent { public: ImageMagickContent (boost::filesystem::path); + + std::string summary () const; + + static bool valid_file (boost::filesystem::path); }; diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc index 8f5b28901..53df4deea 100644 --- a/src/lib/sndfile_content.cc +++ b/src/lib/sndfile_content.cc @@ -5,6 +5,13 @@ using namespace std; +SndfileContent::SndfileContent (boost::filesystem::path f) + : Content (f) + , AudioContent (f) +{ + +} + string SndfileContent::summary () const { @@ -39,3 +46,12 @@ SndfileContent::audio_channel_layout () const return 0; } + +bool +SndfileContent::valid_file (boost::filesystem::path f) +{ + /* XXX: more extensions */ + string ext = f.extension().string(); + transform (ext.begin(), ext.end(), ext.begin(), ::tolower); + return (ext == ".wav" || ext == ".aif" || ext == ".aiff"); +} diff --git a/src/lib/sndfile_content.h b/src/lib/sndfile_content.h index e84617ed3..10cb428a1 100644 --- a/src/lib/sndfile_content.h +++ b/src/lib/sndfile_content.h @@ -3,11 +3,15 @@ class SndfileContent : public AudioContent { public: + SndfileContent (boost::filesystem::path); + std::string summary () const; - /* AudioDecoder */ + /* AudioContent */ int audio_channels () const; ContentAudioFrame audio_length () const; int audio_frame_rate () const; int64_t audio_channel_layout () const; + + static bool valid_file (boost::filesystem::path); }; diff --git a/src/lib/util.cc b/src/lib/util.cc index 024740867..1c020875a 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -878,19 +878,6 @@ video_frames_to_audio_frames (SourceFrame v, float audio_sample_rate, float fram return ((int64_t) v * audio_sample_rate / frames_per_second); } -/** @param f Filename. - * @return true if this file is a still image, false if it is something else. - */ -bool -still_image_file (string f) -{ - string ext = boost::filesystem::path(f).extension().string(); - - transform (ext.begin(), ext.end(), ext.begin(), ::tolower); - - return (ext == N_(".tif") || ext == N_(".tiff") || ext == N_(".jpg") || ext == N_(".jpeg") || ext == N_(".png") || ext == N_(".bmp")); -} - /** @return A pair containing CPU model name and the number of processors */ pair<string, int> cpu_info () diff --git a/src/lib/util.h b/src/lib/util.h index 87274cfff..b8c1e3116 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -106,11 +106,6 @@ struct FrameRateConversion int best_dcp_frame_rate (float); -enum ContentType { - STILL, ///< content is still images - VIDEO ///< content is a video -}; - /** @struct Crop * @brief A description of the crop of an image or video. */ @@ -292,7 +287,6 @@ private: }; extern int64_t video_frames_to_audio_frames (SourceFrame v, float audio_sample_rate, float frames_per_second); -extern bool still_image_file (std::string); extern std::pair<std::string, int> cpu_info (); #endif diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 7dfbf6c50..ce1c1abe8 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -38,6 +38,8 @@ #include "lib/filter.h" #include "lib/config.h" #include "lib/ffmpeg_decoder.h" +#include "lib/imagemagick_content.h" +#include "lib/sndfile_content.h" #include "filter_dialog.h" #include "wx_util.h" #include "film_editor.h" @@ -201,6 +203,10 @@ FilmEditor::connect_to_widgets () _edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this); _format->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this); _trust_content_header->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::trust_content_header_changed), 0, this); + _content_add->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this); + _content_remove->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this); + _content_earlier->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this); + _content_later->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this); _left_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this); _right_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::right_crop_changed), 0, this); _top_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this); @@ -834,6 +840,11 @@ FilmEditor::set_things_sensitive (bool s) _format->Enable (s); _content->Enable (s); _trust_content_header->Enable (s); + _content->Enable (s); + _content_add->Enable (s); + _content_remove->Enable (s); + _content_earlier->Enable (s); + _content_later->Enable (s); _left_crop->Enable (s); _right_crop->Enable (s); _top_crop->Enable (s); @@ -1150,3 +1161,43 @@ FilmEditor::setup_content () } } +void +FilmEditor::content_add_clicked (wxCommandEvent &) +{ + wxFileDialog* d = new wxFileDialog (this); + int const r = d->ShowModal (); + d->Destroy (); + + if (r != wxID_OK) { + return; + } + + boost::filesystem::path p (wx_to_std (d->GetPath())); + + if (ImageMagickContent::valid_file (p)) { + _film->add_content (shared_ptr<ImageMagickContent> (new ImageMagickContent (p))); + } else if (SndfileContent::valid_file (p)) { + _film->add_content (shared_ptr<SndfileContent> (new SndfileContent (p))); + } else { + _film->add_content (shared_ptr<FFmpegContent> (new FFmpegContent (p))); + } + +} + +void +FilmEditor::content_remove_clicked (wxCommandEvent &) +{ + +} + +void +FilmEditor::content_earlier_clicked (wxCommandEvent &) +{ + +} + +void +FilmEditor::content_later_clicked (wxCommandEvent &) +{ + +} diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 6b1d98ea6..52854b894 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -62,6 +62,10 @@ private: void top_crop_changed (wxCommandEvent &); void bottom_crop_changed (wxCommandEvent &); void trust_content_header_changed (wxCommandEvent &); + void content_add_clicked (wxCommandEvent &); + void content_remove_clicked (wxCommandEvent &); + void content_earlier_clicked (wxCommandEvent &); + void content_later_clicked (wxCommandEvent &); void format_changed (wxCommandEvent &); void trim_start_changed (wxCommandEvent &); void trim_end_changed (wxCommandEvent &); |
