Cleanup: remove duplication.
[dcpomatic.git] / src / wx / audio_mapping_view.cc
index 7c12a16462d52eacad9e9e0e810c65d017ceb345..54b951df5aa995a50f5df3a27775d0095c867d7c 100644 (file)
  */
 
 
+#include "audio_gain_dialog.h"
 #include "audio_mapping_view.h"
+#include "wx_ptr.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 <dcp/locale_convert.h>
 #include <dcp/types.h>
-DCPOMATIC_DISABLE_WARNINGS
-#include <wx/wx.h>
-#include <wx/renderer.h>
-#include <wx/grid.h>
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/graphics.h>
-DCPOMATIC_ENABLE_WARNINGS
-#include <iostream>
+#include <wx/grid.h>
+#include <wx/renderer.h>
+#include <wx/wx.h>
+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;
@@ -281,6 +280,11 @@ AudioMappingView::paint_row_labels (wxDC& dc)
        }
        dc.DrawLine (wxPoint(MINIMUM_COLUMN_WIDTH, y), wxPoint(MINIMUM_COLUMN_WIDTH * 2, y));
 
+       if (_input_groups.empty()) {
+               auto const bottom = TOP_HEIGHT + _input_channels.size() * ROW_HEIGHT;
+               dc.DrawLine(wxPoint(MINIMUM_COLUMN_WIDTH, bottom), wxPoint(MINIMUM_COLUMN_WIDTH * 2, bottom));
+       }
+
        /* Group labels and lines; be careful here as wxDCClipper does not restore the old
         * clipping rectangle after it is destroyed
         */
@@ -315,16 +319,12 @@ AudioMappingView::paint_row_labels (wxDC& dc)
 void
 AudioMappingView::paint_row_lines (wxDC& dc)
 {
-       for (size_t i = 0; i < _input_channels.size(); ++i) {
+       for (size_t i = 0; i < _input_channels.size() + 1; ++i) {
                dc.DrawLine (
                        wxPoint(MINIMUM_COLUMN_WIDTH * 2, TOP_HEIGHT + ROW_HEIGHT * i),
                        wxPoint(LEFT_WIDTH + _column_widths_total, TOP_HEIGHT + ROW_HEIGHT * i)
                        );
        }
-       dc.DrawLine (
-               wxPoint(MINIMUM_COLUMN_WIDTH * 2, TOP_HEIGHT + ROW_HEIGHT * _input_channels.size()),
-               wxPoint(LEFT_WIDTH + _column_widths_total, TOP_HEIGHT + ROW_HEIGHT * _input_channels.size())
-               );
 }
 
 
@@ -552,13 +552,11 @@ AudioMappingView::set_gain_from_menu (double linear)
 void
 AudioMappingView::edit ()
 {
-       auto dialog = new AudioGainDialog (this, _menu_input, _menu_output, _map.get(_menu_input, _menu_output));
+       auto dialog = make_wx<AudioGainDialog>(this, _menu_input, _menu_output, _map.get(_menu_input, _menu_output));
        if (dialog->ShowModal() == wxID_OK) {
                _map.set (_menu_input, _menu_output, dialog->value ());
                map_values_changed ();
        }
-
-       dialog->Destroy ();
 }
 
 void