]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-spanner.cc
release: 1.1.0
[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--1998 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 #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
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
42 IMPLEMENT_IS_TYPE_B1(Text_spanner,Spanner);
43
44 void
45 Text_spanner::do_print() const
46 {
47   spec_p_->print();
48 }
49
50 void
51 Text_spanner::do_post_processing()
52 {
53   text_off_ = support_span_l_->center() +
54         Offset (0,support_span_l_->dir_ * paper()->internote_f () * 4); // todo
55 }
56
57 Molecule*
58 Text_spanner::brew_molecule_p() const
59 {
60   Atom tsym (spec_p_->get_atom (paper(),CENTER));
61   tsym.translate (text_off_);
62
63   Molecule*output = new Molecule;
64   output->add_atom (tsym);
65   return output;
66 }
67
68 void
69 Text_spanner::do_pre_processing()
70 {
71   spanned_drul_ = support_span_l_->spanned_drul_;
72 }
73
74 Interval
75 Text_spanner::height() const
76 {
77   return brew_molecule_p()->extent ().y ();
78 }
79
80 void
81 Text_spanner::do_substitute_dependency (Score_element* o, Score_element*n)
82 {
83   if (support_span_l_ == o) 
84         support_span_l_ = (Directional_spanner*) (n?dynamic_cast <Spanner *> (n):0);
85 }
86
87
88 Text_spanner::~Text_spanner()
89 {
90   delete spec_p_;
91 }
92
93 Text_spanner::Text_spanner (Text_spanner const&s)
94   : Spanner (s)
95 {
96   support_span_l_ = s.support_span_l_;
97   spec_p_ = s.spec_p_? s.spec_p_->clone() : 0;
98   text_off_ = s.text_off_;
99 }