}
void
-AudioPanel::film_content_changed (
- shared_ptr<Content>,
- shared_ptr<AudioContent> audio_content,
- shared_ptr<SubtitleContent>,
- shared_ptr<FFmpegContent> ffmpeg_content,
- int property
- )
+AudioPanel::film_content_changed (shared_ptr<Content> c, int property)
{
+ shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c);
+ shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+
if (property == AudioContentProperty::AUDIO_GAIN) {
- checked_set (_gain, audio_content ? audio_content->audio_gain() : 0);
+ checked_set (_gain, ac ? ac->audio_gain() : 0);
} else if (property == AudioContentProperty::AUDIO_DELAY) {
- checked_set (_delay, audio_content ? audio_content->audio_delay() : 0);
+ checked_set (_delay, ac ? ac->audio_delay() : 0);
} else if (property == AudioContentProperty::AUDIO_MAPPING) {
- _mapping->set (audio_content ? audio_content->audio_mapping () : AudioMapping ());
+ _mapping->set (ac ? ac->audio_mapping () : AudioMapping ());
} else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
_stream->Clear ();
- if (ffmpeg_content) {
- vector<shared_ptr<FFmpegAudioStream> > a = ffmpeg_content->audio_streams ();
+ if (fc) {
+ vector<shared_ptr<FFmpegAudioStream> > a = fc->audio_streams ();
for (vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin(); i != a.end(); ++i) {
_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
}
- if (ffmpeg_content->audio_stream()) {
- checked_set (_stream, lexical_cast<string> (ffmpeg_content->audio_stream()->id));
+ if (fc->audio_stream()) {
+ checked_set (_stream, lexical_cast<string> (fc->audio_stream()->id));
}
}
setup_sensitivity ();
AudioPanel (FilmEditor *);
void film_changed (Film::Property);
- void film_content_changed (
- boost::shared_ptr<Content>,
- boost::shared_ptr<AudioContent>,
- boost::shared_ptr<SubtitleContent>,
- boost::shared_ptr<FFmpegContent>,
- int);
+ void film_content_changed (boost::shared_ptr<Content>, int);
void content_selection_changed ();
void setup_sensitivity ();
#include "lib/sound_processor.h"
#include "lib/scaler.h"
#include "timecode.h"
-#include "filter_dialog.h"
#include "wx_util.h"
#include "film_editor.h"
#include "dci_metadata_dialog.h"
#include "timing_panel.h"
#include "subtitle_panel.h"
#include "audio_panel.h"
+#include "video_panel.h"
using std::string;
using std::cout;
make_dcp_panel ();
_main_notebook->AddPage (_dcp_panel, _("DCP"), false);
- setup_ratios ();
-
set_film (f);
connect_to_widgets ();
_use_dci_name->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::use_dci_name_toggled), 0, this);
_edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this);
_container->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::container_changed), 0, this);
- _ratio->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::ratio_changed), 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_RIGHT_CLICK,wxListEventHandler (FilmEditor::content_right_click), 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_timeline->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_timeline_clicked), 0, this);
- _left_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this);
- _right_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::right_crop_changed), 0, this);
- _top_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this);
- _bottom_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::bottom_crop_changed), 0, this);
- _filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_filters_clicked), 0, this);
_scaler->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::scaler_changed), 0, this);
_dcp_content_type->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this);
_dcp_frame_rate->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::dcp_frame_rate_changed), 0, this);
_sequence_video->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::sequence_video_changed), 0, this);
}
-void
-FilmEditor::make_video_panel ()
-{
- _video_panel = new wxPanel (_content_notebook);
- wxBoxSizer* video_sizer = new wxBoxSizer (wxVERTICAL);
- _video_panel->SetSizer (video_sizer);
-
- wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
- video_sizer->Add (grid, 0, wxALL, 8);
-
- int r = 0;
- add_label_to_grid_bag_sizer (grid, _video_panel, _("Left crop"), true, wxGBPosition (r, 0));
- _left_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
- grid->Add (_left_crop, wxGBPosition (r, 1));
- ++r;
-
- add_label_to_grid_bag_sizer (grid, _video_panel, _("Right crop"), true, wxGBPosition (r, 0));
- _right_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
- grid->Add (_right_crop, wxGBPosition (r, 1));
- ++r;
-
- add_label_to_grid_bag_sizer (grid, _video_panel, _("Top crop"), true, wxGBPosition (r, 0));
- _top_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
- grid->Add (_top_crop, wxGBPosition (r, 1));
- ++r;
-
- add_label_to_grid_bag_sizer (grid, _video_panel, _("Bottom crop"), true, wxGBPosition (r, 0));
- _bottom_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
- grid->Add (_bottom_crop, wxGBPosition (r, 1));
- ++r;
-
- add_label_to_grid_bag_sizer (grid, _video_panel, _("Scale to"), true, wxGBPosition (r, 0));
- _ratio = new wxChoice (_video_panel, wxID_ANY);
- grid->Add (_ratio, 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"), true, wxGBPosition (r, 0));
- wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
- _filters = new wxStaticText (_video_panel, wxID_ANY, _("None"));
- s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
- _filters_button = new wxButton (_video_panel, wxID_ANY, _("Edit..."));
- s->Add (_filters_button, 0, wxALIGN_CENTER_VERTICAL);
- grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
- }
- ++r;
-
- _left_crop->SetRange (0, 1024);
- _top_crop->SetRange (0, 1024);
- _right_crop->SetRange (0, 1024);
- _bottom_crop->SetRange (0, 1024);
-}
-
void
FilmEditor::make_content_panel ()
{
_content_notebook = new wxNotebook (_content_panel, wxID_ANY);
_content_sizer->Add (_content_notebook, 1, wxEXPAND | wxTOP, 6);
- make_video_panel ();
- _content_notebook->AddPage (_video_panel, _("Video"), false);
+ _video_panel = new VideoPanel (this);
_audio_panel = new AudioPanel (this);
_subtitle_panel = new SubtitlePanel (this);
_timing_panel = new TimingPanel (this);
}
-
-/** Called when the left crop widget has been changed */
-void
-FilmEditor::left_crop_changed (wxCommandEvent &)
-{
- shared_ptr<VideoContent> c = selected_video_content ();
- if (!c) {
- return;
- }
-
- c->set_left_crop (_left_crop->GetValue ());
-}
-
-/** Called when the right crop widget has been changed */
-void
-FilmEditor::right_crop_changed (wxCommandEvent &)
-{
- shared_ptr<VideoContent> c = selected_video_content ();
- if (!c) {
- return;
- }
-
- c->set_right_crop (_right_crop->GetValue ());
-}
-
-/** Called when the top crop widget has been changed */
-void
-FilmEditor::top_crop_changed (wxCommandEvent &)
-{
- shared_ptr<VideoContent> c = selected_video_content ();
- if (!c) {
- return;
- }
-
- c->set_top_crop (_top_crop->GetValue ());
-}
-
-/** Called when the bottom crop value has been changed */
-void
-FilmEditor::bottom_crop_changed (wxCommandEvent &)
-{
- shared_ptr<VideoContent> c = selected_video_content ();
- if (!c) {
- return;
- }
-
- c->set_bottom_crop (_bottom_crop->GetValue ());
-}
-
/** Called when the name widget has been changed */
void
FilmEditor::name_changed (wxCommandEvent &)
stringstream s;
+ _video_panel->film_changed (p);
_audio_panel->film_changed (p);
_subtitle_panel->film_changed (p);
_timing_panel->film_changed (p);
ffmpeg_content = dynamic_pointer_cast<FFmpegContent> (content);
}
- _audio_panel->film_content_changed (content, audio_content, subtitle_content, ffmpeg_content, property);
- _subtitle_panel->film_content_changed (content, audio_content, subtitle_content, ffmpeg_content, property);
- _timing_panel->film_content_changed (content, audio_content, subtitle_content, ffmpeg_content, property);
-
- /* We can't use case {} here */
-
- 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 == VideoContentProperty::VIDEO_RATIO) {
- if (video_content) {
- int n = 0;
- vector<Ratio const *> ratios = Ratio::all ();
- vector<Ratio const *>::iterator i = ratios.begin ();
- while (i != ratios.end() && *i != video_content->ratio()) {
- ++i;
- ++n;
- }
+ _video_panel->film_content_changed (content, property);
+ _audio_panel->film_content_changed (content, property);
+ _subtitle_panel->film_content_changed (content, property);
+ _timing_panel->film_content_changed (content, property);
- if (i == ratios.end()) {
- checked_set (_ratio, -1);
- } else {
- checked_set (_ratio, n);
- }
- } else {
- checked_set (_ratio, -1);
- }
- setup_scaling_description ();
- } else if (property == FFmpegContentProperty::AUDIO_STREAM) {
+ if (property == FFmpegContentProperty::AUDIO_STREAM) {
setup_dcp_name ();
- } 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 ();
- }
}
}
}
setup_dcp_name ();
- setup_scaling_description ();
+ _video_panel->setup_scaling_description ();
}
/** Called when the container widget has been changed */
_best_dcp_frame_rate->Enable (s && _film && _film->best_dcp_video_frame_rate () != _film->dcp_video_frame_rate ());
}
-/** Called when the `Edit filters' button has been clicked */
-void
-FilmEditor::edit_filters_clicked (wxCommandEvent &)
-{
- 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 ();
-}
-
/** Called when the scaler widget has been changed */
void
FilmEditor::scaler_changed (wxCommandEvent &)
}
}
-void
-FilmEditor::setup_ratios ()
-{
- _ratios = Ratio::all ();
-
- _ratio->Clear ();
- for (vector<Ratio const *>::iterator i = _ratios.begin(); i != _ratios.end(); ++i) {
- _ratio->Append (std_to_wx ((*i)->nickname ()));
- }
-
- _dcp_sizer->Layout ();
-}
-
void
FilmEditor::use_dci_name_toggled (wxCommandEvent &)
{
return dynamic_pointer_cast<SubtitleContent> (c);
}
-void
-FilmEditor::setup_scaling_description ()
-{
- shared_ptr<VideoContent> vc = selected_video_content ();
- if (!vc) {
- _scaling_description->SetLabel ("");
- return;
- }
-
- wxString d;
-
- int lines = 0;
-
- if (vc->video_size().width && vc->video_size().height) {
- d << wxString::Format (
- _("Original video is %dx%d (%.2f:1)\n"),
- vc->video_size().width, vc->video_size().height,
- float (vc->video_size().width) / vc->video_size().height
- );
- ++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;
- d << wxString::Format (
- _("Cropped to %dx%d (%.2f:1)\n"),
- cropped.width, cropped.height,
- float (cropped.width) / cropped.height
- );
- ++lines;
- }
-
- Ratio const * ratio = vc->ratio ();
- if (ratio) {
- libdcp::Size container_size = _film->container()->size (_film->full_frame ());
-
- libdcp::Size const scaled = ratio->size (container_size);
- d << wxString::Format (
- _("Scaled to %dx%d (%.2f:1)\n"),
- scaled.width, scaled.height,
- float (scaled.width) / scaled.height
- );
- ++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;
- }
- }
-
- for (int i = lines; i < 4; ++i) {
- d << wxT ("\n ");
- }
-
- _scaling_description->SetLabel (d);
-}
-
void
FilmEditor::content_timeline_clicked (wxCommandEvent &)
{
}
}
-void
-FilmEditor::ratio_changed (wxCommandEvent &)
-{
- if (!_film) {
- return;
- }
-
- shared_ptr<Content> c = selected_content ();
- if (!c) {
- return;
- }
-
- shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (c);
- if (!vc) {
- return;
- }
-
- int const n = _ratio->GetSelection ();
- if (n >= 0) {
- vector<Ratio const *> ratios = Ratio::all ();
- assert (n < int (ratios.size()));
- vc->set_ratio (ratios[n]);
- }
-}
-
void
FilmEditor::sequence_video_changed (wxCommandEvent &)
{
class TimingPanel;
class SubtitlePanel;
class AudioPanel;
+class VideoPanel;
/** @class FilmEditor
* @brief A wx widget to edit a film's metadata, and perform various functions.
private:
void make_dcp_panel ();
void make_content_panel ();
- void make_video_panel ();
void connect_to_widgets ();
/* Handle changes to the view */
void name_changed (wxCommandEvent &);
void use_dci_name_toggled (wxCommandEvent &);
void edit_dci_button_clicked (wxCommandEvent &);
- void left_crop_changed (wxCommandEvent &);
- void right_crop_changed (wxCommandEvent &);
- void top_crop_changed (wxCommandEvent &);
- void bottom_crop_changed (wxCommandEvent &);
- void trust_content_headers_changed (wxCommandEvent &);
void content_selection_changed (wxListEvent &);
void content_add_clicked (wxCommandEvent &);
void content_remove_clicked (wxCommandEvent &);
- void imagemagick_video_length_changed (wxCommandEvent &);
void container_changed (wxCommandEvent &);
void dcp_content_type_changed (wxCommandEvent &);
void scaler_changed (wxCommandEvent &);
void j2k_bandwidth_changed (wxCommandEvent &);
void dcp_frame_rate_changed (wxCommandEvent &);
void best_dcp_frame_rate_clicked (wxCommandEvent &);
- void edit_filters_clicked (wxCommandEvent &);
void content_timeline_clicked (wxCommandEvent &);
- void ratio_changed (wxCommandEvent &);
void dcp_audio_channels_changed (wxCommandEvent &);
void dcp_resolution_changed (wxCommandEvent &);
void sequence_video_changed (wxCommandEvent &);
void film_content_changed (boost::weak_ptr<Content>, int);
void set_things_sensitive (bool);
- void setup_ratios ();
void setup_dcp_name ();
- void setup_scaling_description ();
void setup_content ();
void setup_container ();
void setup_content_sensitivity ();
void active_jobs_changed (bool);
+ VideoPanel* _video_panel;
AudioPanel* _audio_panel;
SubtitlePanel* _subtitle_panel;
TimingPanel* _timing_panel;
wxSizer* _dcp_sizer;
wxPanel* _content_panel;
wxSizer* _content_sizer;
- wxPanel* _video_panel;
/** The film we are editing */
boost::shared_ptr<Film> _film;
wxButton* _content_timeline;
wxCheckBox* _sequence_video;
wxButton* _edit_dci_button;
- wxChoice* _ratio;
- wxStaticText* _ratio_description;
- wxStaticText* _scaling_description;
- wxSpinCtrl* _left_crop;
- wxSpinCtrl* _right_crop;
- wxSpinCtrl* _top_crop;
- wxSpinCtrl* _bottom_crop;
- wxStaticText* _filters;
- wxButton* _filters_button;
wxChoice* _scaler;
wxSpinCtrl* _j2k_bandwidth;
wxChoice* _dcp_content_type;
FilmEditorPanel (FilmEditor *, wxString);
virtual void film_changed (Film::Property) {}
- virtual void film_content_changed (
- boost::shared_ptr<Content>,
- boost::shared_ptr<AudioContent>,
- boost::shared_ptr<SubtitleContent>,
- boost::shared_ptr<FFmpegContent>,
- int) = 0;
+ virtual void film_content_changed (boost::shared_ptr<Content>, int) = 0;
virtual void content_selection_changed () {}
protected:
class Film;
class FilterView;
+class Filter;
/** @class FilterDialog
* @brief A dialog to select FFmpeg filters.
}
void
-SubtitlePanel::film_content_changed (
- shared_ptr<Content>,
- shared_ptr<AudioContent>,
- shared_ptr<SubtitleContent> subtitle_content,
- shared_ptr<FFmpegContent> ffmpeg_content,
- int property
- )
+SubtitlePanel::film_content_changed (shared_ptr<Content> c, int property)
{
+ shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c);
+ shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+
if (property == FFmpegContentProperty::SUBTITLE_STREAMS) {
_stream->Clear ();
- if (ffmpeg_content) {
- vector<shared_ptr<FFmpegSubtitleStream> > s = ffmpeg_content->subtitle_streams ();
+ if (fc) {
+ vector<shared_ptr<FFmpegSubtitleStream> > s = fc->subtitle_streams ();
for (vector<shared_ptr<FFmpegSubtitleStream> >::iterator i = s.begin(); i != s.end(); ++i) {
_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
}
- if (ffmpeg_content->subtitle_stream()) {
- checked_set (_stream, lexical_cast<string> (ffmpeg_content->subtitle_stream()->id));
+ if (fc->subtitle_stream()) {
+ checked_set (_stream, lexical_cast<string> (fc->subtitle_stream()->id));
} else {
_stream->SetSelection (wxNOT_FOUND);
}
}
setup_control_sensitivity ();
} else if (property == SubtitleContentProperty::SUBTITLE_OFFSET) {
- checked_set (_offset, subtitle_content ? (subtitle_content->subtitle_offset() * 100) : 0);
+ checked_set (_offset, sc ? (sc->subtitle_offset() * 100) : 0);
} else if (property == SubtitleContentProperty::SUBTITLE_SCALE) {
- checked_set (_scale, subtitle_content ? (subtitle_content->subtitle_scale() * 100) : 100);
+ checked_set (_scale, sc ? (sc->subtitle_scale() * 100) : 100);
}
}
SubtitlePanel (FilmEditor *);
void film_changed (Film::Property);
- void film_content_changed (
- boost::shared_ptr<Content>,
- boost::shared_ptr<AudioContent>,
- boost::shared_ptr<SubtitleContent>,
- boost::shared_ptr<FFmpegContent>,
- int);
+ void film_content_changed (boost::shared_ptr<Content>, int);
void setup_control_sensitivity ();
}
void
-TimingPanel::film_content_changed (
- shared_ptr<Content> content,
- shared_ptr<AudioContent>,
- shared_ptr<SubtitleContent>,
- shared_ptr<FFmpegContent>,
- int property
- )
+TimingPanel::film_content_changed (shared_ptr<Content> content, int property)
{
if (property == ContentProperty::START) {
if (content) {
public:
TimingPanel (FilmEditor *);
- void film_content_changed (
- boost::shared_ptr<Content>,
- boost::shared_ptr<AudioContent>,
- boost::shared_ptr<SubtitleContent>,
- boost::shared_ptr<FFmpegContent>,
- int);
+ void film_content_changed (boost::shared_ptr<Content>, int);
private:
void start_changed ();
--- /dev/null
+/*
+ Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <wx/spinctrl.h>
+#include "lib/ratio.h"
+#include "lib/filter.h"
+#include "filter_dialog.h"
+#include "video_panel.h"
+#include "wx_util.h"
+#include "film_editor.h"
+
+using std::vector;
+using std::string;
+using std::pair;
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
+
+VideoPanel::VideoPanel (FilmEditor* e)
+ : FilmEditorPanel (e, _("Video"))
+{
+ wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ _sizer->Add (grid, 0, wxALL, 8);
+
+ int r = 0;
+ add_label_to_grid_bag_sizer (grid, this, _("Left crop"), true, wxGBPosition (r, 0));
+ _left_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
+ grid->Add (_left_crop, wxGBPosition (r, 1));
+ ++r;
+
+ add_label_to_grid_bag_sizer (grid, this, _("Right crop"), true, wxGBPosition (r, 0));
+ _right_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
+ grid->Add (_right_crop, wxGBPosition (r, 1));
+ ++r;
+
+ add_label_to_grid_bag_sizer (grid, this, _("Top crop"), true, wxGBPosition (r, 0));
+ _top_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
+ grid->Add (_top_crop, wxGBPosition (r, 1));
+ ++r;
+
+ add_label_to_grid_bag_sizer (grid, this, _("Bottom crop"), true, wxGBPosition (r, 0));
+ _bottom_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
+ grid->Add (_bottom_crop, wxGBPosition (r, 1));
+ ++r;
+
+ add_label_to_grid_bag_sizer (grid, this, _("Scale to"), true, wxGBPosition (r, 0));
+ _ratio = new wxChoice (this, wxID_ANY);
+ grid->Add (_ratio, wxGBPosition (r, 1));
+ ++r;
+
+ _scaling_description = new wxStaticText (this, 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;
+
+ {
+ 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"));
+ 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;
+
+ _left_crop->SetRange (0, 1024);
+ _top_crop->SetRange (0, 1024);
+ _right_crop->SetRange (0, 1024);
+ _bottom_crop->SetRange (0, 1024);
+
+ vector<Ratio const *> ratios = Ratio::all ();
+ _ratio->Clear ();
+ for (vector<Ratio const *>::iterator i = ratios.begin(); i != ratios.end(); ++i) {
+ _ratio->Append (std_to_wx ((*i)->nickname ()));
+ }
+
+ _ratio->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (VideoPanel::ratio_changed), 0, this);
+ _left_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::left_crop_changed), 0, this);
+ _right_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::right_crop_changed), 0, this);
+ _top_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::top_crop_changed), 0, this);
+ _bottom_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (VideoPanel::bottom_crop_changed), 0, this);
+ _filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (VideoPanel::edit_filters_clicked), 0, this);
+}
+
+
+/** Called when the left crop widget has been changed */
+void
+VideoPanel::left_crop_changed (wxCommandEvent &)
+{
+ shared_ptr<VideoContent> c = _editor->selected_video_content ();
+ if (!c) {
+ return;
+ }
+
+ c->set_left_crop (_left_crop->GetValue ());
+}
+
+/** Called when the right crop widget has been changed */
+void
+VideoPanel::right_crop_changed (wxCommandEvent &)
+{
+ shared_ptr<VideoContent> c = _editor->selected_video_content ();
+ if (!c) {
+ return;
+ }
+
+ c->set_right_crop (_right_crop->GetValue ());
+}
+
+/** Called when the top crop widget has been changed */
+void
+VideoPanel::top_crop_changed (wxCommandEvent &)
+{
+ shared_ptr<VideoContent> c = _editor->selected_video_content ();
+ if (!c) {
+ return;
+ }
+
+ c->set_top_crop (_top_crop->GetValue ());
+}
+
+/** Called when the bottom crop value has been changed */
+void
+VideoPanel::bottom_crop_changed (wxCommandEvent &)
+{
+ shared_ptr<VideoContent> c = _editor->selected_video_content ();
+ if (!c) {
+ return;
+ }
+
+ c->set_bottom_crop (_bottom_crop->GetValue ());
+}
+
+void
+VideoPanel::film_content_changed (shared_ptr<Content> c, int property)
+{
+ shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (c);
+ shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+
+ if (property == VideoContentProperty::VIDEO_CROP) {
+ checked_set (_left_crop, vc ? vc->crop().left : 0);
+ checked_set (_right_crop, vc ? vc->crop().right : 0);
+ checked_set (_top_crop, vc ? vc->crop().top : 0);
+ checked_set (_bottom_crop, vc ? vc->crop().bottom : 0);
+ setup_scaling_description ();
+ } else if (property == VideoContentProperty::VIDEO_RATIO) {
+ if (vc) {
+ int n = 0;
+ vector<Ratio const *> ratios = Ratio::all ();
+ vector<Ratio const *>::iterator i = ratios.begin ();
+ while (i != ratios.end() && *i != vc->ratio()) {
+ ++i;
+ ++n;
+ }
+
+ if (i == ratios.end()) {
+ checked_set (_ratio, -1);
+ } else {
+ checked_set (_ratio, n);
+ }
+ } else {
+ checked_set (_ratio, -1);
+ }
+ setup_scaling_description ();
+ } else if (property == FFmpegContentProperty::FILTERS) {
+ if (fc) {
+ pair<string, string> p = Filter::ffmpeg_strings (fc->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));
+ }
+ }
+ }
+}
+
+/** Called when the `Edit filters' button has been clicked */
+void
+VideoPanel::edit_filters_clicked (wxCommandEvent &)
+{
+ shared_ptr<Content> c = _editor->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
+VideoPanel::setup_scaling_description ()
+{
+ shared_ptr<VideoContent> vc = _editor->selected_video_content ();
+ if (!vc) {
+ _scaling_description->SetLabel ("");
+ return;
+ }
+
+ wxString d;
+
+ int lines = 0;
+
+ if (vc->video_size().width && vc->video_size().height) {
+ d << wxString::Format (
+ _("Original video is %dx%d (%.2f:1)\n"),
+ vc->video_size().width, vc->video_size().height,
+ float (vc->video_size().width) / vc->video_size().height
+ );
+ ++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;
+ d << wxString::Format (
+ _("Cropped to %dx%d (%.2f:1)\n"),
+ cropped.width, cropped.height,
+ float (cropped.width) / cropped.height
+ );
+ ++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);
+ d << wxString::Format (
+ _("Scaled to %dx%d (%.2f:1)\n"),
+ scaled.width, scaled.height,
+ float (scaled.width) / scaled.height
+ );
+ ++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;
+ }
+ }
+
+ for (int i = lines; i < 4; ++i) {
+ d << wxT ("\n ");
+ }
+
+ _scaling_description->SetLabel (d);
+}
+
+
+void
+VideoPanel::ratio_changed (wxCommandEvent &)
+{
+ if (!_editor->film ()) {
+ return;
+ }
+
+ shared_ptr<VideoContent> vc = _editor->selected_video_content ();
+
+ int const n = _ratio->GetSelection ();
+ if (n >= 0) {
+ vector<Ratio const *> ratios = Ratio::all ();
+ assert (n < int (ratios.size()));
+ vc->set_ratio (ratios[n]);
+ }
+}
--- /dev/null
+/*
+ Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "film_editor_panel.h"
+
+class wxChoice;
+class wxStaticText;
+class wxSpinCtrl;
+class wxButton;
+
+class VideoPanel : public FilmEditorPanel
+{
+public:
+ VideoPanel (FilmEditor *);
+
+ void film_content_changed (boost::shared_ptr<Content>, int);
+
+ void setup_scaling_description ();
+
+private:
+ void left_crop_changed (wxCommandEvent &);
+ void right_crop_changed (wxCommandEvent &);
+ void top_crop_changed (wxCommandEvent &);
+ void bottom_crop_changed (wxCommandEvent &);
+ void edit_filters_clicked (wxCommandEvent &);
+ void ratio_changed (wxCommandEvent &);
+
+ wxChoice* _ratio;
+ wxStaticText* _ratio_description;
+ wxStaticText* _scaling_description;
+ wxSpinCtrl* _left_crop;
+ wxSpinCtrl* _right_crop;
+ wxSpinCtrl* _top_crop;
+ wxSpinCtrl* _bottom_crop;
+ wxStaticText* _filters;
+ wxButton* _filters_button;
+};
timeline.cc
timeline_dialog.cc
timing_panel.cc
+ video_panel.cc
wx_util.cc
wx_ui_signaller.cc
"""