]> git.donarmstrong.com Git - lilypond.git/blob - src/staffline.cc
release: 0.0.9
[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.hh"
7 #include "pcol.hh"
8 #include "pscore.hh"
9
10 static String
11 make_vbox(Interval i)
12 {    
13     String s("\\vbox to ");
14     s += print_dimen(i.length());
15     s += "{\\vskip "+print_dimen(i.max)+" ";
16     return s;
17 }
18
19     
20 String
21 Line_of_staff::TeXstring() const
22 {
23     String s("%line_of_staff\n");
24     s+=make_vbox(height());
25     // the staff itself: eg lines, accolades
26     s += "\\hbox{";
27     {
28         Symbol sym = pstaff_->get_stafsym(scor->score->paper_->linewidth);
29         s+=sym.tex;
30         PCursor<const PCol *> cc(scor->cols);
31         Real lastpos=cc->hpos;
32
33         // all items in the current line & staff.
34         for (; cc.ok(); cc++) {
35             Real delta=cc->hpos - lastpos;
36             lastpos = cc->hpos;
37
38             // moveover
39             if (delta)
40                 s +=String( "\\kern ") + print_dimen(delta);
41
42             // now output the items.
43
44             for (PCursor<const Item *> ic(cc->its); ic.ok(); ic++) {
45                 if (ic->pstaff_ == pstaff_)
46                     s += ic->TeXstring();
47             }
48             // spanners.
49             for (PCursor<const Spanner *> sc(cc->starters); sc.ok(); sc++)
50                 if (sc->pstaff_ == pstaff_)
51                     s += sc->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     scor=sc;
61     pstaff_=st;
62 #if 0
63     const PCol *linestart = sc->cols.top();
64     const PCol *linestop = sc->cols.bottom();
65
66     for (PCursor<const Spanner*> sp(pstaff_->spans); sp.ok(); sp++) {
67         const PCol *brokenstart = &MAX(*linestart, *sp->left);
68         const PCol *brokenstop = &MIN(*linestop, *sp->right);
69 //      if (*brokenstop  < *brokenstart)
70         brokenspans.bottom().add(sp->broken_at(0,0));
71     }
72 #endif
73     for (PCursor<const Spanner*> sp(pstaff_->spans); sp.ok(); sp++) {
74
75         brokenspans.bottom().add(sp->broken_at(0,0));
76     }
77 }
78
79
80 Interval
81 Line_of_staff::height() const
82 {
83     Interval y;
84     {
85         Symbol s = pstaff_->stafsym->eval(scor->score->paper_->linewidth);
86         y = s.dim.y;
87     }
88     PCursor<const PCol *> cc(scor->cols);
89     
90     // all items in the current line & staff.
91     for (; cc.ok(); cc++) {
92         for (PCursor<const Item *> ic(cc->its); ic.ok(); ic++) {
93             if (ic->pstaff_ == pstaff_) {
94                 y.unite(ic->height());
95         }
96             
97         // spanners.
98         for (PCursor<const Spanner *> sc(cc->starters); sc.ok(); sc++)
99             if (sc->pstaff_ == pstaff_) {
100                 y.unite(sc->height());
101             }
102         }
103     }
104     return y;
105 }
106
107