#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"
#include "lib/string_text_file_content.h"
#include "lib/text_content.h"
#include "lib/video_content.h"
-#include <wx/wx.h>
-#include <wx/notebook.h>
-#include <wx/listctrl.h>
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
#include <wx/display.h>
+#include <wx/listctrl.h>
+#include <wx/notebook.h>
+#include <wx/wx.h>
+LIBDCP_ENABLE_WARNINGS
#include <boost/filesystem.hpp>
-#include <iostream>
-using std::cout;
using std::dynamic_pointer_cast;
using std::exception;
using std::list;
_splitter = new LimitedSplitter (n);
_top_panel = new wxPanel (_splitter);
- _menu = new ContentMenu (_splitter);
+ _menu = new ContentMenu (_splitter, _film_viewer);
{
auto s = new wxBoxSizer (wxHORIZONTAL);
_add_folder = new Button (_top_panel, _("Add folder..."));
_add_folder->SetToolTip (_("Add a folder of image files (which will be used as a moving image sequence) or a folder of sound files."));
- b->Add (_add_folder, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+ b->Add (_add_folder, 0, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
_add_dcp = new Button (_top_panel, _("Add DCP..."));
_add_dcp->SetToolTip (_("Add a DCP."));
- b->Add (_add_dcp, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+ b->Add (_add_dcp, 0, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
_remove = new Button (_top_panel, _("Remove"));
_remove->SetToolTip (_("Remove the selected piece of content from the film."));
}
optional<DCPTime> go_to;
- for (auto i: selected()) {
- DCPTime p;
- p = i->position();
- if (dynamic_pointer_cast<StringTextFileContent>(i) && i->paths_valid()) {
- /* Rather special case; if we select a text subtitle file jump to its
- first subtitle.
- */
- StringTextFile ts (dynamic_pointer_cast<StringTextFileContent>(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<StringTextFileContent>(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<DCPSubtitleContent>(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;
}
}
return;
}
- list<shared_ptr<Content> > content;
+ vector<shared_ptr<Content>> content;
try {
content = content_factory (path);
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;
{
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());
}
}
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;
_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) {
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 ();
}
+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)