Store subtitle language(s) in Film, and allow setup of those
[dcpomatic.git] / src / wx / language_tag_dialog.h
1 /*
2     Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #ifndef DCPOMATIC_LANGUAGE_TAG_DIALOG_H
23 #define DCPOMATIC_LANGUAGE_TAG_DIALOG_H
24
25
26 #include "lib/warnings.h"
27 #include <dcp/language_tag.h>
28 DCPOMATIC_DISABLE_WARNINGS
29 #include <wx/wx.h>
30 DCPOMATIC_ENABLE_WARNINGS
31
32
33 class wxListCtrl;
34 class LanguageSubtagPanel;
35
36
37 class LanguageTagDialog : public wxDialog
38 {
39 public:
40         class Subtag
41         {
42         public:
43                 Subtag (dcp::LanguageTag::SubtagType type_, boost::optional<dcp::LanguageTag::SubtagData> subtag_)
44                         : type (type_)
45                         , subtag (subtag_)
46                 {}
47
48                 dcp::LanguageTag::SubtagType type;
49                 boost::optional<dcp::LanguageTag::SubtagData> subtag;
50                 std::string last_search;
51         };
52
53         LanguageTagDialog (wxWindow* parent, dcp::LanguageTag tag = dcp::LanguageTag("en"));
54
55         dcp::LanguageTag get () const;
56         void set (dcp::LanguageTag tag);
57
58 private:
59
60         std::string subtag_type_name (dcp::LanguageTag::SubtagType type);
61         void search_changed (std::string search);
62         void add_to_current_tag (dcp::LanguageTag::SubtagType type, boost::optional<dcp::LanguageTag::SubtagData> subtag);
63         void remove_from_current_tag ();
64         void current_tag_selection_changed ();
65         void chosen_subtag_changed (boost::optional<dcp::LanguageTag::SubtagData> selection);
66         void setup_sensitivity ();
67
68         std::vector<Subtag> _current_tag_subtags;
69         wxListCtrl* _current_tag_list;
70         LanguageSubtagPanel* _choose_subtag_panel;
71         wxButton* _add_script;
72         wxButton* _add_region;
73         wxButton* _add_variant;
74         wxButton* _add_external;
75         wxButton* _remove;
76 };
77
78
79
80 class RegionSubtagDialog : public wxDialog
81 {
82 public:
83         RegionSubtagDialog (wxWindow* parent, dcp::LanguageTag::RegionSubtag region);
84
85         boost::optional<dcp::LanguageTag::RegionSubtag> get () const;
86
87 private:
88         LanguageSubtagPanel* _panel;
89 };
90
91
92 #endif