X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Fwx%2Fcontent_panel.cc;h=f51d5ed48da7cd955b9afe8470305be26ab7d7b8;hp=f93b0d471dd09c72dcf1ef8ca8095662c81fdaa8;hb=c103d8c1306e5fb3937b3a6c430a3fff32653fa3;hpb=3c29aa6531a4046a8db72dcac81189eb8893233c diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index f93b0d471..f51d5ed48 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -36,6 +36,8 @@ #include "lib/content_factory.h" #include "lib/cross.h" #include "lib/dcp_content.h" +#include "lib/dcp_subtitle_content.h" +#include "lib/dcp_subtitle_decoder.h" #include "lib/dcpomatic_log.h" #include "lib/ffmpeg_content.h" #include "lib/image_content.h" @@ -85,7 +87,7 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr film, weak_ptr go_to; - for (auto i: selected()) { - DCPTime p; - p = i->position(); - if (dynamic_pointer_cast(i) && i->paths_valid()) { - /* Rather special case; if we select a text subtitle file jump to its - first subtitle. - */ - StringTextFile ts (dynamic_pointer_cast(i)); - if (ts.first()) { - p += DCPTime(ts.first().get(), _film->active_frame_rate_change(i->position())); + for (auto content: selected()) { + if (content->paths_valid()) { + auto position = content->position(); + if (auto text_content = dynamic_pointer_cast(content)) { + /* Rather special case; if we select a text subtitle file jump to its + first subtitle. + */ + StringTextFile ts(text_content); + if (auto first = ts.first()) { + position += DCPTime(first.get(), _film->active_frame_rate_change(content->position())); + } + } else if (auto dcp_content = dynamic_pointer_cast(content)) { + /* Do the same for DCP subtitles */ + DCPSubtitleDecoder ts(_film, dcp_content); + if (auto first = ts.first()) { + position += DCPTime(first.get(), _film->active_frame_rate_change(content->position())); + } + } + if (!go_to || position < go_to.get()) { + go_to = position; } - } - if (!go_to || p < go_to.get()) { - go_to = p; } } @@ -474,7 +483,7 @@ ContentPanel::add_folder_clicked () return; } - list > content; + vector> content; try { content = content_factory (path); @@ -541,7 +550,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; @@ -668,11 +677,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()); } } @@ -684,11 +689,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; @@ -774,7 +775,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) { @@ -784,7 +785,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 (); @@ -852,6 +853,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)