#include "scaler.h"
#include "audio_dialog.h"
#include "imagemagick_content_dialog.h"
-#include "sndfile_content_dialog.h"
+#include "audio_mapping_view.h"
using std::string;
using std::cout;
}
++r;
- _frame_rate_description = new wxStaticText (_film_panel, wxID_ANY, wxT (" \n "), wxDefaultPosition, wxDefaultSize);
+ _frame_rate_description = new wxStaticText (_film_panel, wxID_ANY, wxT (" \n \n "), wxDefaultPosition, wxDefaultSize);
grid->Add (_frame_rate_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
wxFont font = _frame_rate_description->GetFont();
font.SetStyle(wxFONTSTYLE_ITALIC);
_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_headers->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::trust_content_headers_changed), 0, this);
- _content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler (FilmEditor::content_item_selected), 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->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler (FilmEditor::content_activated), 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_remove_clicked), 0, this);
_content_edit->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_edit_clicked), 0, this);
grid->Add (_format, wxGBPosition (r, 1));
++r;
- _format_description = new wxStaticText (_video_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize);
- grid->Add (_format_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6);
- wxFont font = _format_description->GetFont();
- font.SetStyle(wxFONTSTYLE_ITALIC);
- font.SetPointSize(font.GetPointSize() - 1);
- _format_description->SetFont(font);
- ++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;
+ _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();
+ font.SetStyle(wxFONTSTYLE_ITALIC);
+ font.SetPointSize(font.GetPointSize() - 1);
+ _scaling_description->SetFont(font);
+ ++r;
+
/* VIDEO-only stuff */
{
add_label_to_grid_bag_sizer (grid, _video_panel, _("Filters"), wxGBPosition (r, 0));
grid->Add (s, 1, wxEXPAND);
}
+ _audio_mapping = new AudioMappingView (_audio_panel);
+ _audio_sizer->Add (_audio_mapping, 1, wxEXPAND | wxALL, 6);
+
_audio_gain->SetRange (-60, 60);
_audio_delay->SetRange (-1000, 1000);
}
_ffmpeg_subtitle_stream = new wxChoice (_subtitle_panel, wxID_ANY);
grid->Add (_ffmpeg_subtitle_stream);
- add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Offset"));
- _subtitle_offset = new wxSpinCtrl (_subtitle_panel);
- grid->Add (_subtitle_offset, 1);
+ {
+ add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Offset"));
+ wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ _subtitle_offset = new wxSpinCtrl (_subtitle_panel);
+ s->Add (_subtitle_offset);
+ add_label_to_sizer (s, _subtitle_panel, _("pixels"));
+ grid->Add (s);
+ }
{
add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Scale"));
setup_subtitle_control_sensitivity ();
setup_streams ();
setup_show_audio_sensitivity ();
- setup_length ();
break;
case Film::TRUST_CONTENT_HEADERS:
checked_set (_trust_content_headers, _film->trust_content_headers ());
checked_set (_right_crop, _film->crop().right);
checked_set (_top_crop, _film->crop().top);
checked_set (_bottom_crop, _film->crop().bottom);
+ setup_scaling_description ();
break;
case Film::FILTERS:
{
}
if (_film->video_frame_rate()) {
- _frame_rate_description->SetLabel (std_to_wx (FrameRateConversion (_film->video_frame_rate(), _film->dcp_frame_rate()).description));
_best_dcp_frame_rate->Enable (best_dcp_frame_rate (_film->video_frame_rate ()) != _film->dcp_frame_rate ());
} else {
- _frame_rate_description->SetLabel (wxT (""));
_best_dcp_frame_rate->Disable ();
}
+ setup_frame_rate_description ();
+ break;
+ case Film::AUDIO_MAPPING:
+ _audio_mapping->set_mapping (_film->audio_mapping ());
+ break;
}
}
++i;
++n;
}
+
if (i == _formats.end()) {
checked_set (_format, -1);
} else {
checked_set (_format, n);
}
- setup_dcp_name ();
- if (_film->format ()) {
- _format_description->SetLabel (std_to_wx (_film->format()->description ()));
- } else {
- _format_description->SetLabel (wxT (""));
- }
+ setup_dcp_name ();
+ setup_scaling_description ();
}
void
}
}
+void
+FilmEditor::setup_frame_rate_description ()
+{
+ wxString d;
+ if (_film->video_frame_rate()) {
+ d << std_to_wx (FrameRateConversion (_film->video_frame_rate(), _film->dcp_frame_rate()).description);
+#ifdef HAVE_SWRESAMPLE
+ if (_film->audio_frame_rate() != _film->target_audio_sample_rate ()) {
+ d << wxString::Format (
+ _("Audio will be resampled from %dHz to %dHz\n"),
+ _film->audio_frame_rate(),
+ _film->target_audio_sample_rate()
+ );
+ } else {
+ d << "\n";
+ }
+#else
+ d << "\n";
+#endif
+ }
+
+ _frame_rate_description->SetLabel (d);
+}
/** Called when the format widget has been changed */
void
void
FilmEditor::set_film (shared_ptr<Film> f)
{
+ set_things_sensitive (_film != 0);
+
if (_film == f) {
return;
}
_film = f;
- set_things_sensitive (_film != 0);
-
if (_film) {
_film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
_film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _1, _2));
film_changed (Film::J2K_BANDWIDTH);
film_changed (Film::DCI_METADATA);
film_changed (Film::DCP_FRAME_RATE);
+ film_changed (Film::AUDIO_MAPPING);
film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::SUBTITLE_STREAMS);
film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::SUBTITLE_STREAM);
_film->set_audio_delay (_audio_delay->GetValue ());
}
+void
+FilmEditor::setup_notebook_size ()
+{
+ _notebook->InvalidateBestSize ();
+
+ _film_sizer->Layout ();
+ _film_sizer->SetSizeHints (_film_panel);
+ _video_sizer->Layout ();
+ _video_sizer->SetSizeHints (_video_panel);
+ _audio_sizer->Layout ();
+ _audio_sizer->SetSizeHints (_audio_panel);
+ _subtitle_sizer->Layout ();
+ _subtitle_sizer->SetSizeHints (_subtitle_panel);
+
+ _notebook->Fit ();
+ Fit ();
+}
+
void
FilmEditor::trim_start_changed (wxCommandEvent &)
{
if (!_film->ffmpeg_audio_stream()) {
_audio->SetLabel (wxT (""));
} else {
- stringstream s;
+ wxString s;
if (_film->audio_channels() == 1) {
- s << wx_to_std (_("1 channel"));
+ s << _("1 channel");
} else {
- s << _film->audio_channels() << " " << wx_to_std (_("channels"));
+ s << _film->audio_channels() << " " << _("channels");
}
- s << ", " << _film->audio_frame_rate() << wx_to_std (_("Hz"));
- _audio->SetLabel (std_to_wx (s.str ()));
+ s << ", " << _film->audio_frame_rate() << _("Hz");
+ _audio->SetLabel (s);
}
+
+ setup_notebook_size ();
}
void
}
}
+void
+FilmEditor::content_activated (wxListEvent& ev)
+{
+ ContentList c = _film->content ();
+ assert (ev.GetIndex() >= 0 && size_t (ev.GetIndex()) < c.size ());
+
+ edit_content (c[ev.GetIndex()]);
+}
+
void
FilmEditor::content_edit_clicked (wxCommandEvent &)
{
return;
}
+ edit_content (c);
+}
+
+void
+FilmEditor::edit_content (shared_ptr<Content> c)
+{
shared_ptr<ImageMagickContent> im = dynamic_pointer_cast<ImageMagickContent> (c);
if (im) {
ImageMagickContentDialog* d = new ImageMagickContentDialog (this, im);
- int const r = d->ShowModal ();
- d->Destroy ();
-
- if (r == wxID_OK) {
- im->set_video_length (d->video_length() * 24);
- }
- }
-
- shared_ptr<SndfileContent> sf = dynamic_pointer_cast<SndfileContent> (c);
- if (sf) {
- SndfileContentDialog* d = new SndfileContentDialog (this, sf);
d->ShowModal ();
d->Destroy ();
+
+ im->set_video_length (d->video_length() * 24);
}
}
}
void
-FilmEditor::content_item_selected (wxListEvent &)
+FilmEditor::content_selection_changed (wxListEvent &)
{
setup_content_button_sensitivity ();
setup_content_information ();
{
_content_add->Enable (_generally_sensitive);
- bool const have_selection = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1;
- _content_edit->Enable (have_selection && _generally_sensitive);
- _content_remove->Enable (have_selection && _generally_sensitive);
- _content_earlier->Enable (have_selection && _generally_sensitive);
- _content_later->Enable (have_selection && _generally_sensitive);
+ shared_ptr<Content> selection = selected_content ();
+
+ _content_edit->Enable (selection && _generally_sensitive && dynamic_pointer_cast<ImageMagickContent> (selection));
+ _content_remove->Enable (selection && _generally_sensitive);
+ _content_earlier->Enable (selection && _generally_sensitive);
+ _content_later->Enable (selection && _generally_sensitive);
}
shared_ptr<Content>
}
ContentList c = _film->content ();
- assert (s >= 0 && size_t (s) < c.size ());
+ if (s < 0 || size_t (s) >= c.size ()) {
+ return shared_ptr<Content> ();
+ }
+
return c[s];
}
+
+void
+FilmEditor::setup_scaling_description ()
+{
+ wxString d;
+
+ int lines = 0;
+
+ d << wxString::Format (
+ _("Original video is %dx%d (%.2f:1)\n"),
+ _film->video_size().width, _film->video_size().height,
+ float (_film->video_size().width) / _film->video_size().height
+ );
+
+ ++lines;
+
+ Crop const crop = _film->crop ();
+ if (crop.left || crop.right || crop.top || crop.bottom) {
+ libdcp::Size const cropped = _film->cropped_size (_film->video_size ());
+ d << wxString::Format (
+ _("Cropped to %dx%d (%.2f:1)\n"),
+ cropped.width, cropped.height,
+ float (cropped.width) / cropped.height
+ );
+ ++lines;
+ }
+
+ Format const * format = _film->format ();
+ if (format) {
+ int const padding = format->dcp_padding (_film);
+ libdcp::Size scaled = format->dcp_size ();
+ scaled.width -= padding * 2;
+ d << wxString::Format (
+ _("Scaled to %dx%d (%.2f:1)\n"),
+ scaled.width, scaled.height,
+ float (scaled.width) / scaled.height
+ );
+ ++lines;
+
+ if (padding) {
+ d << wxString::Format (
+ _("Padded with black to %dx%d (%.2f:1)\n"),
+ format->dcp_size().width, format->dcp_size().height,
+ float (format->dcp_size().width) / format->dcp_size().height
+ );
+ ++lines;
+ }
+ }
+
+ for (int i = lines; i < 4; ++i) {
+ d << " \n";
+ }
+
+ _scaling_description->SetLabel (d);
+}