]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-spanner.cc
release: 1.1.35
[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--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "molecule.hh"
10 #include "box.hh"
11 #include "text-spanner.hh"
12 #include "text-def.hh"
13 #include "debug.hh"
14 #include "paper-def.hh"
15
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
28 void
29 Text_spanner::do_add_processing ()
30 {
31   set_bounds (LEFT, support_span_l_->spanned_drul_[LEFT]);
32   set_bounds (RIGHT, support_span_l_->spanned_drul_[RIGHT]);
33 }
34
35 Text_spanner::Text_spanner()
36 {
37   spec_p_ = 0;
38   support_span_l_ = 0;
39 }
40
41 void
42 Text_spanner::do_print() const
43 {
44   spec_p_->print();
45 }
46
47 void
48 Text_spanner::do_post_processing()
49 {
50   text_off_ = support_span_l_->center() +
51         Offset (0,support_span_l_->dir_ * paper_l ()->get_realvar(interline_scm_sym)*2.0); // todo
52 }
53
54 Molecule*
55 Text_spanner::do_brew_molecule_p() const
56 {
57   Molecule tsym (spec_p_->get_molecule (paper_l (),CENTER));
58   tsym.translate (text_off_);
59
60   Molecule*output = new Molecule;
61   output->add_molecule (tsym);
62   return output;
63 }
64
65 void
66 Text_spanner::do_pre_processing()
67 {
68   spanned_drul_ = support_span_l_->spanned_drul_;
69 }
70
71 Interval
72 Text_spanner::height() const
73 {
74   return do_brew_molecule_p()->extent ().y ();
75 }
76
77 void
78 Text_spanner::do_substitute_element_pointer (Score_element* o, Score_element*n)
79 {
80   if (support_span_l_ == o) 
81         support_span_l_ = (Directional_spanner*) (n?dynamic_cast <Spanner *> (n):0);
82 }
83
84
85 Text_spanner::~Text_spanner()
86 {
87   delete spec_p_;
88 }
89
90 Text_spanner::Text_spanner (Text_spanner const&s)
91   : Spanner (s)
92 {
93   support_span_l_ = s.support_span_l_;
94   spec_p_ = s.spec_p_? s.spec_p_->clone() : 0;
95   text_off_ = s.text_off_;
96 }