X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ftiming_panel.cc;h=06d655b6bde6138a9411f3616e01828b3a9cacbd;hb=e9e8951e0961564121f9c6cc4ce87555eebf9ec8;hp=aa4f70a81b476c715c8e068a27764eaa30636abc;hpb=888eedd469b461cd51a384518e075dbee9f6834f;p=dcpomatic.git diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index aa4f70a81..06d655b6b 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -1,144 +1,312 @@ /* - Copyright (C) 2012-2013 Carl Hetherington + Copyright (C) 2012-2018 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic 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, + DCP-o-matic 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. + along with DCP-o-matic. If not, see . */ -#include -#include "lib/content.h" -#include "lib/image_content.h" #include "timing_panel.h" #include "wx_util.h" +#include "film_viewer.h" #include "timecode.h" -#include "film_editor.h" +#include "content_panel.h" +#include "move_to_dialog.h" +#include "static_text.h" +#include "dcpomatic_button.h" +#include "lib/content.h" +#include "lib/image_content.h" +#include "lib/text_content.h" +#include "lib/dcp_subtitle_content.h" +#include "lib/audio_content.h" +#include "lib/string_text_file_content.h" +#include "lib/video_content.h" +#include "lib/dcp_content.h" +#include "lib/ffmpeg_content.h" +#include +#include +#include +#include using std::cout; using std::string; using std::set; using boost::shared_ptr; +using boost::weak_ptr; using boost::dynamic_pointer_cast; -using libdcp::raw_convert; +using boost::optional; +using dcp::locale_convert; +using namespace dcpomatic; -TimingPanel::TimingPanel (FilmEditor* e) +TimingPanel::TimingPanel (ContentPanel* p, weak_ptr viewer) /* horrid hack for apparent lack of context support with wxWidgets i18n code */ - : FilmEditorPanel (e, S_("Timing|Timing")) + /// TRANSLATORS: translate the word "Timing" here; do not include the "Timing|" prefix + : ContentSubPanel (p, S_("Timing|Timing")) + , _viewer (viewer) { - wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4); - _sizer->Add (grid, 0, wxALL, 8); - - add_label_to_sizer (grid, this, _("Position"), true); - _position = new Timecode (this); - grid->Add (_position); - add_label_to_sizer (grid, this, _("Full length"), true); - _full_length = new Timecode (this); - grid->Add (_full_length); - add_label_to_sizer (grid, this, _("Trim from start"), true); - _trim_start = new Timecode (this); - grid->Add (_trim_start); - add_label_to_sizer (grid, this, _("Trim from end"), true); - _trim_end = new Timecode (this); - grid->Add (_trim_end); - add_label_to_sizer (grid, this, _("Play length"), true); - _play_length = new Timecode (this); - grid->Add (_play_length); - - { - add_label_to_sizer (grid, this, _("Video frame rate"), true); - wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); - _video_frame_rate = new wxTextCtrl (this, wxID_ANY); - s->Add (_video_frame_rate, 1, wxEXPAND); - _set_video_frame_rate = new wxButton (this, wxID_ANY, _("Set")); - _set_video_frame_rate->Enable (false); - s->Add (_set_video_frame_rate, 0, wxLEFT | wxRIGHT, 8); - grid->Add (s, 1, wxEXPAND); + wxSize size = TimecodeBase::size (this); + + for (int i = 0; i < 3; ++i) { + _colon[i] = create_label (this, wxT(":"), false); } + //// TRANSLATORS: this is an abbreviation for "hours" + _h_label = new StaticText (this, _("h"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL); +#ifdef DCPOMATIC_LINUX + /* Hack to work around failure to centre text on GTK */ + gtk_label_set_line_wrap (GTK_LABEL(_h_label->GetHandle()), FALSE); +#endif + //// TRANSLATORS: this is an abbreviation for "minutes" + _m_label = new StaticText (this, _("m"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL); +#ifdef DCPOMATIC_LINUX + gtk_label_set_line_wrap (GTK_LABEL (_m_label->GetHandle()), FALSE); +#endif + //// TRANSLATORS: this is an abbreviation for "seconds" + _s_label = new StaticText (this, _("s"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL); +#ifdef DCPOMATIC_LINUX + gtk_label_set_line_wrap (GTK_LABEL(_s_label->GetHandle()), FALSE); +#endif + //// TRANSLATORS: this is an abbreviation for "frames" + _f_label = new StaticText (this, _("f"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL); +#ifdef DCPOMATIC_LINUX + gtk_label_set_line_wrap (GTK_LABEL(_f_label->GetHandle()), FALSE); +#endif + + _position_label = create_label (this, _("Position"), true); + _position = new Timecode (this); + _move_to_start_of_reel = new Button (this, _("Move to start of reel")); + _full_length_label = create_label (this, _("Full length"), true); + _full_length = new Timecode (this); + _trim_start_label = create_label (this, _("Trim from start"), true); + _trim_start = new Timecode (this); + _trim_start_to_playhead = new Button (this, _("Trim up to current position")); + _trim_end_label = create_label (this, _("Trim from end"), true); + _trim_end = new Timecode (this); + _trim_end_to_playhead = new Button (this, _("Trim after current position")); + _play_length_label = create_label (this, _("Play length"), true); + _play_length = new Timecode (this); + + _video_frame_rate_label = create_label (this, _("Video frame rate"), true); + _video_frame_rate = new wxTextCtrl (this, wxID_ANY); + _set_video_frame_rate = new Button (this, _("Set")); + _set_video_frame_rate->Enable (false); + + /* We can't use Wrap() here as it doesn't work with markup: + * http://trac.wxwidgets.org/ticket/13389 + */ + + wxString in = _("Only change this if the content's frame rate has been read incorrectly."); + wxString out; + int const width = 20; + int current = 0; + for (size_t i = 0; i < in.Length(); ++i) { + if (in[i] == ' ' && current >= width) { + out += '\n'; + current = 0; + } else { + out += in[i]; + ++current; + } + } + + _tip = new StaticText (this, wxT ("")); + _tip->SetLabelMarkup (out); +#ifdef DCPOMATIC_OSX + /* Hack to stop hidden text on some versions of OS X */ + _tip->SetMinSize (wxSize (-1, 256)); +#endif + _position->Changed.connect (boost::bind (&TimingPanel::position_changed, this)); + _move_to_start_of_reel->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::move_to_start_of_reel_clicked, this)); _full_length->Changed.connect (boost::bind (&TimingPanel::full_length_changed, this)); _trim_start->Changed.connect (boost::bind (&TimingPanel::trim_start_changed, this)); + _trim_start_to_playhead->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::trim_start_to_playhead_clicked, this)); _trim_end->Changed.connect (boost::bind (&TimingPanel::trim_end_changed, this)); + _trim_end_to_playhead->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::trim_end_to_playhead_clicked, this)); _play_length->Changed.connect (boost::bind (&TimingPanel::play_length_changed, this)); - _video_frame_rate->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimingPanel::video_frame_rate_changed, this)); - _set_video_frame_rate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimingPanel::set_video_frame_rate, this)); + _video_frame_rate->Bind (wxEVT_TEXT, boost::bind (&TimingPanel::video_frame_rate_changed, this)); + _set_video_frame_rate->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::set_video_frame_rate, this)); + + shared_ptr fv = _viewer.lock (); + DCPOMATIC_ASSERT (fv); + fv->ImageChanged.connect (boost::bind (&TimingPanel::setup_sensitivity, this)); + + setup_sensitivity (); + add_to_grid (); +} + +void +TimingPanel::add_to_grid () +{ + bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL; + + int r = 0; + + wxSizer* labels = new wxBoxSizer (wxHORIZONTAL); + labels->Add (_h_label, 1, wxEXPAND); + add_label_to_sizer (labels, _colon[0], false); + labels->Add (_m_label, 1, wxEXPAND); + add_label_to_sizer (labels, _colon[1], false); + labels->Add (_s_label, 1, wxEXPAND); + add_label_to_sizer (labels, _colon[2], false); + labels->Add (_f_label, 1, wxEXPAND); + _grid->Add (labels, wxGBPosition(r, 1)); + ++r; + + add_label_to_sizer (_grid, _position_label, true, wxGBPosition(r, 0)); + _grid->Add (_position, wxGBPosition(r, 1)); + ++r; + + _move_to_start_of_reel->Show (full); + _full_length_label->Show (full); + _full_length->Show (full); + _play_length_label->Show (full); + _play_length->Show (full); + _video_frame_rate_label->Show (full); + _video_frame_rate->Show (full); + _set_video_frame_rate->Show (full); + _tip->Show (full); + + if (full) { + _grid->Add (_move_to_start_of_reel, wxGBPosition(r, 1)); + ++r; + + add_label_to_sizer (_grid, _full_length_label, true, wxGBPosition(r, 0)); + _grid->Add (_full_length, wxGBPosition(r, 1)); + ++r; + } + + add_label_to_sizer (_grid, _trim_start_label, true, wxGBPosition(r, 0)); + _grid->Add (_trim_start, wxGBPosition(r, 1)); + ++r; + + _grid->Add (_trim_start_to_playhead, wxGBPosition(r, 1)); + ++r; + + add_label_to_sizer (_grid, _trim_end_label, true, wxGBPosition(r, 0)); + _grid->Add (_trim_end, wxGBPosition(r, 1)); + ++r; + + _grid->Add (_trim_end_to_playhead, wxGBPosition(r, 1)); + ++r; + + if (full) { + add_label_to_sizer (_grid, _play_length_label, true, wxGBPosition(r, 0)); + _grid->Add (_play_length, wxGBPosition(r, 1)); + ++r; + + { + add_label_to_sizer (_grid, _video_frame_rate_label, true, wxGBPosition(r, 0)); + wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + s->Add (_video_frame_rate, 1, wxEXPAND); + s->Add (_set_video_frame_rate, 0, wxLEFT | wxRIGHT, 8); + _grid->Add (s, wxGBPosition(r, 1), wxGBSpan(1, 2)); + } + ++r; + + _grid->Add (_tip, wxGBPosition(r, 1), wxGBSpan(1, 2)); + } + + /* Completely speculative fix for #891 */ + _grid->Layout (); +} + +void +TimingPanel::update_full_length () +{ + set check; + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + check.insert (i->full_length(_parent->film())); + } + + if (check.size() == 1) { + _full_length->set (_parent->selected().front()->full_length(_parent->film()), _parent->film()->video_frame_rate()); + } else { + _full_length->clear (); + } +} + +void +TimingPanel::update_play_length () +{ + set check; + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + check.insert (i->length_after_trim(_parent->film())); + } + + if (check.size() == 1) { + _play_length->set (_parent->selected().front()->length_after_trim(_parent->film()), _parent->film()->video_frame_rate()); + } else { + _play_length->clear (); + } } void TimingPanel::film_content_changed (int property) { - ContentList cl = _editor->selected_content (); - int const film_video_frame_rate = _editor->film()->video_frame_rate (); + int const film_video_frame_rate = _parent->film()->video_frame_rate (); /* Here we check to see if we have exactly one different value of various properties, and fill the controls with that value if so. */ - + if (property == ContentProperty::POSITION) { - set