X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fcontent_panel.cc;h=83085db5aa57f05920ad1496aac7d75dab71e6f9;hb=1cd2c956234dac14c0cd22883bf0575b3c7faf8f;hp=69dd724266abfc35a780f141833587c2853bd13a;hpb=59953282b9f9da1164f39181347a01672c4f674c;p=dcpomatic.git diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 69dd72426..83085db5a 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; @@ -483,7 +479,7 @@ ContentPanel::add_folder_clicked () return; } - list > content; + vector> 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(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 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(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)