]> git.donarmstrong.com Git - lilypond.git/blob - lily/scoreline.cc
release: 0.1.11
[lilypond.git] / lily / scoreline.cc
1 /*
2   scoreline.cc -- implement Line_of_score
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "scoreline.hh"
10 #include "dimen.hh"
11 #include "spanner.hh"
12 #include "symbol.hh"
13 #include "paper-def.hh"
14 #include "p-col.hh"
15 #include "p-score.hh"
16
17
18 /* To do:
19
20    take out hard coded TeX stuff.
21    */
22 String
23 Line_of_score::TeX_output_str () const
24 {
25   String s ("\\hbox{%<- line of score\n");
26   if (error_mark_b_)
27     s+= "\\scorelineerrormark";
28   
29   s+= Score_elem::TeX_output_str();
30   s += "}";
31   return s;
32 }
33
34
35 Line_of_score::Line_of_score()
36 {
37   error_mark_b_ = 0;
38 }
39
40
41 IMPLEMENT_IS_TYPE_B1(Line_of_score,Spanner);
42
43 void
44 Line_of_score::add (Score_elem*e)
45 {
46   // avoid excess dependencies.
47   if (!(e->axis_group_l_a_[0] || e->axis_group_l_a_[1]))
48     add_dependency (e);
49 }
50
51 bool
52 Line_of_score::contains_b (Paper_column const* c) const
53 {
54   return cols.find_l ((Paper_column*)c);
55 }
56
57 void
58 Line_of_score::set_breaking (Array<Col_hpositions> const &breaking)
59 {
60   for (int j=0; j < breaking.size(); j++) 
61     {
62       const Array<Paper_column*> &curline (breaking[j].cols);
63       const Array<Paper_column*> &errors (breaking[j].error_col_l_arr_);
64       const Array<Real> &config (breaking[j].config);
65         
66       for (int i=0; i < errors.size(); i++)
67         errors[i]->error_mark_b_ = true;
68
69       Line_of_score *line_l=0;
70       Line_of_score *line_p =0;
71         
72       if (breaking.size() >1) 
73         {
74           line_p = (Line_of_score*)clone()->spanner ();
75           line_l = line_p;
76         }
77       else 
78         line_l =  this;
79         
80       ((Array<Paper_column*> &)line_l->cols) = curline;
81       line_l->set_bounds(LEFT,curline[0]);
82       
83       line_l->set_bounds(RIGHT,curline.top());
84         
85       if (line_p) 
86         {
87           pscore_l_->typeset_broken_spanner (line_p);
88           broken_into_l_arr_.push (line_p);
89         }
90
91       for (int i=0; i < curline.size(); i++)
92         {
93           curline[i]->translate(config[i],X_AXIS);
94           curline[i]->line_l_ = (Line_of_score*)line_l;
95         }
96     }
97 }
98
99
100 void
101 Line_of_score::break_into_pieces (bool)
102 {
103   
104 }
105
106 Link_array<Line_of_score>
107 Line_of_score::get_lines() const
108 {
109   Link_array<Line_of_score> ret;
110
111   if (broken_into_l_arr_.size())
112     for (int i=0; i < broken_into_l_arr_.size(); i++) 
113       {
114         ret.push ((Line_of_score*)broken_into_l_arr_[i]);
115       }
116   else 
117     ret.push ((Line_of_score*)this);    // ugh
118   
119   return ret;
120 }
121
122 void
123 Line_of_score::do_print() const
124 {
125   Spanner::do_print();
126 }
127
128 Interval
129 Line_of_score::do_width() const
130
131   return Spanner::do_width();
132 }
133
134 void
135 Line_of_score::do_breakable_col_processing() 
136 {
137   for (int i=0; i < cols.size (); i++)
138     cols[i]->breakable_col_processing();
139   Spanner::do_breakable_col_processing();
140 }