gc->StrokePath (lines);
}
+static
+void clip (wxDC& dc, wxGraphicsContext* gc, int x, int y, int w, int h)
+{
+ dc.SetClippingRegion (x, y, w, h);
+ gc->Clip (x, y, w, h);
+}
+
+static
+void translate (wxDC& dc, wxGraphicsContext* gc, int x, int y)
+{
+ gc->PushState ();
+ gc->Translate (-x, -y);
+ dc.SetLogicalOrigin (x, y);
+}
+
+static
+void restore (wxDC& dc, wxGraphicsContext* gc)
+{
+ dc.SetLogicalOrigin (0, 0);
+ gc->PopState ();
+ dc.DestroyClippingRegion ();
+ gc->ResetClip ();
+}
+
void
AudioMappingView::paint_row_labels (wxDC& dc, wxGraphicsContext* gc)
{
int y = TOP_HEIGHT;
BOOST_FOREACH (Group i, _input_groups) {
- dc.GetTextExtent (std_to_wx(i.name), &label_width, &label_height);
int const height = (i.to - i.from + 1) * GRID_SPACING;
+ dc.GetTextExtent (std_to_wx(i.name), &label_width, &label_height);
+ if (label_width > height) {
+ label_width = height - 8;
+ }
+ clip (dc, gc, GRID_SPACING, y + 4, GRID_SPACING, height - 4);
dc.DrawRotatedText (
std_to_wx(i.name),
GRID_SPACING + (GRID_SPACING - label_height) / 2,
y + (height + label_width) / 2,
90
);
+ restore (dc, gc);
lines.MoveToPoint (GRID_SPACING, y);
lines.AddLineToPoint (GRID_SPACING * 2, y);
y += height;
void
AudioMappingView::paint_indicators (wxDC& dc)
{
- for (size_t x = 0; x < _output_channels.size(); ++x) {
- for (size_t y = 0; y < _input_channels.size(); ++y) {
+ /* _{input,output}_channels and _map may not always be in sync, be careful here */
+ size_t const output = min(_output_channels.size(), size_t(_map.output_channels()));
+ size_t const input = min(_input_channels.size(), size_t(_map.input_channels()));
+
+ for (size_t x = 0; x < output; ++x) {
+ for (size_t y = 0; y < input; ++y) {
dc.SetBrush (*wxWHITE_BRUSH);
dc.DrawRectangle (
wxRect(
}
}
-static
-void clip (wxDC& dc, wxGraphicsContext* gc, int x, int y, int w, int h)
-{
- dc.SetClippingRegion (x, y, w, h);
- gc->Clip (x, y, w, h);
-}
-
-static
-void translate (wxDC& dc, wxGraphicsContext* gc, int x, int y)
-{
- gc->PushState ();
- gc->Translate (-x, -y);
- dc.SetLogicalOrigin (x, y);
-}
-
-static
-void restore (wxDC& dc, wxGraphicsContext* gc)
-{
- dc.SetLogicalOrigin (0, 0);
- gc->PopState ();
- dc.DestroyClippingRegion ();
- gc->ResetClip ();
-}
-
void
AudioMappingView::paint ()
{
paint_column_labels (dc, gc);
restore (dc, gc);
- clip (dc, gc, 0, TOP_HEIGHT, GRID_SPACING * (3 + _output_channels.size()), GRID_SPACING * _input_channels.size());
+ clip (dc, gc, 0, TOP_HEIGHT, GRID_SPACING * (3 + _output_channels.size()), GRID_SPACING * _input_channels.size() + 1);
translate (dc, gc, 0, vs);
paint_row_labels (dc, gc);
restore (dc, gc);
- clip (dc, gc, GRID_SPACING * 2, TOP_HEIGHT, GRID_SPACING * (1 + _output_channels.size()), GRID_SPACING * _input_channels.size());
+ clip (dc, gc, GRID_SPACING * 2, TOP_HEIGHT, GRID_SPACING * (1 + _output_channels.size()), GRID_SPACING * _input_channels.size() + 1);
translate (dc, gc, hs, vs);
paint_row_lines (gc);
restore (dc, gc);
- clip (dc, gc, LEFT_WIDTH, GRID_SPACING, GRID_SPACING * (1 + _output_channels.size()), GRID_SPACING * _input_channels.size());
+ clip (dc, gc, LEFT_WIDTH, GRID_SPACING, GRID_SPACING * (1 + _output_channels.size()), GRID_SPACING * (1 + _input_channels.size()));
translate (dc, gc, hs, vs);
paint_column_lines (gc);
restore (dc, gc);