lilypond-0.1.26
[lilypond.git] / lily / stem-grav.cc
blob4cef2a9594ad8ec1003324a7401ca2e4e1e2cc9a
1 /*
2 stem-grav.cc -- implement Stem_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "stem-grav.hh"
10 #include "note-head.hh"
11 #include "stem.hh"
12 #include "musical-request.hh"
13 #include "duration-convert.hh"
14 #include "misc.hh"
16 Stem_engraver::Stem_engraver()
18 abbrev_req_l_ = 0;
19 stem_p_ = 0;
20 default_abbrev_i_ = 16;
21 dir_ = CENTER;
24 void
25 Stem_engraver::do_creation_processing ()
27 Scalar prop = get_property ("abbrev");
28 if (prop.isnum_b ())
30 default_abbrev_i_ = prop;
34 void
35 Stem_engraver::acknowledge_element(Score_elem_info i)
37 if (i.elem_l_->is_type_b (Rhythmic_head::static_name()))
39 Rhythmic_head *h = (Rhythmic_head*) i.elem_l_->item();
40 if (!stem_p_)
42 Rhythmic_req * r = i.req_l_->musical()->rhythmic();
43 stem_p_ = new Stem;
44 int durlog_i = r->duration_.durlog_i_;
45 stem_p_->flag_i_ = durlog_i;
48 if (abbrev_req_l_)
50 int t = abbrev_req_l_->type_i_;
51 if (!t)
52 t = default_abbrev_i_;
53 else
54 default_abbrev_i_ = t;
55 stem_p_->abbrev_flag_i_ =intlog2 (t) - (durlog_i>? 2);
57 announce_element (Score_elem_info (stem_p_, r));
59 stem_p_->add (h);
63 void
64 Stem_engraver::do_pre_move_processing()
66 if (stem_p_)
68 Scalar prop = get_property ("ydirection");
69 dir_ = prop.isnum_b () ? int(prop) : CENTER;
70 if (dir_)
71 stem_p_->dir_ = dir_;
73 typeset_element(stem_p_);
74 stem_p_ = 0;
76 abbrev_req_l_ = 0;
79 bool
80 Stem_engraver::do_try_request (Request* r)
82 Musical_req* mus_l = r->musical ();
83 if (!mus_l)
84 return false;
86 Abbreviation_req* a = mus_l->abbrev ();
87 if (!a)
88 return false;
90 abbrev_req_l_ = a;
92 return true;
95 IMPLEMENT_IS_TYPE_B1(Stem_engraver, Engraver);
96 ADD_THIS_TRANSLATOR(Stem_engraver);