Supporters update.
[dcpomatic.git] / src / wx / content_panel.cc
index d1859b894e1c34a8f391ed7dc0c19b9daedf2ade..8f09949199ceafce2ac1b532a951c03da099fb03 100644 (file)
@@ -34,6 +34,7 @@
 #include "lib/compose.hpp"
 #include "lib/config.h"
 #include "lib/content_factory.h"
+#include "lib/cross.h"
 #include "lib/dcp_content.h"
 #include "lib/dcpomatic_log.h"
 #include "lib/ffmpeg_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;
 using std::make_shared;
-using std::max;
 using std::shared_ptr;
 using std::string;
 using std::vector;
@@ -84,7 +85,7 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmV
        _splitter = new LimitedSplitter (n);
        _top_panel = new wxPanel (_splitter);
 
-       _menu = new ContentMenu (_splitter);
+       _menu = new ContentMenu (_splitter, _film_viewer);
 
        {
                auto s = new wxBoxSizer (wxHORIZONTAL);
@@ -104,11 +105,11 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmV
 
                _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."));
@@ -134,6 +135,7 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmV
 
        _timing_panel = new TimingPanel (this, _film_viewer);
        _notebook->AddPage (_timing_panel, _("Timing"), false);
+       _timing_panel->create ();
 
        _content->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind (&ContentPanel::item_selected, this));
        _content->Bind (wxEVT_LIST_ITEM_DESELECTED, boost::bind (&ContentPanel::item_deselected, this));
@@ -357,6 +359,7 @@ ContentPanel::check_selection ()
        if (have_video && !_video_panel) {
                _video_panel = new VideoPanel (this);
                _notebook->InsertPage (off, _video_panel, _video_panel->name());
+               _video_panel->create ();
        } else if (!have_video && _video_panel) {
                _notebook->DeletePage (off);
                _video_panel = 0;
@@ -369,6 +372,7 @@ ContentPanel::check_selection ()
        if (have_audio && !_audio_panel) {
                _audio_panel = new AudioPanel (this);
                _notebook->InsertPage (off, _audio_panel, _audio_panel->name());
+               _audio_panel->create ();
        } else if (!have_audio && _audio_panel) {
                _notebook->DeletePage (off);
                _audio_panel = 0;
@@ -382,6 +386,7 @@ ContentPanel::check_selection ()
                if (have_text[i] && !_text_panel[i]) {
                        _text_panel[i] = new TextPanel (this, static_cast<TextType>(i));
                        _notebook->InsertPage (off, _text_panel[i], _text_panel[i]->name());
+                       _text_panel[i]->create ();
                } else if (!have_text[i] && _text_panel[i]) {
                        _notebook->DeletePage (off);
                        _text_panel[i] = 0;
@@ -420,13 +425,15 @@ ContentPanel::add_file_clicked ()
                return;
        }
 
+       auto path = Config::instance()->add_files_path();
+
        /* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using
           non-Latin filenames or paths.
        */
        auto d = new wxFileDialog (
                _splitter,
                _("Choose a file or files"),
-               wxT (""),
+               std_to_wx(path ? path->string() : home_directory().string()),
                wxT (""),
                wxT ("All files|*.*|Subtitle files|*.srt;*.xml|Audio files|*.wav;*.w64;*.flac;*.aif;*.aiff"),
                wxFD_MULTIPLE | wxFD_CHANGE_DIR
@@ -441,12 +448,16 @@ ContentPanel::add_file_clicked ()
 
        wxArrayString paths;
        d->GetPaths (paths);
-       list<boost::filesystem::path> path_list;
+       vector<boost::filesystem::path> path_list;
        for (unsigned int i = 0; i < paths.GetCount(); ++i) {
-               path_list.push_back (wx_to_std (paths[i]));
+               path_list.push_back (wx_to_std(paths[i]));
        }
        add_files (path_list);
 
+       if (!path_list.empty()) {
+               Config::instance()->set_add_files_path(path_list[0].parent_path());
+       }
+
        d->Destroy ();
 }
 
@@ -788,9 +799,9 @@ ContentPanel::files_dropped (wxDropFilesEvent& event)
        }
 
        auto paths = event.GetFiles ();
-       list<boost::filesystem::path> path_list;
+       vector<boost::filesystem::path> path_list;
        for (int i = 0; i < event.GetNumberOfFiles(); i++) {
-               path_list.push_back (wx_to_std (paths[i]));
+               path_list.push_back (wx_to_std(paths[i]));
        }
 
        add_files (path_list);
@@ -798,14 +809,14 @@ ContentPanel::files_dropped (wxDropFilesEvent& event)
 
 
 void
-ContentPanel::add_files (list<boost::filesystem::path> paths)
+ContentPanel::add_files (vector<boost::filesystem::path> paths)
 {
        /* It has been reported that the paths returned from e.g. wxFileDialog are not always sorted;
           I can't reproduce that, but sort them anyway.  Don't use ImageFilenameSorter as a normal
           alphabetical sort is expected here.
        */
 
-       paths.sort (CaseInsensitiveSorter ());
+       std::sort (paths.begin(), paths.end(), CaseInsensitiveSorter());
 
        /* XXX: check for lots of files here and do something */