#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 <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>
, _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);
- _menu = new ContentMenu (_splitter);
+ _menu = new ContentMenu (_splitter, _film_viewer);
{
auto s = new wxBoxSizer (wxHORIZONTAL);
}
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;
}
}
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;
_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;
return;
}
- list<shared_ptr<Content> > content;
+ vector<shared_ptr<Content>> content;
try {
content = content_factory (path);
_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) {
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;
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);
{
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 ();
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);
}
+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)