Use EnumIndexedVector in ContentPanel.
authorCarl Hetherington <cth@carlh.net>
Mon, 26 Sep 2022 22:44:25 +0000 (00:44 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 27 Sep 2022 11:46:16 +0000 (13:46 +0200)
src/wx/content_panel.cc
src/wx/content_panel.h

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);
index a886b021726ec00de2ce7d189d2b709c46ce7d54..eec062284eab7eaa9857f594b3d67eeb0776f047 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "content_menu.h"
+#include "lib/enum_indexed_vector.h"
 #include "lib/film.h"
 #include "lib/types.h"
 #include <dcp/warnings.h>
@@ -146,7 +147,7 @@ private:
        wxButton* _timeline;
        VideoPanel* _video_panel = nullptr;
        AudioPanel* _audio_panel = nullptr;
-       TextPanel* _text_panel[static_cast<int>(TextType::COUNT)];
+       EnumIndexedVector<TextPanel*, TextType> _text_panel;
        TimingPanel* _timing_panel;
        ContentMenu* _menu;
        TimelineDialog* _timeline_dialog = nullptr;