X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Faudio_mapping_view.cc;h=8818deb63737ad54b9492bf450701d0b7b2db636;hb=4ef0091b33e12450e5de4e420dfabfa8b110fc35;hp=f561f29e57c7440c86e093f70c70530466af4626;hpb=b87dd579361845b472968e27ee7b9c02d8c395ce;p=dcpomatic.git diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc index f561f29e5..8818deb63 100644 --- a/src/wx/audio_mapping_view.cc +++ b/src/wx/audio_mapping_view.cc @@ -18,41 +18,43 @@ */ + /** @file src/wx/audio_mapping_view.cc * @brief AudioMappingView class and helpers. */ + +#include "audio_gain_dialog.h" #include "audio_mapping_view.h" #include "wx_util.h" -#include "audio_gain_dialog.h" #include "lib/audio_mapping.h" -#include "lib/util.h" -#include "lib/warnings.h" +#include "lib/maths_util.h" #include #include -DCPOMATIC_DISABLE_WARNINGS -#include -#include -#include +#include +LIBDCP_DISABLE_WARNINGS #include -DCPOMATIC_ENABLE_WARNINGS -#include +#include +#include +#include +LIBDCP_ENABLE_WARNINGS + -using std::cout; using std::list; -using std::string; -using std::min; +using std::make_pair; using std::max; -using std::vector; +using std::min; using std::pair; -using std::make_pair; using std::shared_ptr; +using std::string; +using std::vector; using boost::optional; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif using dcp::locale_convert; + static constexpr auto INDICATOR_SIZE = 20; static constexpr auto ROW_HEIGHT = 32; static constexpr auto MINIMUM_COLUMN_WIDTH = 32; @@ -61,6 +63,7 @@ static constexpr auto TOP_HEIGHT = ROW_HEIGHT * 2; static constexpr auto COLUMN_PADDING = 16; static constexpr auto HORIZONTAL_PAGE_SIZE = 32; + enum { ID_off = 1, ID_minus6dB = 2, @@ -69,6 +72,7 @@ enum { ID_edit = 5 }; + AudioMappingView::AudioMappingView (wxWindow* parent, wxString left_label, wxString from, wxString top_label, wxString to) : wxPanel (parent, wxID_ANY) , _menu_input (0) @@ -122,6 +126,7 @@ AudioMappingView::AudioMappingView (wxWindow* parent, wxString left_label, wxStr _horizontal_scroll->Bind (wxEVT_SCROLL_THUMBRELEASE, boost::bind(&AudioMappingView::scroll, this)); } + void AudioMappingView::size (wxSizeEvent& ev) { @@ -129,6 +134,7 @@ AudioMappingView::size (wxSizeEvent& ev) ev.Skip (); } + void AudioMappingView::setup () { @@ -176,12 +182,14 @@ AudioMappingView::setup () true); } + void AudioMappingView::scroll () { Refresh (); } + void AudioMappingView::paint_static (wxDC& dc) { @@ -203,6 +211,7 @@ AudioMappingView::paint_static (wxDC& dc) dc.SetFont (*wxSWISS_FONT); } + void AudioMappingView::paint_column_labels (wxDC& dc) { @@ -220,6 +229,7 @@ AudioMappingView::paint_column_labels (wxDC& dc) dc.DrawLine(wxPoint(LEFT_WIDTH, ROW_HEIGHT * 2), wxPoint(LEFT_WIDTH + _column_widths_total, ROW_HEIGHT * 2)); } + void AudioMappingView::paint_column_lines (wxDC& dc) { @@ -238,6 +248,7 @@ AudioMappingView::paint_column_lines (wxDC& dc) ); } + void AudioMappingView::paint_row_labels (wxDC& dc) { @@ -298,6 +309,7 @@ AudioMappingView::paint_row_labels (wxDC& dc) } } + void AudioMappingView::paint_row_lines (wxDC& dc) { @@ -313,6 +325,7 @@ AudioMappingView::paint_row_lines (wxDC& dc) ); } + void AudioMappingView::paint_indicators (wxDC& dc) { @@ -354,17 +367,6 @@ AudioMappingView::paint_indicators (wxDC& dc) } } -static -void clip (wxDC& dc, int x, int y, int w, int h) -{ - dc.SetClippingRegion (x, y, w, h); -} - -static -void translate (wxDC& dc, int x, int y) -{ - dc.SetLogicalOrigin (x, y); -} static void restore (wxDC& dc) @@ -373,6 +375,7 @@ void restore (wxDC& dc) dc.DestroyClippingRegion (); } + void AudioMappingView::paint () { @@ -383,62 +386,58 @@ AudioMappingView::paint () paint_static (dc); - clip ( - dc, + dc.SetClippingRegion ( LEFT_WIDTH, 0, _column_widths_total, ROW_HEIGHT * (2 + _input_channels.size()) - ); - translate (dc, hs, 0); + ); + dc.SetLogicalOrigin (hs, 0); paint_column_labels (dc); restore (dc); - clip ( - dc, + dc.SetClippingRegion( 0, TOP_HEIGHT, LEFT_WIDTH, min(int(ROW_HEIGHT * _input_channels.size()), GetSize().GetHeight() - TOP_HEIGHT) + 1 ); - translate (dc, 0, vs); + dc.SetLogicalOrigin (0, vs); paint_row_labels (dc); restore (dc); - clip ( - dc, + dc.SetClippingRegion( MINIMUM_COLUMN_WIDTH * 2, TOP_HEIGHT, MINIMUM_COLUMN_WIDTH + _column_widths_total, min(int(ROW_HEIGHT * (2 + _input_channels.size())), GetSize().GetHeight() - TOP_HEIGHT) ); - translate (dc, hs, vs); + dc.SetLogicalOrigin (hs, vs); paint_row_lines (dc); restore (dc); - clip ( - dc, + dc.SetClippingRegion( LEFT_WIDTH, MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH + _column_widths_total, min(int(ROW_HEIGHT * (1 + _input_channels.size())), GetSize().GetHeight() - ROW_HEIGHT) ); - translate (dc, hs, vs); + dc.SetLogicalOrigin(hs, vs); paint_column_lines (dc); restore (dc); - clip ( - dc, + dc.SetClippingRegion ( LEFT_WIDTH, TOP_HEIGHT, _column_widths_total, min(int(ROW_HEIGHT * _input_channels.size()), GetSize().GetHeight() - TOP_HEIGHT) ); - translate (dc, hs, vs); + dc.SetLogicalOrigin(hs, vs); paint_indicators (dc); restore (dc); } + optional> AudioMappingView::mouse_event_to_channels (wxMouseEvent& ev) const {