lilypond-0.1.35
[lilypond.git] / lily / text-spanner.cc
blobc23bb7e645e3ad1d40988579e6a9cca83d95a058
1 /*
2 text-spanner.cc -- implement Text_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "molecule.hh"
10 #include "boxes.hh"
11 #include "text-spanner.hh"
12 #include "text-def.hh"
13 #include "debug.hh"
14 #include "paper-def.hh"
15 #include "atom.hh"
18 void
19 Text_spanner::set_support (Directional_spanner*d)
21 if (support_span_l_)
22 remove_dependency (support_span_l_);
24 support_span_l_ =d;
25 add_dependency (d);
28 Text_spanner::Text_spanner()
30 spec_p_ = 0;
31 support_span_l_ = 0;
35 IMPLEMENT_IS_TYPE_B1(Text_spanner,Spanner);
37 void
38 Text_spanner::do_print() const
40 spec_p_->print();
43 void
44 Text_spanner::do_post_processing()
46 text_off_ = support_span_l_->center() +
47 Offset (0,support_span_l_->dir_ * paper()->internote_f () * 4); // todo
50 Molecule*
51 Text_spanner::brew_molecule_p() const
53 Atom tsym (spec_p_->get_atom (paper(),CENTER));
54 tsym.translate (text_off_);
56 Molecule*output = new Molecule;
57 output->add (tsym);
58 return output;
61 void
62 Text_spanner::do_pre_processing()
64 spanned_drul_ = support_span_l_->spanned_drul_;
67 Interval
68 Text_spanner::height() const
70 return brew_molecule_p()->extent ().y ();
73 void
74 Text_spanner::do_substitute_dependency (Score_elem* o, Score_elem*n)
76 if (support_span_l_ == o)
77 support_span_l_ = (Directional_spanner*) (n?n->spanner():0);
81 Text_spanner::~Text_spanner()
83 delete spec_p_;
86 Text_spanner::Text_spanner (Text_spanner const&s)
87 : Spanner (s)
89 support_span_l_ = s.support_span_l_;
90 spec_p_ = s.spec_p_? s.spec_p_->clone() : 0;
91 text_off_ = s.text_off_;