diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-04-06 12:26:12 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-04-06 12:26:12 +0100 |
| commit | 1bff0990433ab0ce588acaef7c589fa623bd998b (patch) | |
| tree | 65cba435e949deb6359bbf75866b52684116df06 /src/wx | |
| parent | 3429cf48ff2ce056413588be4151be82c8114861 (diff) | |
Add interface to set up still image lengths.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/film_editor.cc | 132 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 9 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 41 | ||||
| -rw-r--r-- | src/wx/film_viewer.h | 2 |
4 files changed, 109 insertions, 75 deletions
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index efbf212d0..58fc077a3 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -59,13 +59,13 @@ using std::setprecision; using std::list; using std::vector; using boost::shared_ptr; +using boost::weak_ptr; using boost::dynamic_pointer_cast; using boost::lexical_cast; /** @param f Film to edit */ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent) : wxPanel (parent) - , _film (f) , _generally_sensitive (true) , _audio_dialog (0) { @@ -84,7 +84,7 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent) make_subtitle_panel (); _notebook->AddPage (_subtitle_panel, _("Subtitles"), false); - set_film (_film); + set_film (f); connect_to_widgets (); JobManager::instance()->ActiveJobsChanged.connect ( @@ -200,6 +200,7 @@ FilmEditor::connect_to_widgets () _content_remove->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_remove_clicked), 0, this); _content_earlier->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_earlier_clicked), 0, this); _content_later->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_later_clicked), 0, this); + _imagemagick_video_length->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::imagemagick_video_length_changed), 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); @@ -354,6 +355,21 @@ FilmEditor::make_content_panel () _content_information = new wxTextCtrl (_content_panel, wxID_ANY, wxT ("\n\n\n\n"), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_MULTILINE); _content_sizer->Add (_content_information, 1, wxEXPAND | wxALL, 6); + + wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4); + _content_sizer->Add (grid, 0, wxEXPAND | wxALL, 6); + + { + add_label_to_sizer (grid, _content_panel, (_("Duration"))); + wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + _imagemagick_video_length = new wxSpinCtrl (_content_panel); + s->Add (_imagemagick_video_length); + /// TRANSLATORS: this is an abbreviation for seconds, the unit of time + add_label_to_sizer (s, _content_panel, _("s")); + grid->Add (s); + } + + _imagemagick_video_length->SetRange (1, 3600); } void @@ -690,7 +706,7 @@ FilmEditor::film_changed (Film::Property p) } void -FilmEditor::film_content_changed (int p) +FilmEditor::film_content_changed (weak_ptr<Content> content, int property) { if (!_film) { /* We call this method ourselves (as well as using it as a signal handler) @@ -699,23 +715,31 @@ FilmEditor::film_content_changed (int p) return; } - if (p == FFmpegContentProperty::SUBTITLE_STREAMS) { + if (property == FFmpegContentProperty::SUBTITLE_STREAMS) { setup_subtitle_control_sensitivity (); setup_streams (); - } else if (p == FFmpegContentProperty::AUDIO_STREAMS) { + } else if (property == FFmpegContentProperty::AUDIO_STREAMS) { setup_streams (); setup_show_audio_sensitivity (); - } else if (p == VideoContentProperty::VIDEO_LENGTH) { + } else if (property == VideoContentProperty::VIDEO_LENGTH) { setup_length (); - setup_content_information (); - } else if (p == FFmpegContentProperty::AUDIO_STREAM) { + + boost::shared_ptr<Content> c = content.lock (); + if (c && c == selected_content()) { + setup_content_information (); + shared_ptr<ImageMagickContent> im = dynamic_pointer_cast<ImageMagickContent> (c); + if (im) { + checked_set (_imagemagick_video_length, im->video_length() / 24); + } + } + } else if (property == FFmpegContentProperty::AUDIO_STREAM) { if (_film->ffmpeg_audio_stream()) { checked_set (_ffmpeg_audio_stream, boost::lexical_cast<string> (_film->ffmpeg_audio_stream()->id)); } setup_dcp_name (); setup_audio_details (); setup_show_audio_sensitivity (); - } else if (p == FFmpegContentProperty::SUBTITLE_STREAM) { + } else if (property == FFmpegContentProperty::SUBTITLE_STREAM) { if (_film->ffmpeg_subtitle_stream()) { checked_set (_ffmpeg_subtitle_stream, boost::lexical_cast<string> (_film->ffmpeg_subtitle_stream()->id)); } @@ -797,13 +821,17 @@ FilmEditor::dcp_content_type_changed (wxCommandEvent &) void FilmEditor::set_film (shared_ptr<Film> f) { + 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)); + _film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _1, _2)); } if (_film) { @@ -838,10 +866,10 @@ FilmEditor::set_film (shared_ptr<Film> f) film_changed (Film::DCI_METADATA); film_changed (Film::DCP_FRAME_RATE); - film_content_changed (FFmpegContentProperty::SUBTITLE_STREAMS); - film_content_changed (FFmpegContentProperty::SUBTITLE_STREAM); - film_content_changed (FFmpegContentProperty::AUDIO_STREAMS); - film_content_changed (FFmpegContentProperty::AUDIO_STREAM); + film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::SUBTITLE_STREAMS); + film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::SUBTITLE_STREAM); + film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::AUDIO_STREAMS); + film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::AUDIO_STREAM); } /** Updates the sensitivity of lots of widgets to a given value. @@ -1224,40 +1252,28 @@ FilmEditor::content_add_clicked (wxCommandEvent &) void FilmEditor::content_remove_clicked (wxCommandEvent &) { - int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - if (s == -1) { - return; + shared_ptr<Content> c = selected_content (); + if (c) { + _film->remove_content (c); } - - ContentList c = _film->content (); - assert (s >= 0 && size_t (s) < c.size ()); - _film->remove_content (c[s]); } void FilmEditor::content_earlier_clicked (wxCommandEvent &) { - int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - if (s == -1) { - return; + shared_ptr<Content> c = selected_content (); + if (c) { + _film->move_content_earlier (c); } - - ContentList c = _film->content (); - assert (s >= 0 && size_t (s) < c.size ()); - _film->move_content_earlier (c[s]); } void FilmEditor::content_later_clicked (wxCommandEvent &) { - int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - if (s == -1) { - return; + shared_ptr<Content> c = selected_content (); + if (c) { + _film->move_content_later (c); } - - ContentList c = _film->content (); - assert (s >= 0 && size_t (s) < c.size ()); - _film->move_content_later (c[s]); } void @@ -1265,20 +1281,27 @@ FilmEditor::content_item_selected (wxListEvent &) { setup_content_button_sensitivity (); setup_content_information (); + + shared_ptr<Content> c = selected_content (); + if (c) { + shared_ptr<ImageMagickContent> im = dynamic_pointer_cast<ImageMagickContent> (c); + _imagemagick_video_length->Enable (im); + if (im) { + checked_set (_imagemagick_video_length, im->video_length() / 24); + } + } } void FilmEditor::setup_content_information () { - int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - if (s == -1) { + shared_ptr<Content> c = selected_content (); + if (!c) { _content_information->SetValue (wxT ("")); return; } - ContentList c = _film->content (); - assert (s >= 0 && size_t (s) < c.size ()); - _content_information->SetValue (std_to_wx (c[s]->information ())); + _content_information->SetValue (std_to_wx (c->information ())); } void @@ -1291,3 +1314,32 @@ FilmEditor::setup_content_button_sensitivity () _content_earlier->Enable (have_selection && _generally_sensitive); _content_later->Enable (have_selection && _generally_sensitive); } + +void +FilmEditor::imagemagick_video_length_changed (wxCommandEvent &) +{ + shared_ptr<Content> c = selected_content (); + if (!c) { + return; + } + + shared_ptr<ImageMagickContent> im = dynamic_pointer_cast<ImageMagickContent> (c); + if (!im) { + return; + } + + im->set_video_length (_imagemagick_video_length->GetValue() * 24); +} + +shared_ptr<Content> +FilmEditor::selected_content () +{ + int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + if (s == -1) { + return shared_ptr<Content> (); + } + + ContentList c = _film->content (); + assert (s >= 0 && size_t (s) < c.size ()); + return c[s]; +} diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 97d1e0dd3..2870714f9 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -68,6 +68,7 @@ private: void content_remove_clicked (wxCommandEvent &); void content_earlier_clicked (wxCommandEvent &); void content_later_clicked (wxCommandEvent &); + void imagemagick_video_length_changed (wxCommandEvent &); void format_changed (wxCommandEvent &); void trim_start_changed (wxCommandEvent &); void trim_end_changed (wxCommandEvent &); @@ -87,13 +88,11 @@ private: void ffmpeg_subtitle_stream_changed (wxCommandEvent &); void dcp_frame_rate_changed (wxCommandEvent &); void best_dcp_frame_rate_clicked (wxCommandEvent &); + void edit_filters_clicked (wxCommandEvent &); /* Handle changes to the model */ void film_changed (Film::Property); - void film_content_changed (int); - - /* Button clicks */ - void edit_filters_clicked (wxCommandEvent &); + void film_content_changed (boost::weak_ptr<Content>, int); void set_things_sensitive (bool); void setup_formats (); @@ -109,6 +108,7 @@ private: void setup_content_information (); void active_jobs_changed (bool); + boost::shared_ptr<Content> selected_content (); wxNotebook* _notebook; wxPanel* _film_panel; @@ -134,6 +134,7 @@ private: wxButton* _content_earlier; wxButton* _content_later; wxTextCtrl* _content_information; + wxSpinCtrl* _imagemagick_video_length; wxButton* _edit_dci_button; wxChoice* _format; wxStaticText* _format_description; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 316a42a66..08358c519 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -37,6 +37,7 @@ #include "lib/player.h" #include "lib/video_content.h" #include "lib/ffmpeg_content.h" +#include "lib/imagemagick_content.h" #include "film_viewer.h" #include "wx_util.h" #include "video_decoder.h" @@ -47,6 +48,7 @@ using std::max; using std::cout; using std::list; using boost::shared_ptr; +using boost::dynamic_pointer_cast; using libdcp::Size; FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p) @@ -84,6 +86,16 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p) set_film (f); + _player = _film->player (); + _player->disable_audio (); + _player->disable_video_sync (); + + /* Don't disable subtitles here as we may need them, and it's nice to be able to turn them + on and off without needing obtain a new Player. + */ + + _player->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3)); + JobManager::instance()->ActiveJobsChanged.connect ( bind (&FilmViewer::active_jobs_changed, this, _1) ); @@ -99,7 +111,6 @@ FilmViewer::film_changed (Film::Property p) break; case Film::CONTENT: { - setup_player (); calculate_sizes (); get_frame (); _panel->Refresh (); @@ -124,32 +135,6 @@ FilmViewer::film_changed (Film::Property p) } void -FilmViewer::setup_player () -{ - _player = _film->player (); - _player->disable_audio (); - _player->disable_video_sync (); - - /* Don't disable subtitles here as we may need them, and it's nice to be able to turn them - on and off without needing obtain a new Player. - */ - - _player->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3)); -} - -void -FilmViewer::film_content_changed (int p) -{ - if (p == VideoContentProperty::VIDEO_LENGTH || p == VideoContentProperty::VIDEO_SIZE) { - setup_player (); - calculate_sizes (); - get_frame (); - _panel->Refresh (); - _v_sizer->Layout (); - } -} - -void FilmViewer::set_film (shared_ptr<Film> f) { if (_film == f) { @@ -163,14 +148,12 @@ FilmViewer::set_film (shared_ptr<Film> f) } _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1)); - _film->ContentChanged.connect (boost::bind (&FilmViewer::film_content_changed, this, _1)); film_changed (Film::CONTENT); film_changed (Film::FORMAT); film_changed (Film::WITH_SUBTITLES); film_changed (Film::SUBTITLE_OFFSET); film_changed (Film::SUBTITLE_SCALE); - film_content_changed (FFmpegContentProperty::SUBTITLE_STREAM); } void diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index bf956ef95..22f443703 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -61,7 +61,6 @@ public: private: void film_changed (Film::Property); - void film_content_changed (int); void paint_panel (wxPaintEvent &); void panel_sized (wxSizeEvent &); void slider_moved (wxScrollEvent &); @@ -75,7 +74,6 @@ private: void raw_to_display (); void get_frame (); void active_jobs_changed (bool); - void setup_player (); boost::shared_ptr<Film> _film; boost::shared_ptr<Player> _player; |
