Use EnumIndexedVector in ContentPanel.
[dcpomatic.git] / src / wx / content_panel.cc
index f51d5ed48da7cd955b9afe8470305be26ab7d7b8..7a0c2eefd5b830cf6da4382823ba7166d64ba465 100644 (file)
@@ -80,10 +80,6 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmV
        , _ignore_deselect (false)
        , _no_check_selection (false)
 {
-       for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
-               _text_panel[i] = 0;
-       }
-
        _splitter = new LimitedSplitter (n);
        _top_panel = new wxPanel (_splitter);
 
@@ -350,7 +346,7 @@ ContentPanel::check_selection ()
 
        bool have_video = false;
        bool have_audio = false;
-       bool have_text[static_cast<int>(TextType::COUNT)] = { false, false };
+       EnumIndexedVector<bool, TextType> have_text;
        for (auto i: selected()) {
                if (i->video) {
                        have_video = true;
@@ -398,7 +394,7 @@ ContentPanel::check_selection ()
                        _text_panel[i]->create ();
                } else if (!have_text[i] && _text_panel[i]) {
                        _notebook->DeletePage (off);
-                       _text_panel[i] = 0;
+                       _text_panel[i] = nullptr;
                }
                if (have_text[i]) {
                        ++off;
@@ -613,9 +609,9 @@ ContentPanel::setup_sensitivity ()
        if (_audio_panel) {
                _audio_panel->Enable (_generally_sensitive && audio_selection.size() > 0);
        }
-       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());
+       for (auto text: _text_panel) {
+               if (text) {
+                       text->Enable(_generally_sensitive && selection.size() == 1 && !selection.front()->text.empty());
                }
        }
        _timing_panel->Enable (_generally_sensitive);
@@ -843,9 +839,9 @@ ContentPanel::panels () const
        if (_audio_panel) {
                p.push_back (_audio_panel);
        }
-       for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
-               if (_text_panel[i]) {
-                       p.push_back (_text_panel[i]);
+       for (auto text: _text_panel) {
+               if (text) {
+                       p.push_back(text);
                }
        }
        p.push_back (_timing_panel);