Replace directory with folder in some messages.
[dcpomatic.git] / src / wx / content_panel.cc
index 69dd724266abfc35a780f141833587c2853bd13a..83085db5aa57f05920ad1496aac7d75dab71e6f9 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;
@@ -483,7 +479,7 @@ ContentPanel::add_folder_clicked ()
                return;
        }
 
-       list<shared_ptr<Content> > content;
+       vector<shared_ptr<Content>> content;
 
        try {
                content = content_factory (path);
@@ -536,7 +532,7 @@ ContentPanel::add_dcp_clicked ()
                        _parent,
                        _(
                                "This looks like a DCP-o-matic project folder, which cannot be added to a different project.  "
-                               "Choose the DCP directory inside the DCP-o-matic project folder if that's what you want to import."
+                               "Choose the DCP folder inside the DCP-o-matic project folder if that's what you want to import."
                         )
                        );
        } catch (exception& e) {
@@ -550,7 +546,7 @@ bool
 ContentPanel::remove_clicked (bool hotkey)
 {
        /* If the method was called because Delete was pressed check that our notebook page
-          is visible and that the content list is focussed.
+          is visible and that the content list is focused.
        */
        if (hotkey && (_parent->GetCurrentPage() != _splitter || !_content->HasFocus())) {
                return true;
@@ -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);
@@ -677,11 +673,7 @@ ContentPanel::set_selection (weak_ptr<Content> wc)
 {
        auto content = _film->content ();
        for (size_t i = 0; i < content.size(); ++i) {
-               if (content[i] == wc.lock ()) {
-                       _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
-               } else {
-                       _content->SetItemState (i, 0, wxLIST_STATE_SELECTED);
-               }
+               set_selected_state(i, content[i] == wc.lock());
        }
 }
 
@@ -693,11 +685,7 @@ ContentPanel::set_selection (ContentList cl)
 
        auto content = _film->content ();
        for (size_t i = 0; i < content.size(); ++i) {
-               if (find(cl.begin(), cl.end(), content[i]) != cl.end()) {
-                       _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
-               } else {
-                       _content->SetItemState (i, 0, wxLIST_STATE_SELECTED);
-               }
+               set_selected_state(i, find(cl.begin(), cl.end(), content[i]) != cl.end());
        }
 
        _no_check_selection = false;
@@ -783,7 +771,7 @@ ContentPanel::setup ()
                _content->InsertItem (item);
 
                if (i.get() == selected_content) {
-                       _content->SetItemState (t, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+                       set_selected_state(t, true);
                }
 
                if (!valid || needs_kdm || needs_assets) {
@@ -793,7 +781,7 @@ ContentPanel::setup ()
 
        if (!selected_content && !content.empty ()) {
                /* Select the item of content if none was selected before */
-               _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+               set_selected_state(0, true);
        }
 
        setup_sensitivity ();
@@ -851,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);
@@ -861,6 +849,14 @@ ContentPanel::panels () const
 }
 
 
+void
+ContentPanel::set_selected_state(int item, bool state)
+{
+       _content->SetItemState(item, state ? wxLIST_STATE_SELECTED : 0, wxLIST_STATE_SELECTED);
+       _content->SetItemState(item, state ? wxLIST_STATE_FOCUSED : 0, wxLIST_STATE_FOCUSED);
+}
+
+
 LimitedSplitter::LimitedSplitter (wxWindow* parent)
        : wxSplitterWindow (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER | wxSP_3DSASH | wxSP_LIVE_UPDATE)
        , _first_shown (false)