2 Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
22 #include "content_properties_dialog.h"
24 #include "static_text.h"
25 #include "lib/content.h"
26 #include "lib/video_content.h"
27 #include "lib/audio_content.h"
28 #include <boost/algorithm/string.hpp>
35 using std::shared_ptr;
36 using std::dynamic_pointer_cast;
39 ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr<const Film> film, shared_ptr<Content> content)
40 : TableDialog (parent, _("Content Properties"), 2, 1, false)
42 map<UserProperty::Category, list<UserProperty>> grouped;
43 for (auto i: content->user_properties(film)) {
44 if (grouped.find(i.category) == grouped.end()) {
45 grouped[i.category] = list<UserProperty> ();
47 grouped[i.category].push_back (i);
50 maybe_add_group (grouped, UserProperty::GENERAL);
51 maybe_add_group (grouped, UserProperty::VIDEO);
52 maybe_add_group (grouped, UserProperty::AUDIO);
53 maybe_add_group (grouped, UserProperty::LENGTH);
55 /* Nasty hack to stop the bottom property being cut off on Windows / OS X */
56 add (wxString(), false);
57 add (wxString(), false);
64 ContentPropertiesDialog::maybe_add_group (map<UserProperty::Category, list<UserProperty>> const & groups, UserProperty::Category category)
66 auto i = groups.find (category);
67 if (i == groups.end()) {
71 wxString category_name;
73 case UserProperty::GENERAL:
74 category_name = _("General");
76 case UserProperty::VIDEO:
77 category_name = _("Video");
79 case UserProperty::AUDIO:
80 category_name = _("Audio");
82 case UserProperty::LENGTH:
83 category_name = _("Length");
87 auto m = new StaticText (this, category_name);
88 wxFont font (*wxNORMAL_FONT);
89 font.SetWeight (wxFONTWEIGHT_BOLD);
97 for (auto j: i->second) {
98 add (std_to_wx (j.key), true);
99 add (new StaticText (this, std_to_wx (j.value + " " + j.unit)));