blob: 4effed1fee1dad133e154ffc5cb342df952d5a50 (
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
|
/*
key-reg.cc -- implement Key_register
source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
Todo: key undo, special keys.
*/
#include "key-reg.hh"
#include "key-item.hh"
#include "command-request.hh"
#include "local-key-reg.hh"
#include "musical-request.hh"
#include "local-key-item.hh"
#include "bar.hh"
#include "time-description.hh"
Key_register::Key_register()
{
do_post_move_processing();
}
bool
Key_register::do_try_request(Request * req_l)
{
Command_req* creq_l= req_l->command();
if (!creq_l|| !creq_l->keychange())
return false;
if (keyreq_l_)
return false; // TODO
keyreq_l_ = creq_l->keychange();
change_key_b_ = true;
read_req(keyreq_l_);
return true;
}
void
Key_register::acknowledge_element(Score_elem_info info)
{
int c0_i= *get_staff_info().c0_position_i_l_;
Command_req * r_l = info.req_l_->command() ;
if (r_l && r_l->clefchange()) {
if (!kit_p_) {
kit_p_ = new Key_item(c0_i);
announce_element(Score_elem_info(kit_p_,0));
}
change_key_b_ = true;
}
if (info.elem_l_->name() == Bar::static_name()) {
default_key_b_ = true;
if (!kit_p_) {
kit_p_ = new Key_item(c0_i);
announce_element(Score_elem_info(kit_p_,0));
}
}
}
void
Key_register::do_process_requests()
{
int c0_i= *get_staff_info().c0_position_i_l_;
if (key_.multi_octave_b_)
assert(false); // TODO .
else if (keyreq_l_) {
kit_p_ = new Key_item(c0_i);
kit_p_->read(*this);
announce_element(Score_elem_info(kit_p_, keyreq_l_));
}
}
void
Key_register::do_pre_move_processing()
{
if (kit_p_) {
typeset_breakable_item( kit_p_);
kit_p_ = 0;
}
}
void
Key_register::read_req(Key_change_req * r)
{
key_.multi_octave_b_ = r->multi_octave_b_;
accidental_idx_arr_.set_size(0);
for (int i = 0; i < r->melodic_p_arr_.size(); i ++) {
Melodic_req * m_l =r->melodic_p_arr_[i];
int n_i =m_l->notename_i_;
int a_i = m_l->accidental_i_;
int o_i = m_l->octave_i_;
if (r->multi_octave_b_)
key_.set(o_i, n_i, a_i);
else
key_.set(n_i, a_i);
accidental_idx_arr_.push(n_i);
}
}
void
Key_register::do_post_move_processing()
{
keyreq_l_ = 0;
default_key_b_ = false;
kit_p_ = 0;
change_key_b_ = false;
}
IMPLEMENT_STATIC_NAME(Key_register);
IMPLEMENT_IS_TYPE_B1(Key_register,Request_register);
ADD_THIS_REGISTER(Key_register);
|