summaryrefslogtreecommitdiff
path: root/lily/script-reg.cc
blob: cd7b0814297cfa106d81ea349397697fec6d75e8 (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
/*
  script-reg.cc -- implement Script_register

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

#include "script-reg.hh"
#include "script.hh"
#include "musical-request.hh"
#include "complex-walker.hh"
#include "stem.hh"

Script_register::Script_register()
{
    script_p_ = 0;
    post_move_processing();
}

bool
Script_register::try_request(Request *r_l)
{
    if (!r_l->script())
	return false ;

    if (script_req_l_
	&& Script_req::compare(*script_req_l_, *r_l->script()))
	
	return false;

    script_req_l_ = r_l->script();
    
    return true;
}

void
Script_register::process_requests()
{
    if (script_req_l_) {
	script_p_ = new Script(script_req_l_, 10);
	announce_element(
	    Staff_elem_info(script_p_, script_req_l_));
    }
}

void
Script_register::acknowledge_element(Staff_elem_info info)
{
    if (!script_p_)
	return;
    if (info.elem_p_->name() == Stem::static_name())
	script_p_->set_stem((Stem*)info.elem_p_);
    else if (info.req_l_->rhythmic())
	script_p_->set_support(info.elem_p_->item());
}

void
Script_register::pre_move_processing()
{
    if (script_p_){
	script_p_->dir = dir_i_;
	typeset_element(script_p_);
	script_p_ = 0;
    }
}
void
Script_register::post_move_processing()
{
    script_req_l_ = 0;
}

void
Script_register::set_feature(Features i)
{
    if (i.direction_i_|| i.initialiser_b_)
	dir_i_ = i.direction_i_;
}
IMPLEMENT_STATIC_NAME(Script_register);
ADD_THIS_REGISTER(Script_register);