lilypond-0.0.32
[lilypond.git] / src / staffline.cc
blob7b79f09212adfd93a9e18166c8977288a17b9b16
1 #include "staffline.hh"
2 #include "scoreline.hh"
3 #include "dimen.hh"
4 #include "spanner.hh"
5 #include "symbol.hh"
6 #include "paperdef.hh"
7 #include "molecule.hh"
8 #include "pcol.hh"
9 #include "pscore.hh"
11 static String
12 make_vbox(Interval i)
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;
22 String
23 Line_of_staff::TeXstring() const
25 String s("%line_of_staff\n");
27 s+=make_vbox(height());
28 // the staff itself: eg lines, accolades
29 s += "\\hbox{";
31 iter_top(line_of_score_l_->cols,cc);
32 Real lastpos=cc->hpos;
34 // all items in the current line & staff.
35 for (; cc.ok(); cc++) {
36 Real delta=cc->hpos - lastpos;
37 lastpos = cc->hpos;
39 // moveover
40 if (delta)
41 s +=String( "\\kern ") + print_dimen(delta);
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();
48 // spanners.
49 for (iter_top(cc->starters,i); i.ok(); i++)
50 if (i->pstaff_l_ == pstaff_l_)
51 s += i->TeXstring();
54 s+="\\hss}\\vss}";
55 return s;
58 Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
60 line_of_score_l_=sc;
61 pstaff_l_=st;
63 PCol *linestart = sc->cols.top();
64 PCol *linestop = sc->cols.bottom();
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);
78 Interval
79 Line_of_staff::height() const
81 Interval y(0,0);
83 iter_top(line_of_score_l_->cols,cc);
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());
92 // spanners.
93 for (iter_top(cc->starters,i); i.ok(); i++)
94 if (i->pstaff_l_ == pstaff_l_) {
95 y.unite(i->height());
99 return y;
102 void
103 Line_of_staff::process()
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