X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fvideo_panel.cc;h=a643832e89dd53e56aee6c73a260ade51eaa819f;hb=c205a496d1d68d23d5101024928cf40ac22a235e;hp=f5306e67fd8e532609893ea1a0557c83e4bc10cf;hpb=92112105d96ed0193031cce21d1197ce29dfecc2;p=dcpomatic.git diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index f5306e67f..a643832e8 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -20,18 +20,25 @@ #include #include "lib/ratio.h" #include "lib/filter.h" +#include "lib/ffmpeg_content.h" +#include "lib/colour_conversion.h" +#include "lib/config.h" +#include "lib/util.h" #include "filter_dialog.h" #include "video_panel.h" #include "wx_util.h" #include "film_editor.h" +#include "content_colour_conversion_dialog.h" using std::vector; using std::string; using std::pair; using std::cout; +using std::list; using boost::shared_ptr; using boost::dynamic_pointer_cast; using boost::bind; +using boost::optional; VideoPanel::VideoPanel (FilmEditor* e) : FilmEditorPanel (e, _("Video")) @@ -74,13 +81,35 @@ VideoPanel::VideoPanel (FilmEditor* e) { add_label_to_grid_bag_sizer (grid, this, _("Filters"), true, wxGBPosition (r, 0)); wxSizer* s = new wxBoxSizer (wxHORIZONTAL); - _filters = new wxStaticText (this, wxID_ANY, _("None")); + + wxClientDC dc (this); + wxSize size = dc.GetTextExtent (wxT ("A quite long name")); + size.SetHeight (-1); + + _filters = new wxStaticText (this, wxID_ANY, _("None"), wxDefaultPosition, size); s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6); _filters_button = new wxButton (this, wxID_ANY, _("Edit...")); s->Add (_filters_button, 0, wxALIGN_CENTER_VERTICAL); grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); } ++r; + + { + add_label_to_grid_bag_sizer (grid, this, _("Colour conversion"), true, wxGBPosition (r, 0)); + wxSizer* s = new wxBoxSizer (wxHORIZONTAL); + + wxClientDC dc (this); + wxSize size = dc.GetTextExtent (wxT ("A quite long name")); + size.SetHeight (-1); + + _colour_conversion = new wxStaticText (this, wxID_ANY, wxT (""), wxDefaultPosition, size); + + s->Add (_colour_conversion, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6); + _colour_conversion_button = new wxButton (this, wxID_ANY, _("Edit...")); + s->Add (_colour_conversion_button, 0, wxALIGN_CENTER_VERTICAL); + grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); + } + ++r; _description = new wxStaticText (this, wxID_ANY, wxT ("\n \n \n \n \n"), wxDefaultPosition, wxDefaultSize); grid->Add (_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6); @@ -100,17 +129,19 @@ VideoPanel::VideoPanel (FilmEditor* e) for (vector::iterator i = ratios.begin(); i != ratios.end(); ++i) { _ratio->Append (std_to_wx ((*i)->nickname ())); } + _ratio->Append (_("No stretch")); _frame_type->Append (_("2D")); _frame_type->Append (_("3D left/right")); - _frame_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::frame_type_changed, this)); - _left_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::left_crop_changed, this)); - _right_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::right_crop_changed, this)); - _top_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::top_crop_changed, this)); - _bottom_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::bottom_crop_changed, this)); - _ratio->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::ratio_changed, this)); - _filters_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_filters_clicked, this)); + _frame_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::frame_type_changed, this)); + _left_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::left_crop_changed, this)); + _right_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::right_crop_changed, this)); + _top_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::top_crop_changed, this)); + _bottom_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::bottom_crop_changed, this)); + _ratio->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::ratio_changed, this)); + _filters_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_filters_clicked, this)); + _colour_conversion_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_colour_conversion_clicked, this)); } @@ -183,6 +214,7 @@ VideoPanel::film_content_changed (shared_ptr c, int property) if (property == VideoContentProperty::VIDEO_FRAME_TYPE) { checked_set (_frame_type, vc ? vc->video_frame_type () : VIDEO_FRAME_TYPE_2D); + setup_description (); } else if (property == VideoContentProperty::VIDEO_CROP) { checked_set (_left_crop, vc ? vc->crop().left : 0); checked_set (_right_crop, vc ? vc->crop().right : 0); @@ -200,7 +232,7 @@ VideoPanel::film_content_changed (shared_ptr c, int property) } if (i == ratios.end()) { - checked_set (_ratio, -1); + checked_set (_ratio, ratios.size ()); } else { checked_set (_ratio, n); } @@ -210,6 +242,10 @@ VideoPanel::film_content_changed (shared_ptr c, int property) setup_description (); } else if (property == VideoContentProperty::VIDEO_FRAME_RATE) { setup_description (); + } else if (property == VideoContentProperty::COLOUR_CONVERSION) { + optional preset = vc ? vc->colour_conversion().preset () : optional (); + vector cc = Config::instance()->colour_conversions (); + _colour_conversion->SetLabel (preset ? std_to_wx (cc[preset.get()].name) : _("Custom")); } else if (property == FFmpegContentProperty::FILTERS) { if (fc) { pair p = Filter::ffmpeg_strings (fc->filters ()); @@ -259,45 +295,45 @@ VideoPanel::setup_description () if (vc->video_size().width && vc->video_size().height) { d << wxString::Format ( _("Content video is %dx%d (%.2f:1)\n"), - vc->video_size().width, vc->video_size().height, - float (vc->video_size().width) / vc->video_size().height + vc->video_size_after_3d_split().width, + vc->video_size_after_3d_split().height, + vc->video_size_after_3d_split().ratio () ); ++lines; } Crop const crop = vc->crop (); if ((crop.left || crop.right || crop.top || crop.bottom) && vc->video_size() != libdcp::Size (0, 0)) { - libdcp::Size cropped = vc->video_size (); - cropped.width -= crop.left + crop.right; - cropped.height -= crop.top + crop.bottom; + libdcp::Size cropped = vc->video_size_after_crop (); d << wxString::Format ( _("Cropped to %dx%d (%.2f:1)\n"), cropped.width, cropped.height, - float (cropped.width) / cropped.height + cropped.ratio () ); ++lines; } Ratio const * ratio = vc->ratio (); - if (ratio) { - libdcp::Size container_size = _editor->film()->container()->size (_editor->film()->full_frame ()); - - libdcp::Size const scaled = ratio->size (container_size); + libdcp::Size container_size = fit_ratio_within (_editor->film()->container()->ratio (), _editor->film()->full_frame ()); + float const ratio_value = ratio ? ratio->ratio() : vc->video_size_after_crop().ratio (); + + /* We have a specified ratio to scale to */ + libdcp::Size const scaled = fit_ratio_within (ratio_value, container_size); + + d << wxString::Format ( + _("Scaled to %dx%d (%.2f:1)\n"), + scaled.width, scaled.height, + scaled.ratio () + ); + ++lines; + + if (scaled != container_size) { d << wxString::Format ( - _("Scaled to %dx%d (%.2f:1)\n"), - scaled.width, scaled.height, - float (scaled.width) / scaled.height + _("Padded with black to %dx%d (%.2f:1)\n"), + container_size.width, container_size.height, + container_size.ratio () ); ++lines; - - if (scaled != container_size) { - d << wxString::Format ( - _("Padded with black to %dx%d (%.2f:1)\n"), - container_size.width, container_size.height, - float (container_size.width) / container_size.height - ); - ++lines; - } } d << wxString::Format (_("Content frame rate %.4f\n"), vc->video_frame_rate ()); @@ -327,8 +363,11 @@ VideoPanel::ratio_changed () int const n = _ratio->GetSelection (); if (n >= 0) { vector ratios = Ratio::all (); - assert (n < int (ratios.size())); - vc->set_ratio (ratios[n]); + if (n < int (ratios.size ())) { + vc->set_ratio (ratios[n]); + } else { + vc->set_ratio (0); + } } } @@ -340,3 +379,20 @@ VideoPanel::frame_type_changed () vc->set_video_frame_type (static_cast (_frame_type->GetSelection ())); } } + +void +VideoPanel::edit_colour_conversion_clicked () +{ + shared_ptr vc = _editor->selected_video_content (); + if (!vc) { + return; + } + + ColourConversion conversion = vc->colour_conversion (); + ContentColourConversionDialog* d = new ContentColourConversionDialog (this); + d->set (conversion); + d->ShowModal (); + + vc->set_colour_conversion (d->get ()); + d->Destroy (); +}