]> git.donarmstrong.com Git - lilypond.git/blob - lily/staffline.cc
release: 0.0.46.jcn1
[lilypond.git] / lily / staffline.cc
1 #include "staffline.hh"
2 #include "scoreline.hh"
3 #include "dimen.hh"
4 #include "spanner.hh"
5 #include "symbol.hh"
6 #include "paper-def.hh"
7 #include "molecule.hh"
8 #include "p-col.hh"
9 #include "p-score.hh"
10
11 static String
12 make_vbox(Interval i)
13 {
14     if (i.empty_b()) 
15         i = Interval(0,0);
16     Real r = i.length();
17     String s("\\vbox to ");
18     s += print_dimen(r);
19     s += "{\\vskip "+print_dimen(i.right)+" ";
20     return s;
21 }
22
23     
24 String
25 Line_of_staff::TeXstring() const
26 {
27     String s("%line_of_staff\n");
28     
29     s+=make_vbox(height());
30     // the staff itself: eg lines, accolades
31     s += "\\hbox{";
32     {                           
33         iter_top(line_of_score_l_->cols,cc);
34         Real lastpos=cc->hpos;
35
36         // all items in the current line & staff.
37         for (; cc.ok(); cc++) {
38             Real delta=cc->hpos - lastpos;
39             lastpos = cc->hpos;
40
41             // moveover
42             if (delta)
43                 s +=String( "\\kern ") + print_dimen(delta);
44
45             // now output the items.
46             for (iter_top(cc->its,i); i.ok(); i++) {
47                 if (i->pstaff_l_ == pstaff_l_)
48                     s += i->TeXstring();
49             }
50             // spanners.
51             for (iter_top(cc->starters,i); i.ok(); i++)
52                 if (i->pstaff_l_ == pstaff_l_)
53                     s += i->TeXstring();
54         }
55     }
56     s+="\\hss}\\vss}";
57     return s;
58 }
59
60 Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
61 {
62     line_of_score_l_=sc;
63     pstaff_l_=st;
64
65     PCol *linestart = sc->cols.top();
66     PCol *linestop = sc->cols.bottom();
67     
68     for (iter_top(pstaff_l_->spans,i); i.ok(); i++) {
69         PCol *brokenstart = &max(*linestart, *i->left_col_l_);
70         PCol *brokenstop = &min(*linestop, *i->right_col_l_);
71         if ( *brokenstart < *brokenstop) {
72             Spanner*span_p =i->broken_at(brokenstart,brokenstop);
73             line_of_score_l_->pscore_l_-> // higghl
74                 add_broken(span_p);
75         }
76     }
77 }
78
79
80 Interval
81 Line_of_staff::height() const
82 {
83     Interval y(0,0);
84
85     iter_top(line_of_score_l_->cols,cc);
86     
87     // all items in the current line & staff.
88     for (; cc.ok(); cc++) {
89         for (iter_top(cc->its,i); i.ok(); i++) {
90             if (i->pstaff_l_ == pstaff_l_) 
91                 y.unite(i->height());
92             
93         }
94         // spanners.
95         for (iter_top(cc->starters,i); i.ok(); i++)
96             if (i->pstaff_l_ == pstaff_l_) {
97                 y.unite(i->height());
98             }
99     }
100     
101     return y;
102 }
103
104 void
105 Line_of_staff::process()
106 {
107 #if 0
108     if (!pstaff_l_->stafsym_p_)
109         pstaff_l_->brew_molecule_p(line_of_score_l_->pscore_l_->
110                                  paper_l_->linewidth);
111 #endif
112 }