push2: fix an apparent bug in cairo when drawing follow action icons

It seems that using ::move_to() followed by Pango::Layout::show_in_cairo_context() leaves
the context in a state that is not correctly restored when using ::restore(). Therefore,
clear the path to avoid leaving any dangling current point
This commit is contained in:
Paul Davis 2022-09-22 00:43:25 -06:00
parent 7cad01ae1e
commit af28394bfd
1 changed files with 8 additions and 3 deletions

View File

@ -906,6 +906,7 @@ FollowActionIcon::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::
context->move_to (size / 2, size / 2);
context->rel_move_to (-tw / 2, -th / 2);
layout->show_in_cairo_context (context);
context->begin_new_path ();
context->restore ();
return;
}
@ -947,14 +948,18 @@ FollowActionIcon::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::
break;
}
}
assert (cue_idx >= 0);
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
layout->set_font_description (font_description);
layout->set_text (cue_marker_name (cue_idx));
int tw, th;
layout->get_pixel_size (tw, th);
// context->move_to (size / 2, size / 2);
// context->rel_move_to (-tw / 2, -th / 2);
// layout->show_in_cairo_context (context);
context->move_to ((size / 2) - (tw/2), (size / 2) - (th/2));
layout->show_in_cairo_context (context);
/* the above call does not clear the path and neither
* does ::restore()
*/
context->begin_new_path ();
} else if (false) { // 'ANY' jump
for (int i = 0; i < 6; i++) {
Cairo::Matrix m = context->get_matrix ();