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