]> git.donarmstrong.com Git - lilypond.git/blob - lily/staffline.cc
release: 0.0.62
[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             if (cc->error_mark_b_) {
45                 s += String("\\columnerrormark");
46             }
47             // now output the items.
48             for (iter_top(cc->its,i); i.ok(); i++) {
49                 if (i->pstaff_l_ == pstaff_l_)
50                     s += i->TeXstring();
51             }
52             // spanners.
53             for (iter_top(cc->starters,i); i.ok(); i++)
54                 if (i->pstaff_l_ == pstaff_l_)
55                     s += i->TeXstring();
56         }
57     }
58     s+="\\hss}\\vss}";
59     return s;
60 }
61
62 Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
63 {
64     line_of_score_l_=sc;
65     pstaff_l_=st;
66
67     PCol *linestart = sc->cols.top();
68     PCol *linestop = sc->cols.bottom();
69     
70     for (iter_top(pstaff_l_->spans,i); i.ok(); i++) {
71         PCol *brokenstart = &max(*linestart, *i->left_col_l_);
72         PCol *brokenstop = &min(*linestop, *i->right_col_l_);
73         if ( *brokenstart < *brokenstop) {
74             Spanner*span_p =i->broken_at(brokenstart,brokenstop);
75             line_of_score_l_->pscore_l_-> // higghl
76                 add_broken(span_p);
77         }
78     }
79 }
80
81
82 Interval
83 Line_of_staff::height() const
84 {
85     Interval y(0,0);
86
87     iter_top(line_of_score_l_->cols,cc);
88     
89     // all items in the current line & staff.
90     for (; cc.ok(); cc++) {
91         for (iter_top(cc->its,i); i.ok(); i++) {
92             if (i->pstaff_l_ == pstaff_l_) 
93                 y.unite(i->height());
94             
95         }
96         // spanners.
97         for (iter_top(cc->starters,i); i.ok(); i++)
98             if (i->pstaff_l_ == pstaff_l_) {
99                 y.unite(i->height());
100             }
101     }
102     
103     return y;
104 }
105
106 void
107 Line_of_staff::process()
108 {
109 #if 0
110     if (!pstaff_l_->stafsym_p_)
111         pstaff_l_->brew_molecule_p(line_of_score_l_->pscore_l_->
112                                  paper_l_->linewidth);
113 #endif
114 }