]> git.donarmstrong.com Git - lilypond.git/blob - lily/a2-engraver.cc
patch::: 1.3.78.jcn1
[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
27   virtual void do_pre_move_processing ();
28
29 private:
30   Item* text_p_;
31   enum State { NORMAL, UNISON, SOLO } state_;
32 };
33
34 ADD_THIS_TRANSLATOR (A2_engraver);
35
36 A2_engraver::A2_engraver ()
37 {
38   text_p_ = 0;
39   state_ = NORMAL;
40 }
41
42 void
43 A2_engraver::do_process_music ()
44 {
45 }
46
47
48 void
49 A2_engraver::acknowledge_element (Score_element_info i)
50 {
51   if (!text_p_)
52     {
53       SCM unison = get_property ("unison");
54       SCM solo = get_property ("solo");
55
56       if ((solo == SCM_BOOL_T && state_ != SOLO)
57           || (unison == SCM_BOOL_T && state_ != UNISON))
58         {
59           text_p_ = new Item (get_property ("basicTextScriptProperties"));
60           Side_position::set_axis (text_p_, Y_AXIS);
61           announce_element (text_p_, 0);
62       
63           /*
64             Urg, read prop
65           */
66           SCM text;
67           Direction dir = UP;
68           if (solo == SCM_BOOL_T)
69             {
70               state_ = SOLO;
71               if (daddy_trans_l_->id_str_ == "one")
72                 text = ly_str02scm ("Solo");
73               else
74                 {
75                   text = ly_str02scm ("Solo II");
76                   dir = DOWN;
77                 }
78             }
79           else if (unison == SCM_BOOL_T)
80             {
81               text = ly_str02scm ("\\`a 2");
82               state_ = UNISON;
83             }
84           
85           Side_position::set_direction (text_p_, dir);
86           text_p_->set_elt_property ("text", text);
87
88         }
89     }
90 #if 0
91 }
92
93 void
94 A2_engraver::acknowledge_element (Score_element_info i)
95 {
96 #endif
97   if (text_p_)
98     {
99       if (Note_head::has_interface (i.elem_l_))
100         {
101           Score_element*t = text_p_;
102           Side_position::add_support (t, i.elem_l_);
103           if (Side_position::get_axis (t) == X_AXIS
104               && !t->parent_l (Y_AXIS))
105             t->set_parent (i.elem_l_, Y_AXIS);
106         }
107       if (Stem::has_interface (i.elem_l_))
108         {
109           Side_position::add_support (text_p_, i.elem_l_);
110         }
111     }
112           
113           
114   if (Stem::has_interface (i.elem_l_))
115     {
116       SCM unirhythm = get_property ("unirhythm");
117       SCM unison = get_property ("unison");
118       SCM solo = get_property ("solo");
119       SCM interval = get_property ("interval");
120
121       /*
122         This still needs some work.
123        */
124       if ((unirhythm != SCM_BOOL_T && solo != SCM_BOOL_T))
125 #if 0
126         /*
127           Apart from the uglyness of this, we can't do this yet
128           because to get up/down stems for small intervals, we
129           need Part_combine_music_iterator to uncombine the
130           voices (while still setting unison).
131          */
132           || (unirhythm == SCM_BOOL_T
133               && gh_number_p (interval) && gh_scm2int (interval) < 3))
134 #endif
135         {
136           if (daddy_trans_l_->id_str_ == "one")
137             {
138               Directional_element_interface (i.elem_l_).set (UP);
139             }
140           else if (daddy_trans_l_->id_str_ == "two")
141             {
142               Directional_element_interface (i.elem_l_).set (DOWN);
143             }
144         }
145     }
146 }
147
148 void 
149 A2_engraver::do_pre_move_processing ()
150 {
151   if (text_p_)
152     {
153       Side_position::add_staff_support (text_p_);
154       typeset_element (text_p_);
155       text_p_ = 0;
156     }
157 }
158