blob: fc1aef825b00ad80e76e6d03eed287d6822a6a78 (
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
|
/*
clef.cc -- implement Clef_register
source file of the LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>,
Mats Bengtsson <matsb@s3.kth.se>
*/
#include "bar.hh"
#include "clef-reg.hh"
#include "clef-item.hh"
#include "debug.hh"
#include "command-request.hh"
#include "time-description.hh"
#include "staff-column.hh"
Clef_register::Clef_register()
{
clef_p_ = 0;
/* ugly hack to prevent segfault (daddy_reg_l_ == 0 at construction) */
clef_type_str_ = "";
}
bool
Clef_register::set_type(String s)
{
clef_type_str_ = s;
if (clef_type_str_ == "violin") {
c0_position_i_= -2;
} else if (clef_type_str_ == "alto") {
c0_position_i_= 4;
} else if (clef_type_str_ == "tenor") {
c0_position_i_= 6;
} else if (clef_type_str_ == "bass") {
c0_position_i_= 10;
}else
return false;
*get_staff_info().c0_position_i_l_ = c0_position_i_;
return true;
}
void
Clef_register::read_req(Clef_change_req*c_l)
{
if (!set_type(c_l->clef_str_))
c_l->error("unknown clef type ");
}
void
Clef_register::acknowledge_element(Staff_elem_info info)
{
if (info.elem_p_->name() == Bar::static_name()) {
if (!clef_p_){
create_clef();
clef_p_->change = false;
}
}
}
bool
Clef_register::try_request(Request * r_l)
{
Command_req* creq_l= r_l->command();
if (!creq_l || !creq_l->clefchange())
return false;
clef_req_l_ = creq_l->clefchange();
// do it now! Others have to read c0_pos.
read_req(creq_l->clefchange());
return true;
}
void
Clef_register::create_clef()
{
clef_p_ = new Clef_item;
clef_p_->read(*this);
announce_element(Staff_elem_info(clef_p_,
clef_req_l_));
}
void
Clef_register::process_requests()
{
if (clef_req_l_) {
create_clef();
clef_p_->change = true;
}
}
void
Clef_register::pre_move_processing()
{
if (!clef_p_)
return;
if (clef_p_->change) {
Clef_item* post_p = new Clef_item(*clef_p_);
post_p->change = false;
typeset_breakable_item(new Clef_item(*clef_p_),
clef_p_, post_p);
} else {
typeset_breakable_item(0, 0, clef_p_);
}
clef_p_ = 0;
}
void
Clef_register::post_move_processing()
{
clef_req_l_ = 0;
/* not in ctor, since the reg might not be linked in.*/
if (clef_type_str_ == "") {
set_type("violin");
}
}
IMPLEMENT_STATIC_NAME(Clef_register);
ADD_THIS_REGISTER(Clef_register);
|