blob: ba48473450e0da8ea869d48cb70cac022a7e183d (
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
|
/*
text-engraver.cc -- implement Text_engraver
source file of the GNU LilyPond music typesetter
(c) 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "engraver.hh"
#include "g-staff-side.hh"
#include "g-text-item.hh"
#include "text-def.hh"
#include "note-head.hh"
#include "stem.hh"
#include "staff-sym.hh"
class Text_engraver : public Engraver
{
Link_array<Script_req> reqs_;
Link_array<G_staff_side_item> positionings_;
Link_array<G_text_item> texts_;
public:
Text_engraver();
VIRTUAL_COPY_CONS(Translator);
protected:
virtual bool do_try_music (Music* m);
virtual void do_pre_move_processing ();
virtual void do_post_move_processing ();
virtual void do_process_requests ();
virtual void acknowledge_element (Score_element_info);
};
Text_engraver::Text_engraver ()
{
}
bool
Text_engraver::do_try_music (Music *m)
{
if (Script_req *r = dynamic_cast<Script_req*> (m))
{
Text_def * t = dynamic_cast<Text_def*> (r->scriptdef_p_);
if (!t)
return false;
reqs_.push (r);
return true;
}
return false;
}
void
Text_engraver::acknowledge_element (Score_element_info i)
{
if (Note_head *n = dynamic_cast<Note_head*> (i.elem_l_))
{
for (int i=0; i < positionings_.size (); i++)
{
positionings_[i]->add_support (n);
}
}
if (Stem *n = dynamic_cast<Stem*> (i.elem_l_))
{
for (int i=0; i < positionings_.size (); i++)
{
positionings_[i]->add_support (n);
}
}
}
void
Text_engraver::do_process_requests ()
{
for (int i=0; i < reqs_.size (); i++)
{
Script_req * r = reqs_[i];
Text_def * t= dynamic_cast<Text_def*> (r->scriptdef_p_);
G_text_item *text = new G_text_item;
G_staff_side_item *ss = new G_staff_side_item;
ss->set_victim (text);
ss->dir_ = r->dir_;
text->text_str_ = t->text_str_;
announce_element (Score_element_info (text, r));
announce_element (Score_element_info (ss, r));
texts_.push (text);
positionings_.push (ss);
}
}
void
Text_engraver::do_pre_move_processing ()
{
Staff_symbol* s_l = get_staff_info().staff_sym_l_;
for (int i=0; i < texts_.size (); i++)
{
if (s_l != 0)
{
positionings_[i]->add_support (s_l);
}
typeset_element (texts_[i]);
typeset_element (positionings_[i]);
}
texts_.clear ();
positionings_.clear ();
}
void
Text_engraver::do_post_move_processing ()
{
reqs_.clear ();
}
ADD_THIS_TRANSLATOR(Text_engraver);
|