#include "language_tag_widget.h"
#include "metadata_dialog.h"
#include "rating_dialog.h"
-#include "region_subtag_dialog.h"
+#include "region_subtag_widget.h"
#include "wx_util.h"
#include "lib/film.h"
#include <dcp/warnings.h>
using std::weak_ptr;
using std::vector;
+using boost::optional;
MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr<Film> weak_film)
overall_sizer->SetSizeHints (this);
_sign_language_video_language->Changed.connect (boost::bind(&MetadataDialog::sign_language_video_language_changed, this));
- _edit_release_territory->Bind (wxEVT_BUTTON, boost::bind(&MetadataDialog::edit_release_territory, this));
_enable_release_territory->bind(&MetadataDialog::enable_release_territory_changed, this);
+ _release_territory->Changed.connect(boost::bind(&MetadataDialog::release_territory_changed, this, _1));
_enable_facility->bind(&MetadataDialog::enable_facility_changed, this);
_facility->Bind (wxEVT_TEXT, boost::bind(&MetadataDialog::facility_changed, this));
_enable_studio->bind(&MetadataDialog::enable_studio_changed, this);
auto rt = film()->release_territory();
checked_set (_enable_release_territory, static_cast<bool>(rt));
if (rt) {
- _release_territory = *rt;
- checked_set (_release_territory_text, std_to_wx(*dcp::LanguageTag::get_subtag_description(*_release_territory)));
+ _release_territory_copy = *rt;
+ checked_set(_release_territory, *_release_territory_copy);
}
} else if (property == Film::Property::FACILITY) {
checked_set (_enable_facility, static_cast<bool>(film()->facility()));
{
_enable_release_territory = new CheckBox(panel, _("Release territory"));
sizer->Add (_enable_release_territory, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_GAP);
- {
- auto s = new wxBoxSizer (wxHORIZONTAL);
- _release_territory_text = new wxStaticText (panel, wxID_ANY, wxT(""));
- s->Add (_release_territory_text, 1, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
- _edit_release_territory = new Button (panel, _("Edit..."));
- s->Add (_edit_release_territory, 0, wxLEFT, DCPOMATIC_SIZER_GAP);
- sizer->Add (s, 0, wxEXPAND);
- }
+ _release_territory = new RegionSubtagWidget(panel, _("Release territory for this DCP"), film()->release_territory());
+ sizer->Add(_release_territory->sizer(), 0, wxEXPAND);
vector<EditableListColumn> columns;
columns.push_back(EditableListColumn("Agency", 200, true));
void
-MetadataDialog::edit_release_territory ()
+MetadataDialog::release_territory_changed(optional<dcp::LanguageTag::RegionSubtag> tag)
{
- DCPOMATIC_ASSERT (film()->release_territory());
- auto d = new RegionSubtagDialog(this, *film()->release_territory());
- d->ShowModal ();
- auto tag = d->get();
if (tag) {
- _release_territory = *tag;
+ _release_territory_copy = *tag;
film()->set_release_territory(*tag);
}
- d->Destroy ();
}
{
_sign_language_video_language->enable (film()->has_sign_language_video_channel());
auto const enabled = _enable_release_territory->GetValue();
- _release_territory_text->Enable (enabled);
- _edit_release_territory->Enable (enabled);
+ _release_territory->enable(enabled);
_facility->Enable (_enable_facility->GetValue());
_chain->Enable (_enable_chain->GetValue());
_studio->Enable (_enable_studio->GetValue());
{
setup_sensitivity ();
if (_enable_release_territory->GetValue()) {
- film()->set_release_territory (_release_territory.get_value_or(dcp::LanguageTag::RegionSubtag("US")));
+ film()->set_release_territory (_release_territory->get().get_value_or(dcp::LanguageTag::RegionSubtag("US")));
} else {
film()->set_release_territory ();
}
class Choice;
class LanguageTagWidget;
class RatingDialog;
+class RegionSubtagWidget;
class wxSpinCtrlDouble;
private:
void sign_language_video_language_changed ();
- void edit_release_territory ();
+ void release_territory_changed(boost::optional<dcp::LanguageTag::RegionSubtag> tag);
void enable_release_territory_changed ();
void facility_changed ();
void enable_facility_changed ();
* the string in _release_territory_text to a RegionSubtag we just store the RegionSubtag
* alongside.
*/
- boost::optional<dcp::LanguageTag::RegionSubtag> _release_territory;
- wxStaticText* _release_territory_text;
- Button* _edit_release_territory;
+ boost::optional<dcp::LanguageTag::RegionSubtag> _release_territory_copy;
+ RegionSubtagWidget* _release_territory;
LanguageTagWidget* _sign_language_video_language = nullptr;
CheckBox* _enable_facility;
wxTextCtrl* _facility;
--- /dev/null
+/*
+ Copyright (C) 2020-2021 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 "dcpomatic_button.h"
+#include "full_language_tag_dialog.h"
+#include "region_subtag_dialog.h"
+#include "region_subtag_widget.h"
+#include "wx_util.h"
+#include "lib/scope_guard.h"
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
+#include <wx/wx.h>
+LIBDCP_ENABLE_WARNINGS
+
+
+using boost::optional;
+
+
+RegionSubtagWidget::RegionSubtagWidget(wxWindow* parent, wxString tooltip, optional<dcp::LanguageTag::RegionSubtag> tag, optional<wxString> size_to_fit)
+ : _parent(parent)
+ , _sizer(new wxBoxSizer(wxHORIZONTAL))
+{
+ _region = new wxStaticText(parent, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
+ _region->SetToolTip(tooltip);
+ set(tag);
+
+ if (size_to_fit) {
+ int w;
+ int h;
+ _region->GetTextExtent(*size_to_fit, &w, &h);
+ _region->SetMinSize(wxSize(w, -1));
+ }
+
+ _sizer->Add(_region, 1, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
+ _edit = new Button(parent, _("Edit..."));
+ _sizer->Add(_edit, 0, wxLEFT, DCPOMATIC_SIZER_GAP);
+
+ _edit->Bind(wxEVT_BUTTON, boost::bind(&RegionSubtagWidget::edit, this));
+}
+
+
+RegionSubtagWidget::~RegionSubtagWidget()
+{
+ _region->Destroy();
+ _edit->Destroy();
+}
+
+
+void
+RegionSubtagWidget::edit()
+{
+ auto d = new RegionSubtagDialog(_parent, _tag.get_value_or(dcp::LanguageTag::RegionSubtag("US")));
+ ScopeGuard sg = [d]() { d->Destroy(); };
+
+ if (d->ShowModal() == wxID_OK) {
+ set(d->get());
+ Changed(d->get());
+ }
+}
+
+
+void
+RegionSubtagWidget::set(optional<dcp::LanguageTag::RegionSubtag> tag)
+{
+ _tag = tag;
+ if (tag) {
+ checked_set(_region, std_to_wx(tag->subtag()));
+ } else {
+ checked_set(_region, wxT(""));
+ }
+}
+
+
+void
+RegionSubtagWidget::enable(bool e)
+{
+ _region->Enable(e);
+ _edit->Enable(e);
+}
--- /dev/null
+/*
+ Copyright (C) 2020 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 <dcp/language_tag.h>
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
+#include <wx/wx.h>
+LIBDCP_ENABLE_WARNINGS
+#include <boost/signals2.hpp>
+
+
+class wxButton;
+class wxSizer;
+class wxStaticText;
+class wxWindow;
+
+
+/** A widget which displays and allows the user to edit a RegionSubtag i.e. a representation of a region of the world,
+ * perhaps a "territory" where a DCP will be released.
+ */
+class RegionSubtagWidget
+{
+public:
+ RegionSubtagWidget(wxWindow* parent, wxString tooltip, boost::optional<dcp::LanguageTag::RegionSubtag> tag, boost::optional<wxString> size_to_fit = boost::none);
+ ~RegionSubtagWidget();
+
+ RegionSubtagWidget(RegionSubtagWidget const&) = delete;
+ RegionSubtagWidget& operator=(RegionSubtagWidget const&) = delete;
+
+ wxSizer* sizer() const {
+ return _sizer;
+ }
+
+ boost::optional<dcp::LanguageTag::RegionSubtag> get() const {
+ return _tag;
+ }
+ void set(boost::optional<dcp::LanguageTag::RegionSubtag> tag);
+ void enable(bool e);
+
+ boost::signals2::signal<void (boost::optional<dcp::LanguageTag::RegionSubtag>)> Changed;
+
+private:
+ void edit ();
+
+ wxStaticText* _region;
+ wxButton* _edit;
+ wxWindow* _parent;
+ boost::optional<dcp::LanguageTag::RegionSubtag> _tag;
+ wxSizer* _sizer;
+};
+
recipient_dialog.cc
recreate_chain_dialog.cc
region_subtag_dialog.cc
+ region_subtag_widget.cc
repeat_dialog.cc
report_problem_dialog.cc
rename_template_dialog.cc
#include "file_picker_ctrl.h"
#include "language_tag_widget.h"
#include "password_entry.h"
+#include "region_subtag_widget.h"
#include "static_text.h"
#include "wx_util.h"
#include "lib/config.h"
}
+void
+checked_set(RegionSubtagWidget* widget, optional<dcp::LanguageTag::RegionSubtag> value)
+{
+ if (widget->get() != value) {
+ widget->set(value);
+ }
+}
+
+
void
dcpomatic_setup_i18n ()
{
class FilePickerCtrl;
class LanguageTagWidget;
+class RegionSubtagWidget;
class wxDirPickerCtrl;
class wxSpinCtrl;
class wxSpinCtrlDouble;
extern void checked_set (wxStaticText* widget, wxString value);
extern void checked_set(LanguageTagWidget* widget, dcp::LanguageTag value);
extern void checked_set(LanguageTagWidget* widget, boost::optional<dcp::LanguageTag> value);
+extern void checked_set(RegionSubtagWidget* widget, boost::optional<dcp::LanguageTag::RegionSubtag> value);
extern int wx_get (wxChoice* widget);
extern int wx_get (wxSpinCtrl* widget);