--- /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 "dcpomatic_button.h"
+#include "language_tag_dialog.h"
+#include "language_tag_widget.h"
+#include "wx_util.h"
+#include <wx/wx.h>
+
+
+LanguageTagWidget::LanguageTagWidget (wxWindow* parent, wxSizer* sizer, wxString label, wxString tooltip, dcp::LanguageTag tag)
+ : _parent (parent)
+{
+ add_label_to_sizer(sizer, parent, label, true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL);
+ wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ _language = new wxStaticText (parent, wxID_ANY, wxT(""));
+ _language->SetToolTip (tooltip);
+ set (tag);
+ s->Add (_language, 1, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
+ _edit = new Button (parent, _("Edit..."));
+ s->Add (_edit, 0, wxLEFT, DCPOMATIC_SIZER_GAP);
+ sizer->Add (s, 0, wxEXPAND);
+
+ _edit->Bind (wxEVT_BUTTON, boost::bind(&LanguageTagWidget::edit, this));
+}
+
+
+void
+LanguageTagWidget::edit ()
+{
+ LanguageTagDialog* d = new LanguageTagDialog(_parent, _tag);
+ d->ShowModal ();
+ set (d->get());
+ Changed (d->get());
+ d->Destroy ();
+}
+
+
+void
+LanguageTagWidget::set (dcp::LanguageTag tag)
+{
+ _tag = tag;
+ checked_set (_language, std_to_wx(tag.to_string()));
+}
--- /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 <wx/wx.h>
+#include <boost/noncopyable.hpp>
+#include <boost/signals2.hpp>
+
+
+class wxButton;
+class wxSizer;
+class wxStaticText;
+class wxWindow;
+
+
+class LanguageTagWidget : public boost::noncopyable
+{
+public:
+ LanguageTagWidget (wxWindow* parent, wxSizer* sizer, wxString label, wxString tooltip, dcp::LanguageTag tag);
+
+ void set (dcp::LanguageTag tag);
+
+ boost::signals2::signal<void (dcp::LanguageTag)> Changed;
+
+private:
+ void edit ();
+
+ wxStaticText* _language;
+ wxButton* _edit;
+ wxWindow* _parent;
+ dcp::LanguageTag _tag;
+};
+
#include "content_version_dialog.h"
#include "editable_list.h"
#include "language_tag_dialog.h"
+#include "language_tag_widget.h"
#include "smpte_metadata_dialog.h"
#include "rating_dialog.h"
#include "lib/film.h"
wxFlexGridSizer* sizer = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
sizer->AddGrowableCol (1, 1);
- wxButton* edit_name_language = 0;
- add_label_to_sizer(sizer, this, _("Title language"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL);
- {
- wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
- _name_language = new wxStaticText (this, wxID_ANY, wxT(""));
- _name_language->SetToolTip (wxString::Format(_("The language that the film's title (\"%s\") is in"), std_to_wx(film()->name())));
- s->Add (_name_language, 1, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
- edit_name_language = new Button (this, _("Edit..."));
- s->Add (edit_name_language, 0, wxLEFT, DCPOMATIC_SIZER_GAP);
- sizer->Add (s, 0, wxEXPAND);
- }
+ _name_language = new LanguageTagWidget(
+ this,
+ sizer,
+ _("Title language"),
+ wxString::Format(_("The language that the film's title (\"%s\") is in"), std_to_wx(film()->name())),
+ film()->name_language()
+ );
- wxButton* edit_audio_language = 0;
- add_label_to_sizer(sizer, this, _("Audio language"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL);
- {
- wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
- _audio_language = new wxStaticText (this, wxID_ANY, wxT(""));
- _audio_language->SetToolTip (_("The main language that is spoken in the film's soundtrack"));
- s->Add (_audio_language, 1, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
- edit_audio_language = new Button (this, _("Edit..."));
- s->Add (edit_audio_language, 0, wxLEFT, DCPOMATIC_SIZER_GAP);
- sizer->Add (s, 0, wxEXPAND);
- }
+ _audio_language = new LanguageTagWidget(
+ this,
+ sizer,
+ _("Audio language"),
+ _("The main language that is spoken in the film's soundtrack"),
+ film()->audio_language()
+ );
Button* edit_release_territory = 0;
add_label_to_sizer (sizer, this, _("Release territory"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL);
_luminance_unit->Append (_("candela per m²"));
_luminance_unit->Append (_("foot lambert"));
- edit_name_language->Bind (wxEVT_BUTTON, boost::bind(&SMPTEMetadataDialog::edit_name_language, this));
- edit_audio_language->Bind (wxEVT_BUTTON, boost::bind(&SMPTEMetadataDialog::edit_audio_language, this));
+ _name_language->Changed.connect (boost::bind(&SMPTEMetadataDialog::name_language_changed, this, _1));
+ _audio_language->Changed.connect (boost::bind(&SMPTEMetadataDialog::audio_language_changed, this, _1));
edit_release_territory->Bind (wxEVT_BUTTON, boost::bind(&SMPTEMetadataDialog::edit_release_territory, this));
_version_number->Bind (wxEVT_SPINCTRL, boost::bind(&SMPTEMetadataDialog::version_number_changed, this));
_status->Bind (wxEVT_CHOICE, boost::bind(&SMPTEMetadataDialog::status_changed, this));
}
if (property == Film::NAME_LANGUAGE) {
- checked_set (_name_language, std_to_wx(film()->name_language().to_string()));
+ _name_language->set (film()->name_language());
} else if (property == Film::RELEASE_TERRITORY) {
checked_set (_release_territory, std_to_wx(*dcp::LanguageTag::get_subtag_description(dcp::LanguageTag::REGION, film()->release_territory().subtag())));
} else if (property == Film::VERSION_NUMBER) {
void
-SMPTEMetadataDialog::edit_name_language ()
+SMPTEMetadataDialog::name_language_changed (dcp::LanguageTag tag)
{
- LanguageTagDialog* d = new LanguageTagDialog(this, film()->name_language());
- d->ShowModal ();
- film()->set_name_language (d->get());
- d->Destroy ();
+ film()->set_name_language (tag);
}
void
-SMPTEMetadataDialog::edit_audio_language ()
+SMPTEMetadataDialog::audio_language_changed (dcp::LanguageTag tag)
{
- LanguageTagDialog* d = new LanguageTagDialog(this, film()->audio_language());
- d->ShowModal ();
- film()->set_audio_language (d->get());
- d->Destroy ();
+ film()->set_audio_language (tag);
}
class Film;
class RatingDialog;
class ContentVersionDialog;
+class LanguageTagWidget;
class SMPTEMetadataDialog : public wxDialog
void set_ratings (std::vector<dcp::Rating> r);
std::vector<std::string> content_versions () const;
void set_content_versions (std::vector<std::string> v);
- void edit_name_language ();
- void edit_audio_language ();
+ void name_language_changed (dcp::LanguageTag tag);
+ void audio_language_changed (dcp::LanguageTag tag);
void edit_release_territory ();
void version_number_changed ();
void status_changed ();
boost::shared_ptr<Film> film () const;
boost::weak_ptr<Film> _film;
- wxStaticText* _name_language;
- wxStaticText* _audio_language;
+ LanguageTagWidget* _name_language;
+ LanguageTagWidget* _audio_language;
wxStaticText* _release_territory;
wxSpinCtrl* _version_number;
wxChoice* _status;