#include <boost/thread.hpp>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
-#include "lib/format.h"
#include "lib/film.h"
#include "lib/transcode_job.h"
#include "lib/exceptions.h"
-#include "lib/ab_transcode_job.h"
#include "lib/job_manager.h"
#include "lib/filter.h"
+#include "lib/ratio.h"
#include "lib/config.h"
-#include "lib/ffmpeg_decoder.h"
#include "lib/imagemagick_content.h"
#include "lib/sndfile_content.h"
#include "lib/dcp_content_type.h"
#include "imagemagick_content_dialog.h"
#include "timeline_dialog.h"
#include "audio_mapping_view.h"
-#include "container.h"
#include "timecode.h"
using std::string;
make_dcp_panel ();
_main_notebook->AddPage (_dcp_panel, _("DCP"), false);
- setup_formats ();
+ setup_ratios ();
set_film (f);
connect_to_widgets ();
_scaler->Append (std_to_wx ((*i)->name()));
}
- vector<Container const *> const co = Container::all ();
- for (vector<Container const *>::const_iterator i = co.begin(); i != co.end(); ++i) {
- _container->Append (std_to_wx ((*i)->name ()));
+ vector<Ratio const *> const ratio = Ratio::all ();
+ for (vector<Ratio const *>::const_iterator i = ratio.begin(); i != ratio.end(); ++i) {
+ _container->Append (std_to_wx ((*i)->nickname ()));
}
vector<DCPContentType const *> const ct = DCPContentType::all ();
_use_dci_name->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::use_dci_name_toggled), 0, this);
_edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this);
_container->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::container_changed), 0, this);
-// _format->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this);
+ _ratio->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::ratio_changed), 0, this);
_content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler (FilmEditor::content_selection_changed), 0, this);
_content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler (FilmEditor::content_selection_changed), 0, this);
_content_add->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this);
_audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
_audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this);
_subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this);
- _audio_mapping->Changed.connect (bind (&FilmEditor::audio_mapping_changed, this, _1));
+ _audio_mapping->Changed.connect (boost::bind (&FilmEditor::audio_mapping_changed, this, _1));
+ _start->Changed.connect (boost::bind (&FilmEditor::start_changed, this));
+ _length->Changed.connect (boost::bind (&FilmEditor::length_changed, this));
}
void
++r;
add_label_to_grid_bag_sizer (grid, _video_panel, _("Scale to"), wxGBPosition (r, 0));
- _format = new wxChoice (_video_panel, wxID_ANY);
- grid->Add (_format, wxGBPosition (r, 1));
+ _ratio = new wxChoice (_video_panel, wxID_ANY);
+ grid->Add (_ratio, wxGBPosition (r, 1));
++r;
_scaling_description = new wxStaticText (_video_panel, wxID_ANY, wxT ("\n \n \n \n"), wxDefaultPosition, wxDefaultSize);
break;
case Film::CONTENT:
setup_content ();
- setup_formats ();
-// setup_format ();
setup_subtitle_control_sensitivity ();
setup_show_audio_sensitivity ();
break;
} else {
_start->set (0, 24);
}
-
+ } else if (property == ContentProperty::LENGTH) {
+ if (content) {
+ _length->set (content->length (), _film->dcp_video_frame_rate ());
+ } else {
+ _length->set (0, 24);
+ }
} else if (property == VideoContentProperty::VIDEO_CROP) {
checked_set (_left_crop, video_content ? video_content->crop().left : 0);
checked_set (_right_crop, video_content ? video_content->crop().right : 0);
checked_set (_top_crop, video_content ? video_content->crop().top : 0);
checked_set (_bottom_crop, video_content ? video_content->crop().bottom : 0);
setup_scaling_description ();
+ } else if (property == VideoContentProperty::VIDEO_RATIO) {
+ if (video_content) {
+ int n = 0;
+ vector<Ratio const *> ratios = Ratio::all ();
+ vector<Ratio const *>::iterator i = ratios.begin ();
+ while (i != ratios.end() && *i != video_content->ratio()) {
+ ++i;
+ ++n;
+ }
+
+ if (i == ratios.end()) {
+ checked_set (_ratio, -1);
+ } else {
+ checked_set (_ratio, n);
+ }
+ } else {
+ checked_set (_ratio, -1);
+ }
} else if (property == AudioContentProperty::AUDIO_GAIN) {
checked_set (_audio_gain, audio_content ? audio_content->audio_gain() : 0);
} else if (property == AudioContentProperty::AUDIO_DELAY) {
FilmEditor::setup_container ()
{
int n = 0;
- vector<Container const *> containers = Container::all ();
- vector<Container const *>::iterator i = containers.begin ();
- while (i != containers.end() && *i != _film->container ()) {
+ vector<Ratio const *> ratios = Ratio::all ();
+ vector<Ratio const *>::iterator i = ratios.begin ();
+ while (i != ratios.end() && *i != _film->container ()) {
++i;
++n;
}
- if (i == containers.end()) {
+ if (i == ratios.end()) {
checked_set (_container, -1);
} else {
checked_set (_container, n);
int const n = _container->GetSelection ();
if (n >= 0) {
- vector<Container const *> containers = Container::all ();
- assert (n < int (containers.size()));
- _film->set_container (containers[n]);
+ vector<Ratio const *> ratios = Ratio::all ();
+ assert (n < int (ratios.size()));
+ _film->set_container (ratios[n]);
}
}
FileChanged ("");
}
- if (_audio_dialog) {
- _audio_dialog->set_film (_film);
- }
-
film_changed (Film::NAME);
film_changed (Film::USE_DCI_NAME);
film_changed (Film::CONTENT);
film_changed (Film::DCI_METADATA);
film_changed (Film::DCP_VIDEO_FRAME_RATE);
- film_content_changed (boost::shared_ptr<Content> (), ContentProperty::START);
- film_content_changed (boost::shared_ptr<Content> (), VideoContentProperty::VIDEO_CROP);
- film_content_changed (boost::shared_ptr<Content> (), AudioContentProperty::AUDIO_GAIN);
- film_content_changed (boost::shared_ptr<Content> (), AudioContentProperty::AUDIO_DELAY);
- film_content_changed (boost::shared_ptr<Content> (), AudioContentProperty::AUDIO_MAPPING);
- film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::SUBTITLE_STREAMS);
- film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::SUBTITLE_STREAM);
- film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::AUDIO_STREAMS);
- film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::AUDIO_STREAM);
- film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::FILTERS);
+ wxListEvent ev;
+ content_selection_changed (ev);
}
/** Updates the sensitivity of lots of widgets to a given value.
_name->Enable (s);
_use_dci_name->Enable (s);
_edit_dci_button->Enable (s);
- _format->Enable (s);
- _content->Enable (s);
+ _ratio->Enable (s);
_content->Enable (s);
_left_crop->Enable (s);
_right_crop->Enable (s);
_audio_gain_calculate_button->Enable (s);
_show_audio->Enable (s);
_audio_delay->Enable (s);
+ _container->Enable (s);
+ _loop_content->Enable (s);
+ _loop_count->Enable (s);
setup_subtitle_control_sensitivity ();
setup_show_audio_sensitivity ();
}
void
-FilmEditor::setup_formats ()
+FilmEditor::setup_ratios ()
{
- _formats = Format::all ();
+ _ratios = Ratio::all ();
- _format->Clear ();
- for (vector<Format const *>::iterator i = _formats.begin(); i != _formats.end(); ++i) {
- _format->Append (std_to_wx ((*i)->name ()));
+ _ratio->Clear ();
+ for (vector<Ratio const *>::iterator i = _ratios.begin(); i != _ratios.end(); ++i) {
+ _ratio->Append (std_to_wx ((*i)->nickname ()));
}
_dcp_sizer->Layout ();
_audio_dialog->Destroy ();
_audio_dialog = 0;
}
+
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return;
+ }
+
+ shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c);
+ if (!ac) {
+ return;
+ }
_audio_dialog = new AudioDialog (this);
_audio_dialog->Show ();
- _audio_dialog->set_film (_film);
+ _audio_dialog->set_content (ac);
}
void
}
if (selected_summary.empty () && !content.empty ()) {
- /* Select the item of content if non was selected before */
+ /* Select the item of content if none was selected before */
_content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
}
for (unsigned int i = 0; i < paths.GetCount(); ++i) {
boost::filesystem::path p (wx_to_std (paths[i]));
+ shared_ptr<Content> c;
+
if (ImageMagickContent::valid_file (p)) {
- _film->add_content (shared_ptr<ImageMagickContent> (new ImageMagickContent (_film, p)));
+ c.reset (new ImageMagickContent (_film, p));
} else if (SndfileContent::valid_file (p)) {
- _film->add_content (shared_ptr<SndfileContent> (new SndfileContent (_film, p)));
+ c.reset (new SndfileContent (_film, p));
} else {
- _film->add_content (shared_ptr<FFmpegContent> (new FFmpegContent (_film, p)));
+ c.reset (new FFmpegContent (_film, p));
}
+
+ _film->examine_and_add_content (c);
}
}
{
setup_content_sensitivity ();
shared_ptr<Content> s = selected_content ();
+
+ if (_audio_dialog && s && dynamic_pointer_cast<AudioContent> (s)) {
+ _audio_dialog->set_content (dynamic_pointer_cast<AudioContent> (s));
+ }
+
film_content_changed (s, ContentProperty::START);
+ film_content_changed (s, ContentProperty::LENGTH);
film_content_changed (s, VideoContentProperty::VIDEO_CROP);
+ film_content_changed (s, VideoContentProperty::VIDEO_RATIO);
film_content_changed (s, AudioContentProperty::AUDIO_GAIN);
film_content_changed (s, AudioContentProperty::AUDIO_DELAY);
film_content_changed (s, AudioContentProperty::AUDIO_MAPPING);
_video_panel->Enable (selection && dynamic_pointer_cast<VideoContent> (selection) && _generally_sensitive);
_audio_panel->Enable (selection && dynamic_pointer_cast<AudioContent> (selection) && _generally_sensitive);
_subtitle_panel->Enable (selection && dynamic_pointer_cast<FFmpegContent> (selection) && _generally_sensitive);
+ _timing_panel->Enable (selection && _generally_sensitive);
}
shared_ptr<Content>
ac->set_audio_mapping (m);
}
+
+void
+FilmEditor::start_changed ()
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return;
+ }
+
+ c->set_start (_start->get (_film->dcp_video_frame_rate ()));
+}
+
+void
+FilmEditor::length_changed ()
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return;
+ }
+
+ shared_ptr<ImageMagickContent> ic = dynamic_pointer_cast<ImageMagickContent> (c);
+ if (ic) {
+ ic->set_video_length (_length->get(_film->dcp_video_frame_rate()) * ic->video_frame_rate() / TIME_HZ);
+ }
+}
+
+void
+FilmEditor::set_selection (weak_ptr<Content> wc)
+{
+ Playlist::ContentList content = _film->content ();
+ for (size_t i = 0; i < content.size(); ++i) {
+ if (content[i] == wc.lock ()) {
+ _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+ } else {
+ _content->SetItemState (i, 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
+ }
+ }
+}
+
+void
+FilmEditor::ratio_changed (wxCommandEvent &)
+{
+ if (!_film) {
+ return;
+ }
+
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return;
+ }
+
+ shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (c);
+ if (!vc) {
+ return;
+ }
+
+ int const n = _ratio->GetSelection ();
+ if (n >= 0) {
+ vector<Ratio const *> ratios = Ratio::all ();
+ assert (n < int (ratios.size()));
+ vc->set_ratio (ratios[n]);
+ }
+}