#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");
+}
{
public:
ImageMagickContent (boost::filesystem::path);
+
+ std::string summary () const;
+
+ static bool valid_file (boost::filesystem::path);
};
using namespace std;
+SndfileContent::SndfileContent (boost::filesystem::path f)
+ : Content (f)
+ , AudioContent (f)
+{
+
+}
+
string
SndfileContent::summary () 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");
+}
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);
};
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 ()
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.
*/
};
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
#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"
_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);
_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);
}
}
+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 &)
+{
+
+}
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 &);