-/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
-
/*
Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
#include "timeline_dialog.h"
#include "audio_mapping_view.h"
#include "container.h"
+#include "timecode.h"
using std::string;
using std::cout;
FilmEditor::make_video_panel ()
{
_video_panel = new wxPanel (_content_notebook);
- _video_sizer = new wxBoxSizer (wxVERTICAL);
- _video_panel->SetSizer (_video_sizer);
+ wxBoxSizer* video_sizer = new wxBoxSizer (wxVERTICAL);
+ _video_panel->SetSizer (video_sizer);
wxGridBagSizer* grid = new wxGridBagSizer (4, 4);
- _video_sizer->Add (grid, 0, wxALL, 8);
+ video_sizer->Add (grid, 0, wxALL, 8);
int r = 0;
- add_label_to_grid_bag_sizer (grid, _video_panel, _("Format"), wxGBPosition (r, 0));
- _format = new wxChoice (_video_panel, wxID_ANY);
- grid->Add (_format, wxGBPosition (r, 1));
- ++r;
-
add_label_to_grid_bag_sizer (grid, _video_panel, _("Left crop"), wxGBPosition (r, 0));
_left_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
grid->Add (_left_crop, wxGBPosition (r, 1));
grid->Add (_bottom_crop, wxGBPosition (r, 1));
++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));
+ ++r;
+
_scaling_description = new wxStaticText (_video_panel, wxID_ANY, wxT ("\n \n \n \n"), wxDefaultPosition, wxDefaultSize);
grid->Add (_scaling_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
wxFont font = _scaling_description->GetFont();
_content_notebook = new wxNotebook (_content_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_LEFT);
_content_sizer->Add (_content_notebook, 1, wxEXPAND | wxTOP, 6);
-
+
make_video_panel ();
_content_notebook->AddPage (_video_panel, _("Video"), false);
make_audio_panel ();
_content_notebook->AddPage (_audio_panel, _("Audio"), false);
make_subtitle_panel ();
_content_notebook->AddPage (_subtitle_panel, _("Subtitles"), false);
+ make_timing_panel ();
+ _content_notebook->AddPage (_timing_panel, _("Timing"), false);
_loop_count->SetRange (2, 1024);
}
FilmEditor::make_audio_panel ()
{
_audio_panel = new wxPanel (_content_notebook);
- _audio_sizer = new wxBoxSizer (wxVERTICAL);
- _audio_panel->SetSizer (_audio_sizer);
+ wxBoxSizer* audio_sizer = new wxBoxSizer (wxVERTICAL);
+ _audio_panel->SetSizer (audio_sizer);
wxFlexGridSizer* grid = new wxFlexGridSizer (3, 4, 4);
- _audio_sizer->Add (grid, 0, wxALL, 8);
+ audio_sizer->Add (grid, 0, wxALL, 8);
_show_audio = new wxButton (_audio_panel, wxID_ANY, _("Show Audio..."));
grid->Add (_show_audio, 1);
grid->AddSpacer (0);
_audio_mapping = new AudioMappingView (_audio_panel);
- _audio_sizer->Add (_audio_mapping, 1, wxEXPAND | wxALL, 6);
+ audio_sizer->Add (_audio_mapping, 1, wxEXPAND | wxALL, 6);
_audio_gain->SetRange (-60, 60);
_audio_delay->SetRange (-1000, 1000);
FilmEditor::make_subtitle_panel ()
{
_subtitle_panel = new wxPanel (_content_notebook);
- _subtitle_sizer = new wxBoxSizer (wxVERTICAL);
- _subtitle_panel->SetSizer (_subtitle_sizer);
+ wxBoxSizer* subtitle_sizer = new wxBoxSizer (wxVERTICAL);
+ _subtitle_panel->SetSizer (subtitle_sizer);
wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4);
- _subtitle_sizer->Add (grid, 0, wxALL, 8);
+ subtitle_sizer->Add (grid, 0, wxALL, 8);
_with_subtitles = new wxCheckBox (_subtitle_panel, wxID_ANY, _("With Subtitles"));
grid->Add (_with_subtitles, 1);
grid->Add (s);
}
- add_label_to_sizer (grid, _subtitle_panel, _("Subtitle stream"));
+ add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Stream"));
_subtitle_stream = new wxChoice (_subtitle_panel, wxID_ANY);
grid->Add (_subtitle_stream, 1, wxEXPAND | wxALL, 6);
grid->AddSpacer (0);
_subtitle_scale->SetRange (1, 1000);
}
+void
+FilmEditor::make_timing_panel ()
+{
+ _timing_panel = new wxPanel (_content_notebook);
+ wxBoxSizer* timing_sizer = new wxBoxSizer (wxVERTICAL);
+ _timing_panel->SetSizer (timing_sizer);
+ wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4);
+ timing_sizer->Add (grid, 0, wxALL, 8);
+
+ add_label_to_sizer (grid, _timing_panel, _("Start time"));
+ _start = new Timecode (_timing_panel);
+ grid->Add (_start);
+ add_label_to_sizer (grid, _timing_panel, _("Length"));
+ _length = new Timecode (_timing_panel);
+ grid->Add (_length);
+}
+
+
/** Called when the left crop widget has been changed */
void
FilmEditor::left_crop_changed (wxCommandEvent &)
case Film::CONTAINER:
setup_container ();
break;
- case Film::FILTERS:
- {
- pair<string, string> p = Filter::ffmpeg_strings (_film->filters ());
- if (p.first.empty () && p.second.empty ()) {
- _filters->SetLabel (_("None"));
- } else {
- string const b = p.first + " " + p.second;
- _filters->SetLabel (std_to_wx (b));
- }
- _dcp_sizer->Layout ();
- break;
- }
case Film::NAME:
checked_set (_name, _film->name());
setup_dcp_name ();
case Film::SCALER:
checked_set (_scaler, Scaler::as_index (_film->scaler ()));
break;
- case Film::AUDIO_GAIN:
- checked_set (_audio_gain, _film->audio_gain ());
- break;
- case Film::AUDIO_DELAY:
- checked_set (_audio_delay, _film->audio_delay ());
- break;
case Film::WITH_SUBTITLES:
checked_set (_with_subtitles, _film->with_subtitles ());
setup_subtitle_control_sensitivity ();
shared_ptr<Content> content = weak_content.lock ();
shared_ptr<VideoContent> video_content;
+ shared_ptr<AudioContent> audio_content;
+ shared_ptr<FFmpegContent> ffmpeg_content;
if (content) {
video_content = dynamic_pointer_cast<VideoContent> (content);
+ audio_content = dynamic_pointer_cast<AudioContent> (content);
+ ffmpeg_content = dynamic_pointer_cast<FFmpegContent> (content);
}
- if (property == VideoContentProperty::VIDEO_CROP) {
+ /* We can't use case {} here */
+
+ if (property == ContentProperty::START) {
+ if (content) {
+ _start->set (content->start (), _film->dcp_video_frame_rate ());
+ } else {
+ _start->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 == AudioContentProperty::AUDIO_GAIN) {
+ checked_set (_audio_gain, audio_content ? audio_content->audio_gain() : 0);
+ } else if (property == AudioContentProperty::AUDIO_DELAY) {
+ checked_set (_audio_delay, audio_content ? audio_content->audio_delay() : 0);
+ } else if (property == AudioContentProperty::AUDIO_MAPPING) {
+ _audio_mapping->set (audio_content ? audio_content->audio_mapping () : AudioMapping ());
} else if (property == FFmpegContentProperty::SUBTITLE_STREAMS) {
+ _subtitle_stream->Clear ();
+ if (ffmpeg_content) {
+ vector<shared_ptr<FFmpegSubtitleStream> > s = ffmpeg_content->subtitle_streams ();
+ if (s.empty ()) {
+ _subtitle_stream->Enable (false);
+ }
+ for (vector<shared_ptr<FFmpegSubtitleStream> >::iterator i = s.begin(); i != s.end(); ++i) {
+ _subtitle_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
+ }
+
+ if (ffmpeg_content->subtitle_stream()) {
+ checked_set (_subtitle_stream, lexical_cast<string> (ffmpeg_content->subtitle_stream()->id));
+ } else {
+ _subtitle_stream->SetSelection (wxNOT_FOUND);
+ }
+ }
setup_subtitle_control_sensitivity ();
} else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
+ _audio_stream->Clear ();
+ if (ffmpeg_content) {
+ vector<shared_ptr<FFmpegAudioStream> > a = ffmpeg_content->audio_streams ();
+ for (vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin(); i != a.end(); ++i) {
+ _audio_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
+ }
+
+ if (ffmpeg_content->audio_stream()) {
+ checked_set (_audio_stream, lexical_cast<string> (ffmpeg_content->audio_stream()->id));
+ }
+ }
setup_show_audio_sensitivity ();
} else if (property == FFmpegContentProperty::AUDIO_STREAM) {
setup_dcp_name ();
setup_show_audio_sensitivity ();
+ } else if (property == FFmpegContentProperty::FILTERS) {
+ if (ffmpeg_content) {
+ pair<string, string> p = Filter::ffmpeg_strings (ffmpeg_content->filters ());
+ if (p.first.empty () && p.second.empty ()) {
+ _filters->SetLabel (_("None"));
+ } else {
+ string const b = p.first + " " + p.second;
+ _filters->SetLabel (std_to_wx (b));
+ }
+ _dcp_sizer->Layout ();
+ }
}
}
film_changed (Film::LOOP);
film_changed (Film::DCP_CONTENT_TYPE);
film_changed (Film::CONTAINER);
- film_changed (Film::FILTERS);
film_changed (Film::SCALER);
- film_changed (Film::AUDIO_GAIN);
- film_changed (Film::AUDIO_DELAY);
film_changed (Film::WITH_SUBTITLES);
film_changed (Film::SUBTITLE_OFFSET);
film_changed (Film::SUBTITLE_SCALE);
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);
}
/** Updates the sensitivity of lots of widgets to a given value.
setup_subtitle_control_sensitivity ();
setup_show_audio_sensitivity ();
- setup_content_button_sensitivity ();
+ setup_content_sensitivity ();
}
/** Called when the `Edit filters' button has been clicked */
void
FilmEditor::edit_filters_clicked (wxCommandEvent &)
{
- FilterDialog* d = new FilterDialog (this, _film->filters());
- d->ActiveChanged.connect (bind (&Film::set_filters, _film, _1));
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return;
+ }
+
+ shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+ if (!fc) {
+ return;
+ }
+
+ FilterDialog* d = new FilterDialog (this, fc->filters());
+ d->ActiveChanged.connect (bind (&FFmpegContent::set_filters, fc, _1));
d->ShowModal ();
d->Destroy ();
}
void
FilmEditor::audio_gain_changed (wxCommandEvent &)
{
- if (!_film) {
+ shared_ptr<AudioContent> ac = selected_audio_content ();
+ if (!ac) {
return;
}
- _film->set_audio_gain (_audio_gain->GetValue ());
+ ac->set_audio_gain (_audio_gain->GetValue ());
}
void
FilmEditor::audio_delay_changed (wxCommandEvent &)
{
- if (!_film) {
+ shared_ptr<AudioContent> ac = selected_audio_content ();
+ if (!ac) {
return;
}
- _film->set_audio_delay (_audio_delay->GetValue ());
+ ac->set_audio_delay (_audio_delay->GetValue ());
}
void
boost::filesystem::path p (wx_to_std (paths[i]));
if (ImageMagickContent::valid_file (p)) {
- _film->add_content (shared_ptr<ImageMagickContent> (new ImageMagickContent (p)));
+ _film->add_content (shared_ptr<ImageMagickContent> (new ImageMagickContent (_film, p)));
} else if (SndfileContent::valid_file (p)) {
- _film->add_content (shared_ptr<SndfileContent> (new SndfileContent (p)));
+ _film->add_content (shared_ptr<SndfileContent> (new SndfileContent (_film, p)));
} else {
- _film->add_content (shared_ptr<FFmpegContent> (new FFmpegContent (p)));
+ _film->add_content (shared_ptr<FFmpegContent> (new FFmpegContent (_film, p)));
}
}
}
void
FilmEditor::content_selection_changed (wxListEvent &)
{
- setup_content_button_sensitivity ();
+ setup_content_sensitivity ();
+ shared_ptr<Content> s = selected_content ();
+ film_content_changed (s, ContentProperty::START);
+ film_content_changed (s, VideoContentProperty::VIDEO_CROP);
+ film_content_changed (s, AudioContentProperty::AUDIO_GAIN);
+ film_content_changed (s, AudioContentProperty::AUDIO_DELAY);
+ film_content_changed (s, AudioContentProperty::AUDIO_MAPPING);
+ film_content_changed (s, FFmpegContentProperty::AUDIO_STREAM);
+ film_content_changed (s, FFmpegContentProperty::AUDIO_STREAMS);
+ film_content_changed (s, FFmpegContentProperty::SUBTITLE_STREAM);
}
void
-FilmEditor::setup_content_button_sensitivity ()
+FilmEditor::setup_content_sensitivity ()
{
_content_add->Enable (_generally_sensitive);
_content_remove->Enable (selection && _generally_sensitive);
_content_timeline->Enable (_generally_sensitive);
+
+ _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);
}
shared_ptr<Content>
return dynamic_pointer_cast<VideoContent> (c);
}
+shared_ptr<AudioContent>
+FilmEditor::selected_audio_content ()
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return shared_ptr<AudioContent> ();
+ }
+
+ return dynamic_pointer_cast<AudioContent> (c);
+}
+
void
FilmEditor::setup_scaling_description ()
{
_timeline_dialog->Show ();
}
-void
-FilmEditor::setup_content_properties ()
-{
- _audio_stream->Clear ();
- _subtitle_stream->Clear ();
-
- shared_ptr<Content> c = selected_content ();
- if (!c) {
- return;
- }
-
- shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
- if (fc) {
-
- vector<shared_ptr<FFmpegAudioStream> > a = fc->audio_streams ();
- for (vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin(); i != a.end(); ++i) {
- _audio_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
- }
-
- if (fc->audio_stream()) {
- checked_set (_audio_stream, lexical_cast<string> (fc->audio_stream()->id));
- }
-
- vector<shared_ptr<FFmpegSubtitleStream> > s = fc->subtitle_streams ();
- if (s.empty ()) {
- _subtitle_stream->Enable (false);
- }
- for (vector<shared_ptr<FFmpegSubtitleStream> >::iterator i = s.begin(); i != s.end(); ++i) {
- _subtitle_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
- }
-
- if (fc->subtitle_stream()) {
- checked_set (_subtitle_stream, lexical_cast<string> (fc->subtitle_stream()->id));
- } else {
- _subtitle_stream->SetSelection (wxNOT_FOUND);
- }
-
- /* XXX: should be general audiocontent */
- _audio_mapping->set_mapping (fc->audio_mapping ());
- }
-}
-
void
FilmEditor::audio_stream_changed (wxCommandEvent &)
{
return;
}
- shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
- if (!fc) {
+ shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c);
+ if (!ac) {
return;
}
- /* XXX: should be general to audiocontent */
- fc->audio_stream()->mapping = m;
+ ac->set_audio_mapping (m);
}