*** empty log message ***
[lilypond.git] / lily / mark-engraver.cc
blob0d875ba8c11a30ecc8a048770ae239e635ee62a6
1 /*
2 mark-engraver.cc -- implement Mark_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2003 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include <ctype.h>
10 #include "bar-line.hh"
12 #include "staff-symbol.hh"
13 #include "engraver-group-engraver.hh"
14 #include "engraver.hh"
15 #include "lily-guile.hh"
16 #include "paper-column.hh"
17 #include "paper-def.hh"
18 #include "side-position-interface.hh"
19 #include "staff-symbol-referencer.hh"
20 #include "item.hh"
21 #include "group-interface.hh"
22 #include "text-item.hh"
24 /**
25 put stuff over or next to bars. Examples: bar numbers, marginal notes,
26 rehearsal marks.
28 class Mark_engraver : public Engraver
30 public:
31 TRANSLATOR_DECLARATIONS(Mark_engraver);
32 protected:
33 Item* text_;
35 protected:
36 virtual void stop_translation_timestep ();
37 virtual void acknowledge_grob (Grob_info);
38 void create_items (Music*);
39 virtual bool try_music (Music *req);
40 virtual void start_translation_timestep ();
41 virtual void process_music ();
43 private:
44 Music * mark_req_;
51 Mark_engraver::Mark_engraver ()
53 text_ =0;
54 mark_req_ = 0;
57 void
58 Mark_engraver::acknowledge_grob (Grob_info inf)
60 Grob * s = inf.grob_;
61 if (text_ && Bar_line::has_interface (s))
64 Ugh. Figure out how to do this right at beginning of line, (without
65 creating class Bar_script : public Item).
67 text_->set_parent (s, X_AXIS);
71 void
72 Mark_engraver::stop_translation_timestep ()
74 if (text_)
76 text_->set_grob_property ("side-support-elements" , get_property ("stavesFound"));
77 typeset_grob (text_);
78 text_ =0;
83 void
84 Mark_engraver::create_items (Music *rq)
86 if (text_)
87 return;
89 SCM s = get_property ("RehearsalMark");
90 text_ = new Item (s);
93 announce_grob(text_, rq->self_scm());
97 void
98 Mark_engraver::start_translation_timestep ()
100 mark_req_ = 0;
104 bool
105 Mark_engraver::try_music (Music* r)
107 mark_req_ = r;
108 return true;
114 TODO: make the increment function in Scheme.
117 void
118 Mark_engraver::process_music ()
120 if (mark_req_)
122 create_items (mark_req_);
124 String t;
127 automatic marks.
130 SCM m = mark_req_->get_mus_property ("label");
131 if (Text_item::markup_p (m))
133 text_->set_grob_property ("text",m);
135 else
137 if (!gh_string_p (m) && !gh_number_p (m))
138 m = get_property ("rehearsalMark");
140 if (gh_number_p (m))
142 int mark_count = gh_scm2int (m);
143 t = to_string (mark_count);
144 mark_count ++;
145 m = gh_int2scm (mark_count);
147 else if (gh_string_p (m))
149 t = ly_scm2string (m);
150 String next;
151 if (t.length ())
153 char c = t[0];
154 c++;
155 next = to_string (c);
157 m = scm_makfrom0str (next.to_str0 ());
159 else
161 m = gh_int2scm (1);
164 daddy_trans_->set_property ("rehearsalMark", m);
166 text_->set_grob_property ("text",
167 scm_makfrom0str (t.to_str0 ()));
169 SCM series = SCM_EOL;
170 SCM family = ly_symbol2scm ("number");
171 for (int i=0; i < t.length (); i++)
173 if (!isdigit (t[i]))
175 series = ly_symbol2scm ("bold");
176 family = ly_symbol2scm ("roman");
177 break;
180 if (gh_symbol_p (series))
181 text_->set_grob_property ("font-series", series);
182 if (gh_symbol_p (family))
183 text_->set_grob_property ("font-family", family);
188 ENTER_DESCRIPTION(Mark_engraver,
189 /* descr */ "",
190 /* creats*/ "RehearsalMark",
191 /* accepts */ "mark-event",
192 /* acks */ "bar-line-interface",
193 /* reads */ "rehearsalMark stavesFound",
194 /* write */ "");