Move locale_convert into libdcp.
[dcpomatic.git] / src / wx / audio_mapping_view.cc
index 13559ff5355b20a877f38689f6c7b7b0d8009f98..0833eadde25c5fce10215772169d780a8162b1a2 100644 (file)
  *  @brief AudioMappingView class and helpers.
  */
 
-#include "lib/audio_mapping.h"
-#include "lib/util.h"
-#include "lib/raw_convert.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 <dcp/locale_convert.h>
 #include <dcp/types.h>
 #include <wx/wx.h>
 #include <wx/renderer.h>
@@ -45,6 +45,7 @@ using std::vector;
 using std::pair;
 using std::make_pair;
 using boost::shared_ptr;
+using dcp::locale_convert;
 
 #define INDICATOR_SIZE 16
 #define LEFT_WIDTH 48
@@ -85,7 +86,7 @@ public:
                dc.SetBrush (*wxTheBrushList->FindOrCreateBrush (wxColour (255, 255, 255), wxBRUSHSTYLE_SOLID));
                dc.DrawRectangle (wxRect (rect.GetLeft() + xo, rect.GetTop() + yo, INDICATOR_SIZE, INDICATOR_SIZE));
 
-               float const value = raw_convert<float> (wx_to_std (grid.GetCellValue (row, col)));
+               float const value = locale_convert<float> (wx_to_std (grid.GetCellValue (row, col)));
                float const value_dB = 20 * log10 (value);
                int const range = 18;
                int height = 0;
@@ -272,6 +273,7 @@ AudioMappingView::set_output_channels (vector<string> const & names)
        }
 
        update_cells ();
+       setup_sizes ();
 }
 
 void
@@ -299,7 +301,7 @@ AudioMappingView::update_cells ()
                        _grid->SetCellValue (i, 0, std_to_wx (row_names[i]));
                }
                for (int j = 1; j < _grid->GetNumberCols(); ++j) {
-                       _grid->SetCellValue (i, j, std_to_wx (raw_convert<string> (_map.get (i, j - 1))));
+                       _grid->SetCellValue (i, j, std_to_wx (locale_convert<string> (_map.get (i, j - 1))));
                }
        }
 
@@ -345,15 +347,23 @@ AudioMappingView::mouse_moved_grid (wxMouseEvent& ev)
 
 void
 AudioMappingView::sized (wxSizeEvent& ev)
+{
+       setup_sizes ();
+       ev.Skip ();
+}
+
+void
+AudioMappingView::setup_sizes ()
 {
        int const top_height = 24;
 
        _grid->AutoSize ();
        _left_labels->SetMinSize (wxSize (LEFT_WIDTH, _grid->GetSize().GetHeight()));
        _top_labels->SetMinSize (wxSize (_grid->GetSize().GetWidth() + LEFT_WIDTH, top_height));
+       /* Try to make the _top_labels 'actua' size respect the minimum we just set */
+       _top_labels->Fit ();
        _left_labels->Refresh ();
        _top_labels->Refresh ();
-       ev.Skip ();
 }
 
 void