X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ffilm_editor.cc;h=feb49ed78a394b392f93e118ae604fe3e2948ce9;hb=d62877ae6c4e316e43f4052e4b9ba673610012cf;hp=6c42359fb69f109910335f81c7f688bba37eea6b;hpb=8750efb9e072cf3b42e6c3c29521c7031c0b5dfd;p=dcpomatic.git diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 6c42359fb..feb49ed78 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -50,7 +50,7 @@ #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; @@ -146,7 +146,7 @@ FilmEditor::make_film_panel () } ++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); @@ -197,7 +197,9 @@ 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_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); @@ -246,14 +248,6 @@ FilmEditor::make_video_panel () 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)); @@ -274,6 +268,14 @@ FilmEditor::make_video_panel () 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)); @@ -406,6 +408,9 @@ FilmEditor::make_audio_panel () 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); } @@ -425,9 +430,14 @@ FilmEditor::make_subtitle_panel () _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")); @@ -598,7 +608,6 @@ FilmEditor::film_changed (Film::Property p) 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 ()); @@ -611,6 +620,7 @@ FilmEditor::film_changed (Film::Property p) 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: { @@ -685,12 +695,15 @@ FilmEditor::film_changed (Film::Property p) } 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; } } @@ -739,18 +752,15 @@ FilmEditor::setup_format () ++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 @@ -771,6 +781,29 @@ FilmEditor::setup_length () } } +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 @@ -805,14 +838,14 @@ FilmEditor::dcp_content_type_changed (wxCommandEvent &) void FilmEditor::set_film (shared_ptr 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)); @@ -849,6 +882,7 @@ FilmEditor::set_film (shared_ptr f) 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 (), FFmpegContentProperty::SUBTITLE_STREAMS); film_content_changed (boost::shared_ptr (), FFmpegContentProperty::SUBTITLE_STREAM); @@ -939,6 +973,24 @@ FilmEditor::audio_delay_changed (wxCommandEvent &) _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 &) { @@ -1126,15 +1178,17 @@ FilmEditor::setup_audio_details () 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 @@ -1242,6 +1296,15 @@ FilmEditor::content_remove_clicked (wxCommandEvent &) } } +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 &) { @@ -1250,22 +1313,19 @@ FilmEditor::content_edit_clicked (wxCommandEvent &) return; } + edit_content (c); +} + +void +FilmEditor::edit_content (shared_ptr c) +{ shared_ptr im = dynamic_pointer_cast (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 sf = dynamic_pointer_cast (c); - if (sf) { - SndfileContentDialog* d = new SndfileContentDialog (this, sf); d->ShowModal (); d->Destroy (); + + im->set_video_length (d->video_length() * 24); } } @@ -1288,7 +1348,7 @@ FilmEditor::content_later_clicked (wxCommandEvent &) } void -FilmEditor::content_item_selected (wxListEvent &) +FilmEditor::content_selection_changed (wxListEvent &) { setup_content_button_sensitivity (); setup_content_information (); @@ -1311,11 +1371,12 @@ FilmEditor::setup_content_button_sensitivity () { _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 selection = selected_content (); + + _content_edit->Enable (selection && _generally_sensitive && dynamic_pointer_cast (selection)); + _content_remove->Enable (selection && _generally_sensitive); + _content_earlier->Enable (selection && _generally_sensitive); + _content_later->Enable (selection && _generally_sensitive); } shared_ptr @@ -1327,6 +1388,64 @@ FilmEditor::selected_content () } ContentList c = _film->content (); - assert (s >= 0 && size_t (s) < c.size ()); + if (s < 0 || size_t (s) >= c.size ()) { + return shared_ptr (); + } + 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); +}