3 plet-engraver.cc -- implement Plet_engraver
5 (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "musical-request.hh"
10 #include "plet-engraver.hh"
11 #include "plet-spanner.hh"
12 #include "text-def.hh"
14 #include "score-column.hh"
18 ADD_THIS_TRANSLATOR (Plet_engraver
);
20 Plet_engraver::Plet_engraver ()
22 beam_mom_drul_
[LEFT
] = span_mom_drul_
[LEFT
] = INT_MAX
;
23 beam_mom_drul_
[RIGHT
] = span_mom_drul_
[LEFT
] = -INT_MAX
;
25 span_reqs_drul_
[RIGHT
] = span_reqs_drul_
[LEFT
] = 0;
29 Plet_engraver::acknowledge_element (Score_element_info i
)
32 Stem
* st
= (dynamic_cast<Stem
*> (i
.elem_l_
));
37 if (!span_reqs_drul_
[LEFT
])
40 if (!plet_spanner_p_
->stem_l_drul_
[LEFT
])
41 plet_spanner_p_
->set_stem (LEFT
, st
);
43 if (span_reqs_drul_
[RIGHT
] && !plet_spanner_p_
->stem_l_drul_
[RIGHT
])
44 plet_spanner_p_
->set_stem (RIGHT
, st
);
48 Plet_engraver::do_try_music (Music
* req_l
)
51 UGH! This is incorrect!
52 Beam_req might not reach the Plet_engraver if ordering is wrong!
54 Beam_req
* b
= dynamic_cast <Beam_req
*> (req_l
);
59 Direction d
= (Direction
)(((int)(b
->spantype_
- 1)) * 2 - 1);
60 beam_mom_drul_
[d
] = get_staff_info ().musical_l ()->when ();
65 Plet_req
* p
= dynamic_cast <Plet_req
*> (req_l
);
69 if (bool (plet_spanner_p_
) == bool (p
->spantype_
== START
))
72 Direction d
= (!plet_spanner_p_
) ? LEFT
: RIGHT
;
73 if (span_reqs_drul_
[d
] && !span_reqs_drul_
[d
]->equal_b (p
))
76 span_reqs_drul_
[d
] = p
;
77 span_mom_drul_
[d
] = get_staff_info ().musical_l ()->when ();
82 Plet_engraver::do_removal_processing ()
86 span_reqs_drul_
[LEFT
]->warning (_ ("unterminated plet"));
87 plet_spanner_p_
->unlink ();
88 delete plet_spanner_p_
;
90 span_reqs_drul_
[RIGHT
] = span_reqs_drul_
[LEFT
] = 0;
95 Plet_engraver::do_process_requests ()
97 if (plet_spanner_p_
|| !span_reqs_drul_
[LEFT
])
100 plet_spanner_p_
= new Plet_spanner
;
101 plet_spanner_p_
->tdef_p_
->text_str_
= to_str (span_reqs_drul_
[LEFT
]->plet_i_
);
103 announce_element (Score_element_info (plet_spanner_p_
, span_reqs_drul_
[LEFT
]));
107 Plet_engraver::do_pre_move_processing ()
109 if (!plet_spanner_p_
|| !span_reqs_drul_
[RIGHT
])
112 Scalar prop
= get_property ("pletvisibility");
114 plet_spanner_p_
->visibility_i_
= prop
;
116 if ((beam_mom_drul_
[LEFT
] <= span_mom_drul_
[LEFT
])
117 && (beam_mom_drul_
[RIGHT
] >= span_mom_drul_
[RIGHT
]))
118 plet_spanner_p_
->visibility_i_
&= ~2;
120 if (plet_spanner_p_
->visibility_i_
)
121 typeset_element (plet_spanner_p_
);
124 plet_spanner_p_
->unlink ();
125 delete plet_spanner_p_
;
129 span_reqs_drul_
[RIGHT
] = span_reqs_drul_
[LEFT
] = 0;