From 7392872dacc5f483792d3f41c2049567b4754d7c Mon Sep 17 00:00:00 2001 From: Malte Meyn Date: Mon, 15 Apr 2019 10:49:29 +0200 Subject: [PATCH] work in progress, how to build a markup in C++? --- lily/multi-measure-rest-engraver.cc | 36 +++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index 7e2a30396b..d8d2e87831 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -18,6 +18,7 @@ along with LilyPond. If not, see . */ +#include "context.hh" #include "multi-measure-rest.hh" #include "paper-column.hh" #include "engraver-group.hh" @@ -129,12 +130,43 @@ Multi_measure_rest_engraver::initialize_grobs () { Stream_event *e = text_events_[i]; Spanner *sp = make_spanner ("MultiMeasureRestText", e->self_scm ()); - SCM t = e->get_property ("text"); + SCM dir = e->get_property ("direction"); - sp->set_property ("text", t); if (is_direction (dir)) sp->set_property ("direction", dir); + SCM t = e->get_property ("text"); + SCM a = e->get_property ("articulation-type"); + + if (scm_is_null (t) && !scm_is_null (a)) + { + SCM alist = context ()->get_property ("scriptDefinitions"); + SCM art = scm_assoc (a, alist); + // TODO: warning, see script-engraver.cc + art = scm_cdr (art); + + SCM glyph_pair = scm_cddr (scm_assoc ( + ly_symbol2scm ("script-stencil"), art)); + int glyph_dir; + SCM glyph_name; + + if (is_direction (dir)) + glyph_dir = scm_to_int (dir); + else + glyph_dir = scm_to_int (scm_cdr (scm_assoc ( + ly_symbol2scm ("direction"), art))); + + if (glyph_dir == DOWN) + glyph_name = scm_car (glyph_pair); + else + glyph_name = scm_cdr (glyph_pair); + + t = glyph_name; + // TODO: this prints the glyph name like “ufermata” (without “scripts.”) + // instead of \markup \musicglyph "scripts.ufermata" + } + + sp->set_property ("text", t); text_.push_back (sp); } -- 2.21.0