From: Carl Hetherington Date: Mon, 26 Sep 2022 22:44:25 +0000 (+0200) Subject: Use EnumIndexedVector in ContentPanel. X-Git-Tag: v2.17.0~20 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=9adbb3c5ab5d90268a3009c4a6f1bbc5f6290d81 Use EnumIndexedVector in ContentPanel. --- diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index f51d5ed48..7a0c2eefd 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -80,10 +80,6 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr film, weak_ptr(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(TextType::COUNT)] = { false, false }; + EnumIndexedVector 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(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(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); diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index a886b0217..eec062284 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -20,6 +20,7 @@ #include "content_menu.h" +#include "lib/enum_indexed_vector.h" #include "lib/film.h" #include "lib/types.h" #include @@ -146,7 +147,7 @@ private: wxButton* _timeline; VideoPanel* _video_panel = nullptr; AudioPanel* _audio_panel = nullptr; - TextPanel* _text_panel[static_cast(TextType::COUNT)]; + EnumIndexedVector _text_panel; TimingPanel* _timing_panel; ContentMenu* _menu; TimelineDialog* _timeline_dialog = nullptr;