X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Faudio_mapping_view.cc;h=a9cdb66999e46ea7d046f85ca07f7948c5c4be32;hb=69829c8c664d301de3f123f9893210eea89d8026;hp=9f1688cdf3ea469b37171963240e3108dd05928d;hpb=102c41ceb089d9038beff0850dbe1a40a2aeae48;p=dcpomatic.git diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc index 9f1688cdf..a9cdb6699 100644 --- a/src/wx/audio_mapping_view.cc +++ b/src/wx/audio_mapping_view.cc @@ -138,6 +138,7 @@ AudioMappingView::AudioMappingView (wxWindow* parent) _grid->EnableEditing (false); _grid->SetCellHighlightPenWidth (0); _grid->SetDefaultRenderer (new NoSelectionStringRenderer); + _grid->EnableScrolling (true, true); _grid->AutoSize (); wxSizer* vertical_sizer = new wxBoxSizer (wxVERTICAL); @@ -151,6 +152,14 @@ AudioMappingView::AudioMappingView (wxWindow* parent) Bind (wxEVT_GRID_CELL_LEFT_CLICK, boost::bind (&AudioMappingView::left_click, this, _1)); Bind (wxEVT_GRID_CELL_RIGHT_CLICK, boost::bind (&AudioMappingView::right_click, this, _1)); _grid->GetGridWindow()->Bind (wxEVT_MOTION, boost::bind (&AudioMappingView::mouse_moved_grid, this, _1)); + _grid->Bind (wxEVT_SCROLLWIN_TOP, boost::bind (&AudioMappingView::grid_scrolled, this)); + _grid->Bind (wxEVT_SCROLLWIN_BOTTOM, boost::bind (&AudioMappingView::grid_scrolled, this)); + _grid->Bind (wxEVT_SCROLLWIN_LINEUP, boost::bind (&AudioMappingView::grid_scrolled, this)); + _grid->Bind (wxEVT_SCROLLWIN_LINEDOWN, boost::bind (&AudioMappingView::grid_scrolled, this)); + _grid->Bind (wxEVT_SCROLLWIN_PAGEUP, boost::bind (&AudioMappingView::grid_scrolled, this)); + _grid->Bind (wxEVT_SCROLLWIN_PAGEDOWN, boost::bind (&AudioMappingView::grid_scrolled, this)); + _grid->Bind (wxEVT_SCROLLWIN_THUMBTRACK, boost::bind (&AudioMappingView::grid_scrolled, this)); + _grid->Bind (wxEVT_SCROLLWIN_THUMBRELEASE, boost::bind (&AudioMappingView::grid_scrolled, this)); Bind (wxEVT_SIZE, boost::bind (&AudioMappingView::sized, this, _1)); _menu = new wxMenu; @@ -159,10 +168,10 @@ AudioMappingView::AudioMappingView (wxWindow* parent) _menu->Append (ID_minus6dB, _("-6dB")); _menu->Append (ID_edit, _("Edit...")); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&AudioMappingView::off, this), ID_off); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&AudioMappingView::full, this), ID_full); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&AudioMappingView::minus6dB, this), ID_minus6dB); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&AudioMappingView::edit, this), ID_edit); + Bind (wxEVT_MENU, boost::bind (&AudioMappingView::off, this), ID_off); + Bind (wxEVT_MENU, boost::bind (&AudioMappingView::full, this), ID_full); + Bind (wxEVT_MENU, boost::bind (&AudioMappingView::minus6dB, this), ID_minus6dB); + Bind (wxEVT_MENU, boost::bind (&AudioMappingView::edit, this), ID_edit); _left_labels->Bind (wxEVT_MOTION, bind (&AudioMappingView::mouse_moved_left_labels, this, _1)); } @@ -263,7 +272,7 @@ AudioMappingView::set_output_channels (vector const & names) if (o < _grid->GetNumberCols ()) { _grid->DeleteCols (o, _grid->GetNumberCols() - o); } else if (o > _grid->GetNumberCols ()) { - _grid->InsertCols (_grid->GetNumberCols(), o - _grid->GetNumberCols()); + _grid->AppendCols (o - _grid->GetNumberCols()); } _grid->SetColLabelValue (0, wxT ("")); @@ -274,6 +283,8 @@ AudioMappingView::set_output_channels (vector const & names) update_cells (); setup_sizes (); + + Layout (); } void @@ -376,6 +387,10 @@ AudioMappingView::paint_left_labels () return; } + int sx, sy; + _grid->CalcUnscrolledPosition (0, 0, &sx, &sy); + gc->Translate (0, -sy); + wxSize const size = dc.GetSize(); int const half = size.GetWidth() / 2; @@ -403,7 +418,7 @@ AudioMappingView::paint_left_labels () dc.DrawRotatedText ( j->name, half + (half - label_height) / 2, - min (i->second, (i->second + i->first + label_width) / 2), + min (i->second, (i->second + i->first + label_width) / 2) - sy, 90 ); @@ -426,7 +441,7 @@ AudioMappingView::paint_left_labels () dc.DrawRotatedText ( _("Content"), (half - overall_label_height) / 2, - min (size.GetHeight(), (size.GetHeight() + _grid->GetColLabelSize() + overall_label_width) / 2), + min (size.GetHeight(), (size.GetHeight() + _grid->GetColLabelSize() + overall_label_width) / 2 - sy), 90 ); @@ -446,6 +461,10 @@ AudioMappingView::paint_top_labels () return; } + int sx, sy; + _grid->CalcUnscrolledPosition (0, 0, &sx, &sy); + gc->Translate (-sx, 0); + wxSize const size = dc.GetSize(); gc->SetAntialiasMode (wxANTIALIAS_DEFAULT); @@ -455,7 +474,7 @@ AudioMappingView::paint_top_labels () wxCoord label_height; dc.GetTextExtent (_("DCP"), &label_width, &label_height); - dc.DrawText (_("DCP"), (size.GetWidth() + _grid->GetColSize(0) + LEFT_WIDTH - label_width) / 2, (size.GetHeight() - label_height) / 2); + dc.DrawText (_("DCP"), (size.GetWidth() + _grid->GetColSize(0) + LEFT_WIDTH - label_width) / 2 - sx, (size.GetHeight() - label_height) / 2); gc->SetPen (wxPen (wxColour (0, 0, 0))); wxGraphicsPath lines = gc->CreatePath(); @@ -471,6 +490,10 @@ AudioMappingView::paint_top_labels () void AudioMappingView::set_input_groups (vector const & groups) { + if (_grid->GetNumberRows() == 0) { + return; + } + _input_groups = groups; _input_group_positions.clear (); @@ -497,3 +520,12 @@ AudioMappingView::mouse_moved_left_labels (wxMouseEvent& event) _left_labels->SetToolTip (""); } } + +void +AudioMappingView::grid_scrolled () +{ + _left_labels->Refresh (); + _left_labels->Update (); + _top_labels->Refresh (); + _top_labels->Update (); +}