diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-04-06 14:42:08 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-04-06 14:42:08 +0100 |
| commit | 8750efb9e072cf3b42e6c3c29521c7031c0b5dfd (patch) | |
| tree | 0f0dd00b0413763b678ed2388b849cfe45a88468 /src/wx | |
| parent | 1bff0990433ab0ce588acaef7c589fa623bd998b (diff) | |
Basics of content dialogs.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/audio_dialog.cc | 7 | ||||
| -rw-r--r-- | src/wx/film_editor.cc | 79 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 5 | ||||
| -rw-r--r-- | src/wx/imagemagick_content_dialog.cc | 62 | ||||
| -rw-r--r-- | src/wx/imagemagick_content_dialog.h | 34 | ||||
| -rw-r--r-- | src/wx/sndfile_content_dialog.cc | 67 | ||||
| -rw-r--r-- | src/wx/sndfile_content_dialog.h | 36 | ||||
| -rw-r--r-- | src/wx/wscript | 2 |
8 files changed, 241 insertions, 51 deletions
diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index 1241c2e76..f53ea7c19 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -20,6 +20,7 @@ #include <boost/filesystem.hpp> #include "lib/audio_analysis.h" #include "lib/film.h" +#include "lib/audio_mapping.h" #include "audio_dialog.h" #include "audio_plot.h" #include "wx_util.h" @@ -108,7 +109,7 @@ AudioDialog::setup_channels () return; } - AudioMapping m (_film->audio_channels ()); + AutomaticAudioMapping m (_film->audio_channels ()); for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) { if (m.dcp_to_source(static_cast<libdcp::Channel>(i))) { @@ -134,7 +135,7 @@ AudioDialog::try_to_load_analysis () _plot->set_analysis (a); - AudioMapping m (_film->audio_channels ()); + AutomaticAudioMapping m (_film->audio_channels ()); optional<libdcp::Channel> c = m.source_to_dcp (0); if (c) { _channel_checkbox[c.get()]->SetValue (true); @@ -157,7 +158,7 @@ AudioDialog::channel_clicked (wxCommandEvent& ev) assert (c < MAX_AUDIO_CHANNELS); - AudioMapping m (_film->audio_channels ()); + AutomaticAudioMapping m (_film->audio_channels ()); optional<int> s = m.dcp_to_source (static_cast<libdcp::Channel> (c)); if (s) { _plot->set_channel_visible (s.get(), _channel_checkbox[c]->GetValue ()); diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 58fc077a3..6c42359fb 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -49,6 +49,8 @@ #include "dci_metadata_dialog.h" #include "scaler.h" #include "audio_dialog.h" +#include "imagemagick_content_dialog.h" +#include "sndfile_content_dialog.h" using std::string; using std::cout; @@ -198,9 +200,9 @@ FilmEditor::connect_to_widgets () _content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler (FilmEditor::content_item_selected), 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); _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); @@ -343,6 +345,8 @@ FilmEditor::make_content_panel () b->Add (_content_add); _content_remove = new wxButton (_content_panel, wxID_ANY, _("Remove")); b->Add (_content_remove); + _content_edit = new wxButton (_content_panel, wxID_ANY, _("Edit...")); + b->Add (_content_edit); _content_earlier = new wxButton (_content_panel, wxID_ANY, _("Earlier")); b->Add (_content_earlier); _content_later = new wxButton (_content_panel, wxID_ANY, _("Later")); @@ -355,21 +359,6 @@ 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 @@ -723,14 +712,9 @@ FilmEditor::film_content_changed (weak_ptr<Content> content, int property) setup_show_audio_sensitivity (); } else if (property == VideoContentProperty::VIDEO_LENGTH) { setup_length (); - 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()) { @@ -1259,6 +1243,33 @@ FilmEditor::content_remove_clicked (wxCommandEvent &) } void +FilmEditor::content_edit_clicked (wxCommandEvent &) +{ + shared_ptr<Content> c = selected_content (); + if (!c) { + return; + } + + shared_ptr<ImageMagickContent> im = dynamic_pointer_cast<ImageMagickContent> (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<SndfileContent> sf = dynamic_pointer_cast<SndfileContent> (c); + if (sf) { + SndfileContentDialog* d = new SndfileContentDialog (this, sf); + d->ShowModal (); + d->Destroy (); + } +} + +void FilmEditor::content_earlier_clicked (wxCommandEvent &) { shared_ptr<Content> c = selected_content (); @@ -1281,15 +1292,6 @@ 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 @@ -1310,27 +1312,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); } -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 () { diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 2870714f9..b6f6a24ee 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -16,7 +16,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + /** @file src/film_editor.h * @brief A wx widget to edit a film's metadata, and perform various functions. */ @@ -66,6 +66,7 @@ private: void content_item_selected (wxListEvent &); void content_add_clicked (wxCommandEvent &); void content_remove_clicked (wxCommandEvent &); + void content_edit_clicked (wxCommandEvent &); void content_earlier_clicked (wxCommandEvent &); void content_later_clicked (wxCommandEvent &); void imagemagick_video_length_changed (wxCommandEvent &); @@ -131,10 +132,10 @@ private: wxListCtrl* _content; wxButton* _content_add; wxButton* _content_remove; + wxButton* _content_edit; 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/imagemagick_content_dialog.cc b/src/wx/imagemagick_content_dialog.cc new file mode 100644 index 000000000..726e4b8e2 --- /dev/null +++ b/src/wx/imagemagick_content_dialog.cc @@ -0,0 +1,62 @@ +/* + Copyright (C) 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/imagemagick_content.h" +#include "imagemagick_content_dialog.h" +#include "wx_util.h" + +using boost::shared_ptr; + +ImageMagickContentDialog::ImageMagickContentDialog (wxWindow* parent, shared_ptr<ImageMagickContent> content) + : wxDialog (parent, wxID_ANY, _("Image")) +{ + wxFlexGridSizer* grid = new wxFlexGridSizer (3, 6, 6); + grid->AddGrowableCol (1, 1); + + { + add_label_to_sizer (grid, this, (_("Duration"))); + wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + _video_length = new wxSpinCtrl (this); + s->Add (_video_length); + /// TRANSLATORS: this is an abbreviation for seconds, the unit of time + add_label_to_sizer (s, this, _("s")); + grid->Add (s); + } + + wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); + overall_sizer->Add (grid, 1, wxEXPAND | wxALL, 6); + + wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); + if (buttons) { + overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + } + + SetSizer (overall_sizer); + overall_sizer->Layout (); + overall_sizer->SetSizeHints (this); + + checked_set (_video_length, content->video_length () / 24); +} + +int +ImageMagickContentDialog::video_length () const +{ + return _video_length->GetValue (); +} diff --git a/src/wx/imagemagick_content_dialog.h b/src/wx/imagemagick_content_dialog.h new file mode 100644 index 000000000..2fa955929 --- /dev/null +++ b/src/wx/imagemagick_content_dialog.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 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/wx.h> + +class wxSpinCtrl; +class ImageMagickContent; + +class ImageMagickContentDialog : public wxDialog +{ +public: + ImageMagickContentDialog (wxWindow *, boost::shared_ptr<ImageMagickContent>); + + int video_length () const; + +private: + wxSpinCtrl* _video_length; +}; diff --git a/src/wx/sndfile_content_dialog.cc b/src/wx/sndfile_content_dialog.cc new file mode 100644 index 000000000..f305b158c --- /dev/null +++ b/src/wx/sndfile_content_dialog.cc @@ -0,0 +1,67 @@ +/* + Copyright (C) 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 "lib/util.h" +#include "lib/sndfile_content.h" +#include "sndfile_content_dialog.h" +#include "wx_util.h" + +using boost::shared_ptr; + +SndfileContentDialog::SndfileContentDialog (wxWindow* parent, shared_ptr<SndfileContent> content) + : wxDialog (parent, wxID_ANY, _("Sound file")) +{ + wxFlexGridSizer* grid = new wxFlexGridSizer (7, 6, 0); + + add_label_to_sizer (grid, this, wxT ("")); + add_label_to_sizer (grid, this, _("L")); + add_label_to_sizer (grid, this, _("R")); + add_label_to_sizer (grid, this, _("C")); + add_label_to_sizer (grid, this, _("Lfe")); + add_label_to_sizer (grid, this, _("Ls")); + add_label_to_sizer (grid, this, _("Rs")); + + _buttons.resize (content->audio_channels ()); + for (int i = 0; i < content->audio_channels(); ++i) { + + if (content->audio_channels() == 1) { + add_label_to_sizer (grid, this, _("Source")); + } else { + add_label_to_sizer (grid, this, wxString::Format (_("Source %d"), i + 1)); + } + + for (int j = 0; j < MAX_AUDIO_CHANNELS; ++j) { + wxRadioButton* b = new wxRadioButton (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, j ? 0 : wxRB_GROUP); + _buttons[i].push_back (b); + grid->Add (b, wxSHRINK); + } + } + + wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); + overall_sizer->Add (grid, 1, wxEXPAND | wxALL, 6); + + wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); + if (buttons) { + overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + } + + SetSizer (overall_sizer); + overall_sizer->Layout (); + overall_sizer->SetSizeHints (this); +} diff --git a/src/wx/sndfile_content_dialog.h b/src/wx/sndfile_content_dialog.h new file mode 100644 index 000000000..5a328892a --- /dev/null +++ b/src/wx/sndfile_content_dialog.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 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 <vector> +#include <boost/shared_ptr.hpp> +#include <wx/wx.h> +#include "lib/audio_mapping.h" + +class SndfileContent; + +class SndfileContentDialog : public wxDialog +{ +public: + SndfileContentDialog (wxWindow *, boost::shared_ptr<SndfileContent>); + + ConfiguredAudioMapping audio_mapping () const; + +private: + std::vector<std::vector<wxRadioButton *> > _buttons; +}; diff --git a/src/wx/wscript b/src/wx/wscript index 42bb8ca88..bd21af6ce 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -14,11 +14,13 @@ sources = """ filter_dialog.cc filter_view.cc gain_calculator_dialog.cc + imagemagick_content_dialog.cc job_manager_view.cc job_wrapper.cc new_film_dialog.cc properties_dialog.cc server_dialog.cc + sndfile_content_dialog.cc wx_util.cc wx_ui_signaller.cc """ |
