]> git.donarmstrong.com Git - lilypond.git/blob - lily/a2-engraver.cc
patch::: 1.3.77.jcn4
[lilypond.git] / lily / a2-engraver.cc
1 /*
2   a2-engraver.cc -- implement A2_engraver
3
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "engraver.hh"
10 #include "item.hh"
11 #include "note-head.hh"
12 #include "stem.hh"
13 #include "translator-group.hh"
14 #include "side-position-interface.hh"
15 #include "directional-element-interface.hh"
16
17 class A2_engraver : public Engraver
18 {
19 public:
20   A2_engraver ();
21   VIRTUAL_COPY_CONS (Translator);
22   
23 protected:
24   virtual void do_process_music ();
25   virtual void acknowledge_element (Score_element_info);
26   //virtual void process_acknowledged ();
27
28   virtual void do_pre_move_processing ();
29
30 private:
31   Item* text_p_;
32 };
33
34 ADD_THIS_TRANSLATOR (A2_engraver);
35
36 A2_engraver::A2_engraver ()
37 {
38   text_p_ = 0;
39 }
40
41 void
42 A2_engraver::do_process_music ()
43 {
44   if (!text_p_)
45     {
46       SCM a2 = get_property ("a2");
47       SCM solo = get_property ("solo");
48       SCM solo2 = get_property ("solo2");
49
50       if (solo == SCM_BOOL_T || a2 == SCM_BOOL_T || solo2 == SCM_BOOL_T)
51         {
52           text_p_ = new Item (get_property ("basicTextScriptProperties"));
53           Side_position::set_axis (text_p_, Y_AXIS);
54           announce_element (text_p_, 0);
55       
56           /*
57             Urg, read prop
58           */
59           SCM text;
60           Direction dir = UP;
61           if (solo == SCM_BOOL_T)
62             {
63               text = ly_str02scm ("Solo");
64             }
65           else if (solo2 == SCM_BOOL_T)
66             {
67               text = ly_str02scm ("Solo II");
68               dir = DOWN;
69             }
70           else if (a2 == SCM_BOOL_T)
71             {
72               text = ly_str02scm ("\\`a 2");
73             }
74
75           Side_position::set_direction (text_p_, dir);
76           text_p_->set_elt_property ("text", text);
77
78         }
79     }
80 }
81
82 void
83 A2_engraver::acknowledge_element (Score_element_info i)
84 {
85   if (text_p_)
86     {
87       if (Note_head::has_interface (i.elem_l_))
88         {
89           Score_element*t = text_p_;
90           Side_position::add_support (t, i.elem_l_);
91           if (Side_position::get_axis (t) == X_AXIS
92               && !t->parent_l (Y_AXIS))
93             t->set_parent (i.elem_l_, Y_AXIS);
94         }
95       if (Stem::has_interface (i.elem_l_))
96         {
97           Side_position::add_support (text_p_, i.elem_l_);
98           
99           SCM a2 = get_property ("a2");
100           SCM solo = get_property ("solo");
101           SCM solo2 = get_property ("solo2");
102
103           SCM first = get_property ("first");
104           SCM second = get_property ("second");
105
106           if (solo != SCM_BOOL_T
107               && solo2 != SCM_BOOL_T
108               && a2 != SCM_BOOL_T)
109             {
110               if (first == SCM_BOOL_T)
111                 {
112                   Directional_element_interface (i.elem_l_).set (UP);
113                 }
114               else if (second == SCM_BOOL_T)
115                 {
116                   Directional_element_interface (i.elem_l_).set (DOWN);
117                 }
118             }
119         }
120     }
121 }
122
123 void 
124 A2_engraver::do_pre_move_processing ()
125 {
126   if (text_p_)
127     {
128       Side_position::add_staff_support (text_p_);
129       typeset_element (text_p_);
130       text_p_ = 0;
131     }
132   // burp: reset properties
133   daddy_trans_l_->set_property ("a2", SCM_BOOL_F);
134   daddy_trans_l_->set_property ("solo", SCM_BOOL_F);
135   daddy_trans_l_->set_property ("solo2", SCM_BOOL_F);
136 }
137