]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-spanner.cc
release: 0.1.39
[lilypond.git] / lily / text-spanner.cc
1 /*
2   text-spanner.cc -- implement Text_spanner
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
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"
16
17
18 void
19 Text_spanner::set_support (Directional_spanner*d)
20 {
21   if (support_span_l_)
22     remove_dependency (support_span_l_);
23   
24   support_span_l_ =d;
25   add_dependency (d);
26 }
27 void
28 Text_spanner::do_add_processing ()
29 {
30   set_bounds (LEFT, support_span_l_->spanned_drul_[LEFT]);
31   set_bounds (RIGHT, support_span_l_->spanned_drul_[RIGHT]);
32 }
33
34 Text_spanner::Text_spanner()
35 {
36   spec_p_ = 0;
37   support_span_l_ = 0;
38 }
39
40
41 IMPLEMENT_IS_TYPE_B1(Text_spanner,Spanner);
42
43 void
44 Text_spanner::do_print() const
45 {
46   spec_p_->print();
47 }
48
49 void
50 Text_spanner::do_post_processing()
51 {
52   text_off_ = support_span_l_->center() +
53         Offset (0,support_span_l_->dir_ * paper()->internote_f () * 4); // todo
54 }
55
56 Molecule*
57 Text_spanner::brew_molecule_p() const
58 {
59   Atom tsym (spec_p_->get_atom (paper(),CENTER));
60   tsym.translate (text_off_);
61
62   Molecule*output = new Molecule;
63   output->add (tsym);
64   return output;
65 }
66
67 void
68 Text_spanner::do_pre_processing()
69 {
70   spanned_drul_ = support_span_l_->spanned_drul_;
71 }
72
73 Interval
74 Text_spanner::height() const
75 {
76   return brew_molecule_p()->extent ().y ();
77 }
78
79 void
80 Text_spanner::do_substitute_dependency (Score_elem* o, Score_elem*n)
81 {
82   if (support_span_l_ == o) 
83         support_span_l_ = (Directional_spanner*) (n?n->spanner():0);
84 }
85
86
87 Text_spanner::~Text_spanner()
88 {
89   delete spec_p_;
90 }
91
92 Text_spanner::Text_spanner (Text_spanner const&s)
93   : Spanner (s)
94 {
95   support_span_l_ = s.support_span_l_;
96   spec_p_ = s.spec_p_? s.spec_p_->clone() : 0;
97   text_off_ = s.text_off_;
98 }