]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-spanner.cc
release: 0.0.67
[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 "symbol.hh"
16
17
18 void
19 Text_spanner::set_support(Directional_spanner*d)
20 {
21     if (support)
22         remove_dependency(support);
23     
24     support =d;
25     add_dependency(d);
26 }
27
28 Text_spanner::Text_spanner()
29 {
30     spec_p_ = 0;
31     support = 0;
32 }
33
34 IMPLEMENT_STATIC_NAME(Text_spanner);
35
36 void
37 Text_spanner::do_print() const
38 {
39     spec_p_->print();
40 }
41
42 void
43 Text_spanner::do_post_processing()
44 {
45     text_off_ = support->center() +
46         Offset(0,support->dir_i_ * paper()->internote_f() * 4); // todo
47 }
48
49 Molecule*
50 Text_spanner::brew_molecule_p() const
51 {
52     Atom tsym (spec_p_->get_atom(paper(),0));
53     tsym.translate(text_off_);
54
55     Molecule*output = new Molecule;
56     output->add( tsym );
57     return output;
58 }
59
60 void
61 Text_spanner::do_pre_processing()
62 {
63     right_col_l_ = support->right_col_l_;
64     left_col_l_ = support->left_col_l_;
65     assert(left_col_l_ && right_col_l_);
66 }
67
68 Interval
69 Text_spanner::height()const
70 {
71     return brew_molecule_p()->extent().y;
72 }
73
74 void
75 Text_spanner::do_substitute_dependency(Score_elem* o, Score_elem*n)
76 {
77     Directional_spanner * old = (Directional_spanner*)o->spanner();
78     if (support == old)
79         support = (Directional_spanner*) n->spanner();
80 }
81
82
83 Text_spanner::~Text_spanner()
84 {
85     delete spec_p_;
86 }