]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-symbol-engraver.cc
*** empty log message ***
[lilypond.git] / lily / staff-symbol-engraver.cc
1 /*
2   staff-symbol-engraver.cc -- implement Staff_symbol_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "staff-symbol-engraver.hh"
10 #include "spanner.hh"
11
12 Staff_symbol_engraver::~Staff_symbol_engraver ()
13 {
14   assert (!span_);
15 }
16
17 Staff_symbol_engraver::Staff_symbol_engraver ()
18 {
19   finished_span_ = 0;
20   first_start_ = true; 
21   span_ = 0;
22   span_events_[LEFT] = 0;
23   span_events_[RIGHT] = 0;
24 }
25
26 bool
27 Staff_symbol_engraver::try_music (Music *music)
28 {
29   Direction d = to_dir (music->get_property ("span-direction"));
30   if (d)
31     {
32       span_events_[d] = music;
33       return true;
34     }
35   
36   return false;
37 }
38
39 void
40 Staff_symbol_engraver::process_music ()
41 {
42   if (span_events_[STOP])
43     {
44       finished_span_ = span_;
45       span_ = 0;
46     }
47
48   if (span_events_[START])
49     start_spanner ();
50 }
51
52
53 void
54 Staff_symbol_engraver::initialize ()
55 {
56   start_spanner ();
57 }
58
59 void
60 Staff_symbol_engraver::start_spanner ()
61 {
62   if (!span_)
63     {
64       span_ = make_spanner ("StaffSymbol", SCM_EOL);
65     }
66 }
67
68 void
69 Staff_symbol_engraver::stop_spanner ()
70 {
71   if (finished_span_ && !finished_span_->get_bound (RIGHT))
72     {
73       finished_span_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
74     }
75   finished_span_ = 0;
76 }
77
78 void
79 Staff_symbol_engraver::stop_translation_timestep ()
80 {
81   if ((span_events_[START] || first_start_)
82       && span_
83       && !span_->get_bound (LEFT))
84     {
85       span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
86       first_start_ = false;
87     }
88
89   span_events_[START] = 0;
90   span_events_[STOP] = 0;
91   stop_spanner ();
92 }
93
94 void
95 Staff_symbol_engraver::finalize ()
96 {
97   finished_span_ = span_;
98   span_ = 0;
99   stop_spanner ();
100 }
101
102 void
103 Staff_symbol_engraver::acknowledge_grob (Grob_info s)
104 {
105
106   /*
107     Perhaps should try to take SeparationItem as bound of the staff
108     symbol?
109    */
110   if (span_)
111     s.grob_->set_property ("staff-symbol", span_->self_scm ());
112 }
113
114 ADD_TRANSLATOR (Staff_symbol_engraver,
115                 /* descr */ "Create the constellation of five (default) "
116                 "staff lines.",
117                 /* creats*/ "StaffSymbol",
118                 /* accepts */ "staff-span-event",
119                 /* acks  */ "grob-interface",
120                 /* reads */ "",
121                 /* write */ "");