summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-08-24 11:40:34 +0100
committerCarl Hetherington <cth@carlh.net>2016-08-24 14:28:32 +0100
commit1a693725f9a8cc6ba58f65b2f1ef03255d295f23 (patch)
tree91596f7800dcc02103c90f8f19c763f45281603e /src/wx
parenta03e9a98ed667eb44c9dfbbeaf6da57f44992914 (diff)
Basic template support (#485).
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/film_editor.cc4
-rw-r--r--src/wx/new_film_dialog.cc35
-rw-r--r--src/wx/new_film_dialog.h7
-rw-r--r--src/wx/save_template_dialog.cc40
-rw-r--r--src/wx/save_template_dialog.h32
-rw-r--r--src/wx/wscript1
6 files changed, 113 insertions, 6 deletions
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index a5e1e82e9..edf5d3bd7 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -127,8 +127,8 @@ FilmEditor::set_film (shared_ptr<Film> film)
_film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _2));
}
- if (_film) {
- FileChanged (_film->directory ());
+ if (_film && _film->directory()) {
+ FileChanged (_film->directory().get());
} else {
FileChanged ("");
}
diff --git a/src/wx/new_film_dialog.cc b/src/wx/new_film_dialog.cc
index 04b9e1057..907b289b5 100644
--- a/src/wx/new_film_dialog.cc
+++ b/src/wx/new_film_dialog.cc
@@ -18,14 +18,15 @@
*/
-#include <boost/filesystem.hpp>
-#include <wx/stdpaths.h>
#include "lib/config.h"
#include "new_film_dialog.h"
#include "wx_util.h"
#ifdef DCPOMATIC_USE_OWN_PICKER
#include "dir_picker_ctrl.h"
#endif
+#include <wx/stdpaths.h>
+#include <boost/filesystem.hpp>
+#include <boost/foreach.hpp>
using namespace std;
using namespace boost;
@@ -53,21 +54,49 @@ NewFilmDialog::NewFilmDialog (wxWindow* parent)
_folder->SetPath (std_to_wx (_directory.get().string()));
add (_folder);
+ _use_template = new wxCheckBox (this, wxID_ANY, _("From template"));
+ add (_use_template);
+ _template_name = new wxChoice (this, wxID_ANY);
+ add (_template_name);
+
_name->SetFocus ();
+ _template_name->Enable (false);
+
+ BOOST_FOREACH (string i, Config::instance()->template_names ()) {
+ _template_name->Append (std_to_wx (i));
+ }
+
+ _use_template->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, bind (&NewFilmDialog::use_template_clicked, this));
layout ();
}
+void
+NewFilmDialog::use_template_clicked ()
+{
+ _template_name->Enable (_use_template->GetValue ());
+}
+
NewFilmDialog::~NewFilmDialog ()
{
_directory = wx_to_std (_folder->GetPath ());
}
boost::filesystem::path
-NewFilmDialog::get_path () const
+NewFilmDialog::path () const
{
filesystem::path p;
p /= wx_to_std (_folder->GetPath ());
p /= wx_to_std (_name->GetValue ());
return p;
}
+
+optional<string>
+NewFilmDialog::template_name () const
+{
+ if (!_use_template->GetValue() || _template_name->GetSelection() == -1) {
+ return optional<string> ();
+ }
+
+ return wx_to_std (_template_name->GetString(_template_name->GetSelection()));
+}
diff --git a/src/wx/new_film_dialog.h b/src/wx/new_film_dialog.h
index 6dc83d815..81dd29fea 100644
--- a/src/wx/new_film_dialog.h
+++ b/src/wx/new_film_dialog.h
@@ -31,14 +31,19 @@ public:
NewFilmDialog (wxWindow *);
~NewFilmDialog ();
- boost::filesystem::path get_path () const;
+ boost::filesystem::path path () const;
+ boost::optional<std::string> template_name () const;
private:
+ void use_template_clicked ();
+
wxTextCtrl* _name;
#ifdef DCPOMATIC_USE_OWN_PICKER
DirPickerCtrl* _folder;
#else
wxDirPickerCtrl* _folder;
#endif
+ wxCheckBox* _use_template;
+ wxChoice* _template_name;
static boost::optional<boost::filesystem::path> _directory;
};
diff --git a/src/wx/save_template_dialog.cc b/src/wx/save_template_dialog.cc
new file mode 100644
index 000000000..eff61a256
--- /dev/null
+++ b/src/wx/save_template_dialog.cc
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "save_template_dialog.h"
+#include "wx_util.h"
+#include <boost/foreach.hpp>
+
+using std::string;
+
+SaveTemplateDialog::SaveTemplateDialog (wxWindow* parent)
+ : TableDialog (parent, _("Save template"), 2, 1, true)
+{
+ add (_("Template name"), true);
+ _name = add (new wxTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (300, -1)));
+ _name->SetFocus ();
+ layout ();
+}
+
+string
+SaveTemplateDialog::name () const
+{
+ return wx_to_std (_name->GetValue ());
+}
diff --git a/src/wx/save_template_dialog.h b/src/wx/save_template_dialog.h
new file mode 100644
index 000000000..8069fa2f0
--- /dev/null
+++ b/src/wx/save_template_dialog.h
@@ -0,0 +1,32 @@
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "table_dialog.h"
+
+class SaveTemplateDialog : public TableDialog
+{
+public:
+ SaveTemplateDialog (wxWindow* parent);
+
+ std::string name () const;
+
+private:
+ wxTextCtrl* _name;
+};
diff --git a/src/wx/wscript b/src/wx/wscript
index ee77e6c20..1f9aed6b3 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -75,6 +75,7 @@ sources = """
repeat_dialog.cc
report_problem_dialog.cc
rgba_colour_picker.cc
+ save_template_dialog.cc
screen_dialog.cc
screens_panel.cc
self_dkdm_dialog.cc