]> git.donarmstrong.com Git - lilypond.git/blob - lily/mark-engraver.cc
release: 1.1.0
[lilypond.git] / lily / mark-engraver.cc
1 /*
2   mark-engraver.cc -- implement Mark_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "mark-engraver.hh"
10 #include "text-def.hh"
11 #include "script.hh"
12 #include "paper-def.hh"
13 #include "command-request.hh"
14 #include "time-description.hh"
15 #include "engraver-group.hh"
16
17 IMPLEMENT_IS_TYPE_B1 (Mark_engraver, Engraver);
18 ADD_THIS_TRANSLATOR (Mark_engraver);
19
20 Mark_engraver::Mark_engraver ()
21 {
22   mark_req_l_ = 0;
23   script_p_ = 0;
24 }
25
26 bool
27 Mark_engraver::do_try_request (Request* r_l)
28 {
29   Command_req* c_l = dynamic_cast <Command_req *> (r_l);
30   if (!c_l || !dynamic_cast <Mark_req *> (c_l) || mark_req_l_) 
31     return false;
32
33   mark_req_l_ = dynamic_cast <Mark_req *> (c_l);
34
35   return true;
36 }
37
38 void
39 Mark_engraver::do_process_requests ()
40 {  
41   if (!mark_req_l_ || script_p_)
42     return;
43
44   script_p_ = new Script;
45   script_p_->breakable_b_ = true;
46
47   Text_def *td_p = new Text_def;
48
49   td_p->text_str_ = mark_req_l_->str_;
50   td_p->align_dir_ = CENTER;
51
52   td_p->style_str_ = td_p->text_str_.index_any_i ("0123456789") >= 0 
53     ? "mark" : "Large";
54
55   script_p_->dir_ = LEFT;
56   script_p_->specs_p_ = td_p->clone ();
57   script_p_->postbreak_only_b_ = true;
58   
59   Scalar padding = get_property ("markScriptPadding");
60   if (padding.length_i() && padding.isnum_b ())
61     {
62       script_p_->padding_f_ = Real(padding);
63     }
64   Scalar break_priority = get_property ("markBreakPriority");
65   if (break_priority.length_i() && break_priority.isnum_b ())
66     {
67       script_p_->break_priority_i_ = int(break_priority);
68     }
69
70   
71   announce_element (Score_element_info (script_p_, mark_req_l_));
72 }
73
74 void 
75 Mark_engraver::do_pre_move_processing ()
76 {
77   if (script_p_) 
78     {
79       typeset_element (script_p_);
80       script_p_ = 0;
81       mark_req_l_ = 0;
82     }
83 }
84