lilypond-1.3.130
[lilypond.git] / lily / plet-engraver.cc
blobff855674b563b46d37457aefe58c94bb78c2ec8b
1 #if 0
2 /*
3 plet-engraver.cc -- implement Plet_engraver
5 (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
6 */
8 #include "proto.hh"
9 #include "musical-request.hh"
10 #include "plet-engraver.hh"
11 #include "plet-spanner.hh"
12 #include "text-def.hh"
13 #include "beam.hh"
14 #include "score-column.hh"
15 #include "stem.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;
24 plet_spanner_p_ = 0;
25 span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0;
28 void
29 Plet_engraver::acknowledge_element (Score_element_info i)
32 Stem * st = (dynamic_cast<Stem *> (i.elem_l_));
33 if (!st)
34 return;
35 if (!plet_spanner_p_)
36 return;
37 if (!span_reqs_drul_[LEFT])
38 return;
40 if (!plet_spanner_p_->stem_l_drul_[LEFT])
41 plet_spanner_p_->set_stem (LEFT, st);
42 else
43 if (span_reqs_drul_[RIGHT] && !plet_spanner_p_->stem_l_drul_[RIGHT])
44 plet_spanner_p_->set_stem (RIGHT, st);
47 bool
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);
55 if (b)
57 if (b->spantype_)
59 Direction d = (Direction)(((int)(b->spantype_ - 1)) * 2 - 1);
60 beam_mom_drul_[d] = get_staff_info ().musical_l ()->when ();
62 return false;
65 Plet_req* p = dynamic_cast <Plet_req *> (req_l);
66 if (!p)
67 return false;
69 if (bool (plet_spanner_p_) == bool (p->spantype_ == START))
70 return false;
72 Direction d = (!plet_spanner_p_) ? LEFT : RIGHT;
73 if (span_reqs_drul_[d] && !span_reqs_drul_[d]->equal_b (p))
74 return false;
76 span_reqs_drul_[d] = p;
77 span_mom_drul_[d] = get_staff_info ().musical_l ()->when ();
78 return true;
81 void
82 Plet_engraver::do_removal_processing ()
84 if (plet_spanner_p_)
86 span_reqs_drul_[LEFT]->warning (_ ("unterminated plet"));
87 plet_spanner_p_->unlink ();
88 delete plet_spanner_p_;
89 plet_spanner_p_ = 0;
90 span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0;
94 void
95 Plet_engraver::do_process_requests ()
97 if (plet_spanner_p_ || !span_reqs_drul_[LEFT])
98 return;
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]));
106 void
107 Plet_engraver::do_pre_move_processing ()
109 if (!plet_spanner_p_ || !span_reqs_drul_[RIGHT])
110 return;
112 Scalar prop = get_property ("pletvisibility");
113 if (prop.isnum_b ())
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_);
122 else
124 plet_spanner_p_->unlink ();
125 delete plet_spanner_p_;
128 plet_spanner_p_ = 0;
129 span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0;
132 #endif