summaryrefslogtreecommitdiff
path: root/lily/staff.cc
blob: 76e6d995cab21a8a75c907c739bcadd1b3b400b1 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
  staff.cc -- implement Staff

  source file of the GNU LilyPond music typesetter

  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/

#include "proto.hh"
#include "plist.hh"
#include "input-register.hh"
#include "staff.hh"
#include "score.hh"
#include "voice.hh"
#include "staff-column.hh"
#include "score-column.hh"
#include "voice-element.hh"
#include "debug.hh"
#include "musical-request.hh"
#include "command-request.hh" // todo
#include "staffline.hh"
#include "complex-walker.hh"
#include "super-elem.hh"
#include "p-score.hh"
#include "scoreline.hh"

void
Staff::add(Link_list<Voice*> const &l)
{
    for (iter_top(l,i); i.ok(); i++)
	voice_list_.bottom().add(i);
}

Paper_def *
Staff::paper() const
{
    return score_l_->paper_p_;
}

void
Staff::clean_cols()
{
#if 0 // TODO
    iter_top(cols_,i);
    for(; i.ok(); ){
	if (!i->musical_column_l_->used_b())
	    i->musical_column_l_ = 0;
	if (!i->command_column_l_->used_b())
	    i->command_column_l_ =0;
	
	if (!i->command_column_l_&& !i->musical_column_l_)
	    delete i.remove_p();
	else
	    i++;
    }
#endif
}


void
Staff::OK() const
{
#ifndef NDEBUG
    cols_.OK();
    voice_list_.OK();
    assert(score_l_);
#endif    
}


Moment
Staff::last() const
{
    Moment l = 0;
    for (iter_top(voice_list_,i); i.ok(); i++) {
	l = l >? i->last();
    }
    return l;
}

void
Staff::print() const
{
#ifndef NPRINT
    mtor << "Staff {\n";
    for (iter_top(voice_list_,i); i.ok(); i++) {
	i->print();	
    }
    ireg_p_->print();
    mtor <<"}\n";
#endif
}

Staff::~Staff()
{
    delete ireg_p_;
}

Staff::Staff()
{    
    ireg_p_ =0;
    score_l_ =0;
    pscore_l_ =0;
}

void
Staff::add_col(Staff_column*c_l)
{
    cols_.bottom().add(c_l);
    c_l->staff_l_ = this;
}

void
Staff::set_output(PScore* pscore_l )
{
    pscore_l_ = pscore_l;
    staff_line_l_ = new Line_of_staff;
    pscore_l_->typeset_unbroken_spanner(staff_line_l_);
    pscore_l_->super_elem_l_->line_of_score_l_->add_line(staff_line_l_);
}


Staff_walker * 
Staff::get_walker_p()
{
    return new Complex_walker(this);
}