Formatting / C++11 tidying.
[dcpomatic.git] / src / wx / content_panel.cc
index 0530c9128453f85606d4032d73e8fa7b5bb6d73b..7789e7b786b4fc8366b3d10f32d24d21bf1406a9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 */
 
-#include "content_panel.h"
-#include "wx_util.h"
-#include "video_panel.h"
+
 #include "audio_panel.h"
+#include "content_panel.h"
+#include "dcpomatic_button.h"
+#include "film_viewer.h"
+#include "image_sequence_dialog.h"
 #include "text_panel.h"
-#include "timing_panel.h"
 #include "timeline_dialog.h"
-#include "image_sequence_dialog.h"
-#include "film_viewer.h"
-#include "dcpomatic_button.h"
+#include "timing_panel.h"
+#include "video_panel.h"
+#include "wx_util.h"
 #include "lib/audio_content.h"
-#include "lib/text_content.h"
-#include "lib/video_content.h"
-#include "lib/ffmpeg_content.h"
-#include "lib/content_factory.h"
-#include "lib/image_content.h"
-#include "lib/dcp_content.h"
 #include "lib/case_insensitive_sorter.h"
-#include "lib/playlist.h"
+#include "lib/compose.hpp"
 #include "lib/config.h"
+#include "lib/content_factory.h"
+#include "lib/dcp_content.h"
+#include "lib/dcpomatic_log.h"
+#include "lib/ffmpeg_content.h"
+#include "lib/image_content.h"
 #include "lib/log.h"
-#include "lib/compose.hpp"
-#include "lib/string_text_file_content.h"
+#include "lib/playlist.h"
 #include "lib/string_text_file.h"
-#include "lib/dcpomatic_log.h"
+#include "lib/string_text_file_content.h"
+#include "lib/text_content.h"
+#include "lib/video_content.h"
 #include <wx/wx.h>
 #include <wx/notebook.h>
 #include <wx/listctrl.h>
 #include <boost/filesystem.hpp>
 #include <iostream>
 
-using std::list;
-using std::string;
+
 using std::cout;
-using std::vector;
-using std::max;
+using std::dynamic_pointer_cast;
 using std::exception;
+using std::list;
+using std::make_shared;
+using std::max;
 using std::shared_ptr;
+using std::string;
+using std::vector;
 using std::weak_ptr;
-using std::dynamic_pointer_cast;
 using boost::optional;
 using namespace dcpomatic;
 #if BOOST_VERSION >= 106100
@@ -67,18 +70,14 @@ using namespace boost::placeholders;
 
 
 ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer)
-       : _video_panel (0)
-       , _audio_panel (0)
-       , _timeline_dialog (0)
-       , _parent (n)
-       , _last_selected_tab (0)
+       : _parent (n)
        , _film (film)
        , _film_viewer (viewer)
        , _generally_sensitive (true)
        , _ignore_deselect (false)
        , _no_check_selection (false)
 {
-       for (int i = 0; i < TEXT_COUNT; ++i) {
+       for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
                _text_panel[i] = 0;
        }
 
@@ -177,6 +176,7 @@ ContentPanel::selected ()
        return sel;
 }
 
+
 ContentList
 ContentPanel::selected_video ()
 {
@@ -191,6 +191,7 @@ ContentPanel::selected_video ()
        return vc;
 }
 
+
 ContentList
 ContentPanel::selected_audio ()
 {
@@ -205,6 +206,7 @@ ContentPanel::selected_audio ()
        return ac;
 }
 
+
 ContentList
 ContentPanel::selected_text ()
 {
@@ -219,6 +221,7 @@ ContentPanel::selected_text ()
        return sc;
 }
 
+
 FFmpegContentList
 ContentPanel::selected_ffmpeg ()
 {
@@ -234,12 +237,13 @@ ContentPanel::selected_ffmpeg ()
        return sc;
 }
 
+
 void
 ContentPanel::film_changed (Film::Property p)
 {
        switch (p) {
-       case Film::CONTENT:
-       case Film::CONTENT_ORDER:
+       case Film::Property::CONTENT:
+       case Film::Property::CONTENT_ORDER:
                setup ();
                break;
        default:
@@ -251,6 +255,7 @@ ContentPanel::film_changed (Film::Property p)
        }
 }
 
+
 void
 ContentPanel::item_deselected ()
 {
@@ -261,6 +266,7 @@ ContentPanel::item_deselected ()
        signal_manager->when_idle (boost::bind (&ContentPanel::item_deselected_idle, this));
 }
 
+
 void
 ContentPanel::item_deselected_idle ()
 {
@@ -269,6 +275,7 @@ ContentPanel::item_deselected_idle ()
        }
 }
 
+
 void
 ContentPanel::item_selected ()
 {
@@ -276,6 +283,7 @@ ContentPanel::item_selected ()
        check_selection ();
 }
 
+
 void
 ContentPanel::check_selection ()
 {
@@ -331,7 +339,7 @@ ContentPanel::check_selection ()
 
        bool have_video = false;
        bool have_audio = false;
-       bool have_text[TEXT_COUNT] = { false, false };
+       bool have_text[static_cast<int>(TextType::COUNT)] = { false, false };
        for (auto i: selected()) {
                if (i->video) {
                        have_video = true;
@@ -340,7 +348,7 @@ ContentPanel::check_selection ()
                        have_audio = true;
                }
                for (auto j: i->text) {
-                       have_text[j->original_type()] = true;
+                       have_text[static_cast<int>(j->original_type())] = true;
                }
        }
 
@@ -370,7 +378,7 @@ ContentPanel::check_selection ()
                ++off;
        }
 
-       for (int i = 0; i < TEXT_COUNT; ++i) {
+       for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
                if (have_text[i] && !_text_panel[i]) {
                        _text_panel[i] = new TextPanel (this, static_cast<TextType>(i));
                        _notebook->InsertPage (off, _text_panel[i], _text_panel[i]->name());
@@ -401,6 +409,7 @@ ContentPanel::check_selection ()
        SelectionChanged ();
 }
 
+
 void
 ContentPanel::add_file_clicked ()
 {
@@ -441,6 +450,7 @@ ContentPanel::add_file_clicked ()
        d->Destroy ();
 }
 
+
 void
 ContentPanel::add_folder_clicked ()
 {
@@ -486,6 +496,7 @@ ContentPanel::add_folder_clicked ()
        }
 }
 
+
 void
 ContentPanel::add_dcp_clicked ()
 {
@@ -499,12 +510,13 @@ ContentPanel::add_dcp_clicked ()
        }
 
        try {
-               _film->examine_and_add_content (shared_ptr<Content> (new DCPContent (path)));
+               _film->examine_and_add_content (make_shared<DCPContent>(path));
        } catch (exception& e) {
                error_dialog (_parent, e.what());
        }
 }
 
+
 /** @return true if this remove "click" should be ignored */
 bool
 ContentPanel::remove_clicked (bool hotkey)
@@ -524,6 +536,7 @@ ContentPanel::remove_clicked (bool hotkey)
        return false;
 }
 
+
 void
 ContentPanel::timeline_clicked ()
 {
@@ -541,12 +554,14 @@ ContentPanel::timeline_clicked ()
        _timeline_dialog->Show ();
 }
 
+
 void
 ContentPanel::right_click (wxListEvent& ev)
 {
        _menu->popup (_film, selected (), TimelineContentViewList (), ev.GetPoint ());
 }
 
+
 /** Set up broad sensitivity based on the type of content that is selected */
 void
 ContentPanel::setup_sensitivity ()
@@ -570,7 +585,7 @@ ContentPanel::setup_sensitivity ()
        if (_audio_panel) {
                _audio_panel->Enable (_generally_sensitive && audio_selection.size() > 0);
        }
-       for (int i = 0; i < TEXT_COUNT; ++i) {
+       for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
                if (_text_panel[i]) {
                        _text_panel[i]->Enable (_generally_sensitive && selection.size() == 1 && !selection.front()->text.empty());
                }
@@ -578,6 +593,7 @@ ContentPanel::setup_sensitivity ()
        _timing_panel->Enable (_generally_sensitive);
 }
 
+
 void
 ContentPanel::set_film (shared_ptr<Film> film)
 {
@@ -587,8 +603,8 @@ ContentPanel::set_film (shared_ptr<Film> film)
 
        _film = film;
 
-       film_changed (Film::CONTENT);
-       film_changed (Film::AUDIO_CHANNELS);
+       film_changed (Film::Property::CONTENT);
+       film_changed (Film::Property::AUDIO_CHANNELS);
 
        if (_film) {
                check_selection ();
@@ -597,6 +613,7 @@ ContentPanel::set_film (shared_ptr<Film> film)
        setup_sensitivity ();
 }
 
+
 void
 ContentPanel::set_general_sensitivity (bool s)
 {
@@ -604,6 +621,7 @@ ContentPanel::set_general_sensitivity (bool s)
        setup_sensitivity ();
 }
 
+
 void
 ContentPanel::earlier_clicked ()
 {
@@ -614,6 +632,7 @@ ContentPanel::earlier_clicked ()
        }
 }
 
+
 void
 ContentPanel::later_clicked ()
 {
@@ -624,6 +643,7 @@ ContentPanel::later_clicked ()
        }
 }
 
+
 void
 ContentPanel::set_selection (weak_ptr<Content> wc)
 {
@@ -637,6 +657,7 @@ ContentPanel::set_selection (weak_ptr<Content> wc)
        }
 }
 
+
 void
 ContentPanel::set_selection (ContentList cl)
 {
@@ -655,6 +676,14 @@ ContentPanel::set_selection (ContentList cl)
        check_selection ();
 }
 
+
+void
+ContentPanel::select_all ()
+{
+       set_selection (_film->content());
+}
+
+
 void
 ContentPanel::film_content_changed (int property)
 {
@@ -673,6 +702,7 @@ ContentPanel::film_content_changed (int property)
        }
 }
 
+
 void
 ContentPanel::setup ()
 {
@@ -741,6 +771,7 @@ ContentPanel::setup ()
        setup_sensitivity ();
 }
 
+
 void
 ContentPanel::files_dropped (wxDropFilesEvent& event)
 {
@@ -757,6 +788,7 @@ ContentPanel::files_dropped (wxDropFilesEvent& event)
        add_files (path_list);
 }
 
+
 void
 ContentPanel::add_files (list<boost::filesystem::path> paths)
 {
@@ -780,6 +812,7 @@ ContentPanel::add_files (list<boost::filesystem::path> paths)
        }
 }
 
+
 list<ContentSubPanel*>
 ContentPanel::panels () const
 {
@@ -790,7 +823,7 @@ ContentPanel::panels () const
        if (_audio_panel) {
                p.push_back (_audio_panel);
        }
-       for (int i = 0; i < TEXT_COUNT; ++i) {
+       for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
                if (_text_panel[i]) {
                        p.push_back (_text_panel[i]);
                }