BOOST_FOREACH.
[dcpomatic.git] / src / wx / text_panel.cc
index e7f5741bb71fbe39936861bb0fae3682a4ea5065..521e55fc50f4e9c604d851322e4de34a7590f237 100644 (file)
 #include "lib/analyse_subtitles_job.h"
 #include "lib/subtitle_analysis.h"
 #include <wx/spinctrl.h>
-#include <boost/foreach.hpp>
 
 using std::vector;
 using std::string;
 using std::list;
 using std::cout;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::optional;
-using boost::dynamic_pointer_cast;
+using std::dynamic_pointer_cast;
 using boost::bind;
 
 /** @param t Original text type of the content, if known */
@@ -60,8 +59,6 @@ TextPanel::TextPanel (ContentPanel* p, TextType t)
        , _outline_subtitles (0)
        , _dcp_track_label (0)
        , _dcp_track (0)
-       , _language_label (0)
-       , _language (0)
        , _text_view (0)
        , _fonts_dialog (0)
        , _original_type (t)
@@ -157,16 +154,6 @@ TextPanel::setup_visibility ()
                        _dcp_track->Destroy ();
                        _dcp_track = 0;
                }
-               if (!_language_label) {
-                       _language_label = create_label (this, _("Language"), true);
-                       add_label_to_sizer (_grid, _language_label, true, wxGBPosition(_language_row, 0));
-               }
-               if (!_language) {
-                       _language = new wxTextCtrl (this, wxID_ANY);
-                       _language->Bind (wxEVT_TEXT, boost::bind(&TextPanel::language_changed, this));
-                       _grid->Add (_language, wxGBPosition(_language_row, 1), wxDefaultSpan, wxEXPAND);
-                       film_content_changed (TextContentProperty::LANGUAGE);
-               }
                if (!_outline_subtitles) {
                        _outline_subtitles = new CheckBox (this, _("Show subtitle area"));
                        _outline_subtitles->Bind (wxEVT_CHECKBOX, boost::bind (&TextPanel::outline_subtitles_changed, this));
@@ -175,22 +162,14 @@ TextPanel::setup_visibility ()
 
                break;
        case TEXT_CLOSED_CAPTION:
-               if (_language_label) {
-                       _language_label->Destroy ();
-                       _language_label = 0;
-               }
-               if (_language) {
-                       _language->Destroy ();
-                       _language = 0;
-               }
                if (!_dcp_track_label) {
                        _dcp_track_label = create_label (this, _("CCAP track"), true);
-                       add_label_to_sizer (_grid, _dcp_track_label, true, wxGBPosition(_language_row, 0));
+                       add_label_to_sizer (_grid, _dcp_track_label, true, wxGBPosition(_ccap_track_row, 0));
                }
                if (!_dcp_track) {
                        _dcp_track = new wxChoice (this, wxID_ANY);
                        _dcp_track->Bind (wxEVT_CHOICE, boost::bind(&TextPanel::dcp_track_changed, this));
-                       _grid->Add (_dcp_track, wxGBPosition(_language_row, 1), wxDefaultSpan, wxEXPAND);
+                       _grid->Add (_dcp_track, wxGBPosition(_ccap_track_row, 1), wxDefaultSpan, wxEXPAND);
                        update_dcp_tracks ();
                        film_content_changed (TextContentProperty::DCP_TRACK);
                }
@@ -210,20 +189,13 @@ TextPanel::setup_visibility ()
 void
 TextPanel::add_to_grid ()
 {
-       Config::Interface const interface = Config::instance()->interface_complexity();
-
        int r = 0;
 
-       _reference->Show (interface == Config::INTERFACE_FULL);
-       _reference_note->Show (interface == Config::INTERFACE_FULL);
-
-       if (interface == Config::INTERFACE_FULL) {
-               wxBoxSizer* reference_sizer = new wxBoxSizer (wxVERTICAL);
-               reference_sizer->Add (_reference, 0);
-               reference_sizer->Add (_reference_note, 0);
-               _grid->Add (reference_sizer, wxGBPosition(r, 0), wxGBSpan(1, 4));
-               ++r;
-       }
+       wxBoxSizer* reference_sizer = new wxBoxSizer (wxVERTICAL);
+       reference_sizer->Add (_reference, 0);
+       reference_sizer->Add (_reference_note, 0);
+       _grid->Add (reference_sizer, wxGBPosition(r, 0), wxGBSpan(1, 4));
+       ++r;
 
        wxBoxSizer* use = new wxBoxSizer (wxHORIZONTAL);
        use->Add (_use, 0, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_GAP);
@@ -278,7 +250,7 @@ TextPanel::add_to_grid ()
                ++r;
        }
 
-       _language_row = r;
+       _ccap_track_row = r;
        ++r;
 
        add_label_to_sizer (_grid, _stream_label, true, wxGBPosition (r, 0));
@@ -306,7 +278,7 @@ TextPanel::update_dcp_track_selection ()
 
        optional<DCPTextTrack> selected;
        bool many = false;
-       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text()) {
+       for (auto i: _parent->selected_text()) {
                shared_ptr<TextContent> t = i->text_of_original_type(_original_type);
                if (t) {
                        optional<DCPTextTrack> dt = t->dcp_track();
@@ -319,7 +291,7 @@ TextPanel::update_dcp_track_selection ()
        }
 
        int n = 0;
-       BOOST_FOREACH (DCPTextTrack i, _parent->film()->closed_caption_tracks()) {
+       for (auto i: _parent->film()->closed_caption_tracks()) {
                if (!many && selected && *selected == i) {
                        _dcp_track->SetSelection (n);
                }
@@ -337,7 +309,7 @@ TextPanel::update_dcp_tracks ()
        DCPOMATIC_ASSERT (_dcp_track);
 
        _dcp_track->Clear ();
-       BOOST_FOREACH (DCPTextTrack i, _parent->film()->closed_caption_tracks()) {
+       for (auto i: _parent->film()->closed_caption_tracks()) {
                /* XXX: don't display the "magic" track which has empty name and language;
                   this is a nasty hack (see also Film::closed_caption_tracks)
                */
@@ -366,7 +338,7 @@ TextPanel::dcp_track_changed ()
                d->Destroy ();
        } else {
                /* Find the DCPTextTrack that was selected */
-               BOOST_FOREACH (DCPTextTrack i, _parent->film()->closed_caption_tracks()) {
+               for (auto i: _parent->film()->closed_caption_tracks()) {
                        if (i.summary() == wx_to_std(_dcp_track->GetStringSelection())) {
                                track = i;
                        }
@@ -374,7 +346,7 @@ TextPanel::dcp_track_changed ()
        }
 
        if (track) {
-               BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text()) {
+               for (auto i: _parent->selected_text()) {
                        shared_ptr<TextContent> t = i->text_of_original_type(_original_type);
                        if (t && t->type() == TEXT_CLOSED_CAPTION) {
                                t->set_dcp_track(*track);
@@ -468,10 +440,6 @@ TextPanel::film_content_changed (int property)
        } else if (property == TextContentProperty::LINE_SPACING) {
                checked_set (_line_spacing, text ? lrint (text->line_spacing() * 100) : 100);
                clear_outline_subtitles ();
-       } else if (property == TextContentProperty::LANGUAGE) {
-               if (_language) {
-                       checked_set (_language, text ? text->language() : "");
-               }
        } else if (property == TextContentProperty::DCP_TRACK) {
                if (_dcp_track) {
                        update_dcp_track_selection ();
@@ -487,13 +455,15 @@ TextPanel::film_content_changed (int property)
                setup_sensitivity ();
        } else if (property == DCPContentProperty::TEXTS) {
                setup_sensitivity ();
+       } else if (property == ContentProperty::TRIM_START) {
+               setup_sensitivity ();
        }
 }
 
 void
 TextPanel::use_toggled ()
 {
-       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text()) {
+       for (auto i: _parent->selected_text()) {
                i->text_of_original_type(_original_type)->set_use (_use->GetValue());
        }
 }
@@ -515,7 +485,7 @@ TextPanel::current_type () const
 void
 TextPanel::type_changed ()
 {
-       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text()) {
+       for (auto i: _parent->selected_text()) {
                i->text_of_original_type(_original_type)->set_type (current_type ());
        }
 
@@ -525,7 +495,7 @@ TextPanel::type_changed ()
 void
 TextPanel::burn_toggled ()
 {
-       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text ()) {
+       for (auto i: _parent->selected_text ()) {
                i->text_of_original_type(_original_type)->set_burn (_burn->GetValue());
        }
 }
@@ -539,12 +509,12 @@ TextPanel::setup_sensitivity ()
        /* DCP subs can't have their line spacing changed */
        int dcp_subs = 0;
        ContentList sel = _parent->selected_text ();
-       BOOST_FOREACH (shared_ptr<Content> i, sel) {
+       for (auto i: sel) {
                /* These are the content types that could include subtitles */
-               shared_ptr<const FFmpegContent> fc = boost::dynamic_pointer_cast<const FFmpegContent> (i);
-               shared_ptr<const StringTextFileContent> sc = boost::dynamic_pointer_cast<const StringTextFileContent> (i);
-               shared_ptr<const DCPContent> dc = boost::dynamic_pointer_cast<const DCPContent> (i);
-               shared_ptr<const DCPSubtitleContent> dsc = boost::dynamic_pointer_cast<const DCPSubtitleContent> (i);
+               shared_ptr<const FFmpegContent> fc = std::dynamic_pointer_cast<const FFmpegContent> (i);
+               shared_ptr<const StringTextFileContent> sc = std::dynamic_pointer_cast<const StringTextFileContent> (i);
+               shared_ptr<const DCPContent> dc = std::dynamic_pointer_cast<const DCPContent> (i);
+               shared_ptr<const DCPSubtitleContent> dsc = std::dynamic_pointer_cast<const DCPSubtitleContent> (i);
                if (fc) {
                        if (!fc->text.empty()) {
                                ++ffmpeg_subs;
@@ -645,7 +615,7 @@ TextPanel::stream_changed ()
 void
 TextPanel::x_offset_changed ()
 {
-       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text ()) {
+       for (auto i: _parent->selected_text ()) {
                i->text_of_original_type(_original_type)->set_x_offset (_x_offset->GetValue() / 100.0);
        }
 }
@@ -653,7 +623,7 @@ TextPanel::x_offset_changed ()
 void
 TextPanel::y_offset_changed ()
 {
-       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text ()) {
+       for (auto i: _parent->selected_text ()) {
                i->text_of_original_type(_original_type)->set_y_offset (_y_offset->GetValue() / 100.0);
        }
 }
@@ -670,7 +640,7 @@ TextPanel::x_scale_changed ()
 void
 TextPanel::y_scale_changed ()
 {
-       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text ()) {
+       for (auto i: _parent->selected_text ()) {
                i->text_of_original_type(_original_type)->set_y_scale (_y_scale->GetValue() / 100.0);
        }
 }
@@ -678,20 +648,11 @@ TextPanel::y_scale_changed ()
 void
 TextPanel::line_spacing_changed ()
 {
-       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text ()) {
+       for (auto i: _parent->selected_text ()) {
                i->text_of_original_type(_original_type)->set_line_spacing (_line_spacing->GetValue() / 100.0);
        }
 }
 
-void
-TextPanel::language_changed ()
-{
-       DCPOMATIC_ASSERT (_language);
-       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text ()) {
-               i->text_of_original_type(_original_type)->set_language (wx_to_std (_language->GetValue()));
-       }
-}
-
 void
 TextPanel::content_selection_changed ()
 {
@@ -703,7 +664,6 @@ TextPanel::content_selection_changed ()
        film_content_changed (TextContentProperty::X_SCALE);
        film_content_changed (TextContentProperty::Y_SCALE);
        film_content_changed (TextContentProperty::LINE_SPACING);
-       film_content_changed (TextContentProperty::LANGUAGE);
        film_content_changed (TextContentProperty::FONTS);
        film_content_changed (TextContentProperty::TYPE);
        film_content_changed (TextContentProperty::DCP_TRACK);
@@ -809,7 +769,7 @@ TextPanel::try_to_load_analysis ()
        boost::filesystem::path const path = _parent->film()->subtitle_analysis_path(content);
 
        if (!boost::filesystem::exists(path)) {
-               BOOST_FOREACH (shared_ptr<Job> i, JobManager::instance()->get()) {
+               for (auto i: JobManager::instance()->get()) {
                        if (dynamic_pointer_cast<AnalyseSubtitlesJob>(i)) {
                                i->cancel ();
                        }