X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fdcp_panel.cc;h=ccfe5711cf717b3b9586be6d0188308cc0f88a1c;hb=e4fc4dcbd68e80dacfda96d95897c33489a89849;hp=ce02c46c8663296b5752da7e0768b008962dc4d0;hpb=22b9f3b2090d8bdfe52cda1e69d3acbe874f1ce5;p=dcpomatic.git diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index ce02c46c8..ccfe5711c 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,14 +19,15 @@ #include "dcp_panel.h" #include "wx_util.h" +#include "key_dialog.h" #include "isdcf_metadata_dialog.h" #include "lib/ratio.h" -#include "lib/scaler.h" #include "lib/config.h" #include "lib/dcp_content_type.h" #include "lib/util.h" #include "lib/film.h" #include "lib/ffmpeg_content.h" +#include #include #include #include @@ -58,11 +59,6 @@ DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr f) grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxLEFT | wxRIGHT); ++r; - add_label_to_grid_bag_sizer (grid, _panel, _("DCP Name"), true, wxGBPosition (r, 0)); - _dcp_name = new wxStaticText (_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END); - grid->Add (_dcp_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL | wxEXPAND); - ++r; - int flags = wxALIGN_CENTER_VERTICAL; #ifdef __WXOSX__ flags |= wxALIGN_RIGHT; @@ -70,8 +66,20 @@ DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr f) _use_isdcf_name = new wxCheckBox (_panel, wxID_ANY, _("Use ISDCF name")); grid->Add (_use_isdcf_name, wxGBPosition (r, 0), wxDefaultSpan, flags); - _edit_isdcf_button = new wxButton (_panel, wxID_ANY, _("Details...")); - grid->Add (_edit_isdcf_button, wxGBPosition (r, 1)); + + { + wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + _edit_isdcf_button = new wxButton (_panel, wxID_ANY, _("Details...")); + s->Add (_edit_isdcf_button, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP); + _copy_isdcf_name_button = new wxButton (_panel, wxID_ANY, _("Copy as name")); + s->Add (_copy_isdcf_name_button, 1, wxEXPAND | wxLEFT, DCPOMATIC_SIZER_X_GAP); + grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND); + ++r; + } + + add_label_to_grid_bag_sizer (grid, _panel, _("DCP Name"), true, wxGBPosition (r, 0)); + _dcp_name = new wxStaticText (_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END); + grid->Add (_dcp_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL | wxEXPAND); ++r; add_label_to_grid_bag_sizer (grid, _panel, _("Content Type"), true, wxGBPosition (r, 0)); @@ -93,18 +101,35 @@ DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr f) grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2)); ++r; + wxClientDC dc (_panel); + wxSize size = dc.GetTextExtent (wxT ("GGGGGGGG...")); + size.SetHeight (-1); + + { + add_label_to_grid_bag_sizer (grid, _panel, _("Key"), true, wxGBPosition (r, 0)); + wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + _key = new wxStaticText (_panel, wxID_ANY, "", wxDefaultPosition, size); + s->Add (_key, 1, wxALIGN_CENTER_VERTICAL); + _edit_key = new wxButton (_panel, wxID_ANY, _("Edit...")); + s->Add (_edit_key); + grid->Add (s, wxGBPosition (r, 1)); + ++r; + } + add_label_to_grid_bag_sizer (grid, _panel, _("Standard"), true, wxGBPosition (r, 0)); _standard = new wxChoice (_panel, wxID_ANY); grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); ++r; - _name->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DCPPanel::name_changed, this)); - _use_isdcf_name->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&DCPPanel::use_isdcf_name_toggled, this)); - _edit_isdcf_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DCPPanel::edit_isdcf_button_clicked, this)); - _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::dcp_content_type_changed, this)); - _signed->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&DCPPanel::signed_toggled, this)); - _encrypted->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&DCPPanel::encrypted_toggled, this)); - _standard->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::standard_changed, this)); + _name->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DCPPanel::name_changed, this)); + _use_isdcf_name->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&DCPPanel::use_isdcf_name_toggled, this)); + _edit_isdcf_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DCPPanel::edit_isdcf_button_clicked, this)); + _copy_isdcf_name_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DCPPanel::copy_isdcf_name_button_clicked, this)); + _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::dcp_content_type_changed, this)); + _signed->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&DCPPanel::signed_toggled, this)); + _encrypted->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&DCPPanel::encrypted_toggled, this)); + _edit_key->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DCPPanel::edit_key_clicked, this)); + _standard->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::standard_changed, this)); vector const ct = DCPContentType::all (); for (vector::const_iterator i = ct.begin(); i != ct.end(); ++i) { @@ -117,6 +142,16 @@ DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr f) Config::instance()->Changed.connect (boost::bind (&DCPPanel::config_changed, this)); } +void +DCPPanel::edit_key_clicked () +{ + KeyDialog* d = new KeyDialog (_panel, _film->key ()); + if (d->ShowModal () == wxID_OK) { + _film->set_key (d->key ()); + } + d->Destroy (); +} + void DCPPanel::name_changed () { @@ -200,7 +235,7 @@ DCPPanel::audio_channels_changed () return; } - _film->set_audio_channels (_audio_channels->GetValue ()); + _film->set_audio_channels ((_audio_channels->GetSelection () + 1) * 2); } void @@ -240,9 +275,6 @@ DCPPanel::film_changed (int p) checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ())); setup_dcp_name (); break; - case Film::SCALER: - checked_set (_scaler, Scaler::as_index (_film->scaler ())); - break; case Film::BURN_SUBTITLES: checked_set (_burn_subtitles, _film->burn_subtitles ()); break; @@ -254,10 +286,17 @@ DCPPanel::film_changed (int p) if (_film->encrypted ()) { _film->set_signed (true); _signed->Enable (false); + _key->Enable (_generally_sensitive); + _edit_key->Enable (_generally_sensitive); } else { _signed->Enable (_generally_sensitive); + _key->Enable (false); + _edit_key->Enable (false); } break; + case Film::KEY: + checked_set (_key, _film->key().hex().substr (0, 8) + "..."); + break; case Film::RESOLUTION: checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1); setup_dcp_name (); @@ -266,9 +305,12 @@ DCPPanel::film_changed (int p) checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000); break; case Film::USE_ISDCF_NAME: + { checked_set (_use_isdcf_name, _film->use_isdcf_name ()); setup_dcp_name (); + _edit_isdcf_button->Enable (_film->use_isdcf_name ()); break; + } case Film::ISDCF_METADATA: setup_dcp_name (); break; @@ -293,7 +335,7 @@ DCPPanel::film_changed (int p) break; } case Film::AUDIO_CHANNELS: - checked_set (_audio_channels, _film->audio_channels ()); + checked_set (_audio_channels, (_film->audio_channels () / 2) - 1); setup_dcp_name (); break; case Film::THREE_D: @@ -302,6 +344,7 @@ DCPPanel::film_changed (int p) break; case Film::INTEROP: checked_set (_standard, _film->interop() ? 1 : 0); + setup_dcp_name (); break; default: break; @@ -311,7 +354,9 @@ DCPPanel::film_changed (int p) void DCPPanel::film_content_changed (int property) { - if (property == FFmpegContentProperty::AUDIO_STREAM || property == SubtitleContentProperty::USE_SUBTITLES) { + if (property == FFmpegContentProperty::AUDIO_STREAM || + property == SubtitleContentProperty::USE_SUBTITLES || + property == VideoContentProperty::VIDEO_SCALE) { setup_dcp_name (); } } @@ -348,7 +393,7 @@ DCPPanel::container_changed () int const n = _container->GetSelection (); if (n >= 0) { vector ratios = Ratio::all (); - assert (n < int (ratios.size())); + DCPOMATIC_ASSERT (n < int (ratios.size())); _film->set_container (ratios[n]); } } @@ -378,10 +423,10 @@ DCPPanel::set_film (shared_ptr film) film_changed (Film::DCP_CONTENT_TYPE); film_changed (Film::CONTAINER); film_changed (Film::RESOLUTION); - film_changed (Film::SCALER); film_changed (Film::SIGNED); film_changed (Film::BURN_SUBTITLES); film_changed (Film::ENCRYPTED); + film_changed (Film::KEY); film_changed (Film::J2K_BANDWIDTH); film_changed (Film::ISDCF_METADATA); film_changed (Film::VIDEO_FRAME_RATE); @@ -398,6 +443,7 @@ DCPPanel::set_general_sensitivity (bool s) _use_isdcf_name->Enable (s); _edit_isdcf_button->Enable (s); _dcp_content_type->Enable (s); + _copy_isdcf_name_button->Enable (s); bool si = s; if (_film && _film->encrypted ()) { @@ -407,6 +453,8 @@ DCPPanel::set_general_sensitivity (bool s) _signed->Enable (si); _encrypted->Enable (s); + _key->Enable (s && _film && _film->encrypted ()); + _edit_key->Enable (s && _film && _film->encrypted ()); _frame_rate_choice->Enable (s); _frame_rate_spin->Enable (s); _audio_channels->Enable (s); @@ -414,25 +462,10 @@ DCPPanel::set_general_sensitivity (bool s) _container->Enable (s); _best_frame_rate->Enable (s && _film && _film->best_video_frame_rate () != _film->video_frame_rate ()); _resolution->Enable (s); - _scaler->Enable (s); _three_d->Enable (s); _standard->Enable (s); } -/** Called when the scaler widget has been changed */ -void -DCPPanel::scaler_changed () -{ - if (!_film) { - return; - } - - int const n = _scaler->GetSelection (); - if (n >= 0) { - _film->set_scaler (Scaler::from_index (n)); - } -} - void DCPPanel::use_isdcf_name_toggled () { @@ -534,7 +567,7 @@ DCPPanel::make_video_panel () _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL); setup_frame_rate_widget (); _best_frame_rate = new wxButton (panel, wxID_ANY, _("Use best")); - _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND); + _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL); grid->Add (_frame_rate_sizer, wxGBPosition (r, 1)); } ++r; @@ -562,26 +595,17 @@ DCPPanel::make_video_panel () } ++r; - add_label_to_grid_bag_sizer (grid, panel, _("Scaler"), true, wxGBPosition (r, 0)); - _scaler = new wxChoice (panel, wxID_ANY); - grid->Add (_scaler, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); - ++r; - _container->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::container_changed, this)); - _scaler->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::scaler_changed, this)); _frame_rate_choice->Bind(wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::frame_rate_choice_changed, this)); _frame_rate_spin->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DCPPanel::frame_rate_spin_changed, this)); _best_frame_rate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DCPPanel::best_frame_rate_clicked, this)); _burn_subtitles->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&DCPPanel::burn_subtitles_toggled, this)); _j2k_bandwidth->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DCPPanel::j2k_bandwidth_changed, this)); + /* Also listen to wxEVT_COMMAND_TEXT_UPDATED so that typing numbers directly in is always noticed */ + _j2k_bandwidth->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DCPPanel::j2k_bandwidth_changed, this)); _resolution->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::resolution_changed, this)); _three_d->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&DCPPanel::three_d_changed, this)); - vector const sc = Scaler::all (); - for (vector::const_iterator i = sc.begin(); i != sc.end(); ++i) { - _scaler->Append (std_to_wx ((*i)->name())); - } - vector const ratio = Ratio::all (); for (vector::const_iterator i = ratio.begin(); i != ratio.end(); ++i) { _container->Append (std_to_wx ((*i)->nickname ())); @@ -612,13 +636,21 @@ DCPPanel::make_audio_panel () int r = 0; add_label_to_grid_bag_sizer (grid, panel, _("Channels"), true, wxGBPosition (r, 0)); - _audio_channels = new wxSpinCtrl (panel, wxID_ANY); + _audio_channels = new wxChoice (panel, wxID_ANY); + for (int i = 2; i <= 12; i += 2) { + _audio_channels->Append (wxString::Format ("%d", i)); + } grid->Add (_audio_channels, wxGBPosition (r, 1)); ++r; - _audio_channels->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DCPPanel::audio_channels_changed, this)); - - _audio_channels->SetRange (0, MAX_DCP_AUDIO_CHANNELS); + _audio_channels->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::audio_channels_changed, this)); return panel; } + +void +DCPPanel::copy_isdcf_name_button_clicked () +{ + _film->set_name (_film->isdcf_name (false)); + _film->set_use_isdcf_name (false); +}