]> git.donarmstrong.com Git - lilypond.git/blob - lily/mark-engraver.cc
patch::: 1.1.18.mb1: Re: LilyPond 1.1.18
[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 #include "staff-sym.hh"
17 #include "g-text-item.hh"
18 #include "g-staff-side.hh"
19 #include "stem.hh"
20 #include "rhythmic-head.hh"
21
22 ADD_THIS_TRANSLATOR (Mark_engraver);
23
24 Mark_engraver::Mark_engraver ()
25 {
26   mark_req_l_ = 0;
27   staff_side_p_ = 0;
28   text_p_ = 0;
29 }
30
31 bool
32 Mark_engraver::do_try_music (Music* r_l)
33 {
34   if (Mark_req *mr = dynamic_cast <Mark_req *> (r_l))
35     {
36       mark_req_l_ = mr;
37       return true;
38     }
39   return false;
40 }
41
42 void
43 Mark_engraver::do_process_requests ()
44 {  
45   if (!mark_req_l_ || staff_side_p_)
46     return;
47
48   staff_side_p_ = new G_staff_side_item;
49
50   text_p_ = new G_text_item;
51
52   text_p_->text_str_ = mark_req_l_->str_;
53   //  text_p_->align_dir_ = CENTER;
54
55   text_p_->style_str_ = text_p_->text_str_.index_any_i ("0123456789") >= 0 
56     ? "mark" : "Large";
57
58   Scalar prop = get_property ("markdir", 0);
59   if (prop.isnum_b ())
60     {
61       staff_side_p_->dir_ = (Direction) (int) prop;
62     }
63   else 
64     {
65       staff_side_p_->dir_ = UP;
66     }
67
68   staff_side_p_->set_victim(text_p_);
69   
70   //  Scalar padding = get_property ("markScriptPadding", 0);
71   //  if (padding.length_i() && padding.isnum_b ())
72   //    {
73   //      script_p_->padding_f_ = Real(padding);
74   //    }
75   //  Scalar break_priority = get_property ("markBreakPriority", 0);
76   //  if (break_priority.length_i() && break_priority.isnum_b ())
77   //    {
78   //      staff_side_p_->break_priority_i_ = int(break_priority);
79   //    }
80
81   
82   announce_element (Score_element_info (text_p_, mark_req_l_));
83   announce_element (Score_element_info (staff_side_p_, mark_req_l_));
84 }
85
86 void 
87 Mark_engraver::do_pre_move_processing ()
88 {
89   if (staff_side_p_) 
90     {
91       Staff_symbol* s_l = get_staff_info().staff_sym_l_;
92       staff_side_p_->add_support (s_l);
93       typeset_element (text_p_);
94       typeset_element (staff_side_p_);
95       text_p_ = 0;
96       staff_side_p_ = 0;
97       mark_req_l_ = 0;
98     }
99 }
100
101 void
102 Mark_engraver::acknowledge_element (Score_element_info i)
103 {
104   if (staff_side_p_) 
105     {
106       if (dynamic_cast<Stem *> (i.elem_l_) ||
107           dynamic_cast<Rhythmic_head *> (i.elem_l_))
108         {
109           staff_side_p_->add_support (i.elem_l_);
110         }
111     }
112 }