From bb5434e9845556a0bd58792c3082a8a15abd127e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 15 Jul 2016 22:53:21 +0100 Subject: [PATCH] Add channel count hints to the default audio channel count preference, and remove the choice for default to zero channels. Remove em-dash from hints as it apparently does not render on Windows for some reason. --- src/wx/config_dialog.cc | 10 +++------- src/wx/dcp_panel.cc | 27 ++------------------------- src/wx/dcp_panel.h | 1 - src/wx/wx_util.cc | 26 +++++++++++++++++++++++++- src/wx/wx_util.h | 1 + 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index e44ed879b..8b7cbdae5 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -43,6 +43,7 @@ #include "lib/exceptions.h" #include #include +#include #include #include #include @@ -477,12 +478,7 @@ private: _dcp_content_type->Append (std_to_wx (ct[i]->pretty_name ())); } - vector > items; - for (int i = 0; i <= 16; i += 2) { - items.push_back (make_pair (raw_convert (i), raw_convert (i))); - } - - checked_set (_dcp_audio_channels, items); + setup_audio_channels_choice (_dcp_audio_channels, 2); _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DefaultsPage::dcp_content_type_changed, this)); _dcp_audio_channels->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DefaultsPage::dcp_audio_channels_changed, this)); @@ -539,7 +535,7 @@ private: { int const s = _dcp_audio_channels->GetSelection (); if (s != wxNOT_FOUND) { - Config::instance()->set_default_dcp_audio_channels (s * 2); + Config::instance()->set_default_dcp_audio_channels (dcp::raw_convert (string_client_data (_dcp_audio_channels->GetClientObject (s)))); } } diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 5b882763f..49595dfd7 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -404,7 +404,7 @@ DCPPanel::film_changed (int p) } else { checked_set (_audio_processor, 0); } - setup_audio_channels_choice (); + setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels ()); film_changed (Film::AUDIO_CHANNELS); break; case Film::REEL_TYPE: @@ -728,29 +728,6 @@ DCPPanel::minimum_allowed_audio_channels () const return min; } -void -DCPPanel::setup_audio_channels_choice () -{ - vector > items; - for (int i = minimum_allowed_audio_channels(); i <= 16; i += 2) { - if (i == 2) { - items.push_back (make_pair (wx_to_std (_("2 — stereo")), dcp::raw_convert (i))); - } else if (i == 4) { - items.push_back (make_pair (wx_to_std (_("4 — L/C/R/Lfe")), dcp::raw_convert (i))); - } else if (i == 6) { - items.push_back (make_pair (wx_to_std (_("6 — 5.1")), dcp::raw_convert (i))); - } else if (i == 8) { - items.push_back (make_pair (wx_to_std (_("8 — 5.1/HI/VI")), dcp::raw_convert (i))); - } else if (i == 12) { - items.push_back (make_pair (wx_to_std (_("12 — 7.1/HI/VI")), dcp::raw_convert (i))); - } else { - items.push_back (make_pair (dcp::raw_convert (i), dcp::raw_convert (i))); - } - } - - checked_set (_audio_channels, items); -} - wxPanel * DCPPanel::make_audio_panel () { @@ -764,7 +741,7 @@ DCPPanel::make_audio_panel () add_label_to_sizer (grid, panel, _("Channels"), true, wxGBPosition (r, 0)); _audio_channels = new wxChoice (panel, wxID_ANY); - setup_audio_channels_choice (); + setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels ()); grid->Add (_audio_channels, wxGBPosition (r, 1)); ++r; diff --git a/src/wx/dcp_panel.h b/src/wx/dcp_panel.h index a6fab5d05..9209d3f9b 100644 --- a/src/wx/dcp_panel.h +++ b/src/wx/dcp_panel.h @@ -79,7 +79,6 @@ private: void setup_frame_rate_widget (); void setup_container (); void setup_dcp_name (); - void setup_audio_channels_choice (); int minimum_allowed_audio_channels () const; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 40e72543a..e12443dd3 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington This file is part of DCP-o-matic. @@ -26,6 +26,7 @@ #include "file_picker_ctrl.h" #include "lib/config.h" #include "lib/util.h" +#include #include #include @@ -357,3 +358,26 @@ time_to_timecode (DCPTime t, double fps) int const f = lrint (w * fps); return wxString::Format (wxT("%02d:%02d:%02d.%02d"), h, m, s, f); } + +void +setup_audio_channels_choice (wxChoice* choice, int minimum) +{ + vector > items; + for (int i = minimum; i <= 16; i += 2) { + if (i == 2) { + items.push_back (make_pair (wx_to_std (_("2 - stereo")), dcp::raw_convert (i))); + } else if (i == 4) { + items.push_back (make_pair (wx_to_std (_("4 - L/C/R/Lfe")), dcp::raw_convert (i))); + } else if (i == 6) { + items.push_back (make_pair (wx_to_std (_("6 - 5.1")), dcp::raw_convert (i))); + } else if (i == 8) { + items.push_back (make_pair (wx_to_std (_("8 - 5.1/HI/VI")), dcp::raw_convert (i))); + } else if (i == 12) { + items.push_back (make_pair (wx_to_std (_("12 - 7.1/HI/VI")), dcp::raw_convert (i))); + } else { + items.push_back (make_pair (dcp::raw_convert (i), dcp::raw_convert (i))); + } + } + + checked_set (choice, items); +} diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index 54552e3cb..44a2a8212 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -69,6 +69,7 @@ extern void dcpomatic_setup_i18n (); extern wxString context_translation (wxString); extern std::string string_client_data (wxClientData* o); extern wxString time_to_timecode (DCPTime t, double fps); +extern void setup_audio_channels_choice (wxChoice* choice, int minimum); extern void checked_set (FilePickerCtrl* widget, boost::filesystem::path value); extern void checked_set (wxSpinCtrl* widget, int value); -- 2.30.2