diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-11 12:41:09 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-11 12:41:09 +0100 |
| commit | 2f848b51a4ac00f7f25691fad40841d066f867cc (patch) | |
| tree | ad2ecb200a0b6f58ea4133ec8336ff0a76bde2ac /src/wx/audio_mapping_view.cc | |
| parent | 4985bbd615df73bf92fa14ba5cd585aa051e5b12 (diff) | |
Basics of allowing setup of DCP audio channels.
Diffstat (limited to 'src/wx/audio_mapping_view.cc')
| -rw-r--r-- | src/wx/audio_mapping_view.cc | 75 |
1 files changed, 60 insertions, 15 deletions
diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc index 1e938b357..859c4d548 100644 --- a/src/wx/audio_mapping_view.cc +++ b/src/wx/audio_mapping_view.cc @@ -99,15 +99,7 @@ AudioMappingView::AudioMappingView (wxWindow* parent) _grid->SetCellHighlightPenWidth (0); _grid->SetDefaultRenderer (new NoSelectionStringRenderer); - _grid->SetColLabelValue (0, _("Content channel")); - _grid->SetColLabelValue (1, _("L")); - _grid->SetColLabelValue (2, _("R")); - _grid->SetColLabelValue (3, _("C")); - _grid->SetColLabelValue (4, _("Lfe")); - _grid->SetColLabelValue (5, _("Ls")); - _grid->SetColLabelValue (6, _("Rs")); - - _grid->AutoSize (); + set_column_labels (); _sizer = new wxBoxSizer (wxVERTICAL); _sizer->Add (_grid, 1, wxEXPAND | wxALL); @@ -129,26 +121,28 @@ AudioMappingView::left_click (wxGridEvent& ev) _grid->SetCellValue (ev.GetRow(), ev.GetCol(), wxT("1")); } - AudioMapping mapping; + _map = AudioMapping (); for (int i = 0; i < _grid->GetNumberRows(); ++i) { for (int j = 1; j < _grid->GetNumberCols(); ++j) { if (_grid->GetCellValue (i, j) == wxT ("1")) { - mapping.add (i, static_cast<libdcp::Channel> (j - 1)); + _map.add (i, static_cast<libdcp::Channel> (j - 1)); } } } - Changed (mapping); + Changed (_map); } void AudioMappingView::set (AudioMapping map) { + _map = map; + if (_grid->GetNumberRows ()) { _grid->DeleteRows (0, _grid->GetNumberRows ()); } - list<int> content_channels = map.content_channels (); + list<int> content_channels = _map.content_channels (); _grid->InsertRows (0, content_channels.size ()); for (size_t r = 0; r < content_channels.size(); ++r) { @@ -161,11 +155,62 @@ AudioMappingView::set (AudioMapping map) for (list<int>::iterator i = content_channels.begin(); i != content_channels.end(); ++i) { _grid->SetCellValue (n, 0, wxString::Format (wxT("%d"), *i + 1)); - list<libdcp::Channel> const d = map.content_to_dcp (*i); + list<libdcp::Channel> const d = _map.content_to_dcp (*i); for (list<libdcp::Channel>::const_iterator j = d.begin(); j != d.end(); ++j) { - _grid->SetCellValue (n, static_cast<int> (*j) + 1, wxT("1")); + int const c = static_cast<int>(*j) + 1; + if (c < _grid->GetNumberCols ()) { + _grid->SetCellValue (n, c, wxT("1")); + } } ++n; } } +void +AudioMappingView::set_channels (int c) +{ + c++; + + if (c < _grid->GetNumberCols ()) { + _grid->DeleteCols (c, _grid->GetNumberCols() - c); + } else if (c > _grid->GetNumberCols ()) { + _grid->InsertCols (_grid->GetNumberCols(), c - _grid->GetNumberCols()); + set_column_labels (); + } + + set (_map); +} + +void +AudioMappingView::set_column_labels () +{ + int const c = _grid->GetNumberCols (); + + _grid->SetColLabelValue (0, _("Content channel")); + + if (c > 0) { + _grid->SetColLabelValue (1, _("L")); + } + + if (c > 1) { + _grid->SetColLabelValue (2, _("R")); + } + + if (c > 2) { + _grid->SetColLabelValue (3, _("C")); + } + + if (c > 3) { + _grid->SetColLabelValue (4, _("Lfe")); + } + + if (c > 4) { + _grid->SetColLabelValue (5, _("Ls")); + } + + if (c > 5) { + _grid->SetColLabelValue (6, _("Rs")); + } + + _grid->AutoSize (); +} |
