2 separating-line-group-engraver.cc -- implement Separating_line_group_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
11 #include "separation-item.hh"
12 #include "paper-column.hh"
13 #include "output-def.hh"
14 #include "axis-group-interface.hh"
15 #include "note-spacing.hh"
16 #include "accidental-placement.hh"
19 #include "grob-array.hh"
20 #include "pointer-group-interface.hh"
22 #include "translator.icc"
27 vector
<Item
*> note_spacings_
;
34 bool is_empty () const
36 return !staff_spacing_
&& !note_spacings_
.size ();
41 note_spacings_
.clear ();
45 class Separating_line_group_engraver
: public Engraver
48 Spacings current_spacings_
;
49 Spacings last_spacings_
;
51 DECLARE_ACKNOWLEDGER (item
);
52 DECLARE_ACKNOWLEDGER (break_aligned
);
53 void stop_translation_timestep ();
54 void start_translation_timestep ();
56 vector
<Grob
*> break_aligned_
;
58 TRANSLATOR_DECLARATIONS (Separating_line_group_engraver
);
61 Separating_line_group_engraver::Separating_line_group_engraver ()
66 Separating_line_group_engraver::acknowledge_item (Grob_info i
)
70 if (Note_spacing::has_interface (it
))
72 current_spacings_
.note_spacings_
.push_back (it
);
76 if (Item::is_non_musical (it
)
77 && !current_spacings_
.staff_spacing_
78 && to_boolean (get_property ("createSpacing")))
80 Grob
*col
= unsmob_grob (get_property ("currentCommandColumn"));
82 current_spacings_
.staff_spacing_
= make_item ("StaffSpacing", SCM_EOL
);
83 context ()->set_property ("hasStaffSpacing", SCM_BOOL_T
);
85 Pointer_group_interface::add_grob (current_spacings_
.staff_spacing_
,
86 ly_symbol2scm ("left-items"),
89 if (!last_spacings_
.note_spacings_
.size ()
90 && last_spacings_
.staff_spacing_
)
92 SCM ri
= last_spacings_
.staff_spacing_
->get_object ("right-items");
93 Grob_array
*ga
= unsmob_grob_array (ri
);
96 SCM ga_scm
= Grob_array::make_array ();
97 last_spacings_
.staff_spacing_
->set_object ("right-items", ga_scm
);
98 ga
= unsmob_grob_array (ga_scm
);
108 Separating_line_group_engraver::acknowledge_break_aligned (Grob_info gi
)
110 break_aligned_
.push_back (gi
.grob ());
114 Separating_line_group_engraver::start_translation_timestep ()
116 context ()->unset_property (ly_symbol2scm ("hasStaffSpacing"));
120 Separating_line_group_engraver::stop_translation_timestep ()
122 for (vsize i
= 0; i
< break_aligned_
.size (); i
++)
124 SCM smob
= break_aligned_
[i
]->self_scm ();
126 if (Item
*sp
= current_spacings_
.staff_spacing_
)
127 Pointer_group_interface::add_grob (sp
, ly_symbol2scm ("left-break-aligned"), smob
);
129 for (vsize j
= 0; j
< last_spacings_
.note_spacings_
.size (); j
++)
130 Pointer_group_interface::add_grob (last_spacings_
.note_spacings_
[j
],
131 ly_symbol2scm ("right-break-aligned"), smob
);
134 if (!current_spacings_
.is_empty ())
135 last_spacings_
= current_spacings_
;
137 if (Item
*sp
= current_spacings_
.staff_spacing_
)
138 if (Grob
*col
= unsmob_grob (get_property ("currentMusicalColumn")))
139 Pointer_group_interface::add_grob (sp
, ly_symbol2scm ("right-items"), col
);
141 current_spacings_
.clear ();
142 break_aligned_
.clear ();
145 ADD_ACKNOWLEDGER (Separating_line_group_engraver
, item
);
146 ADD_ACKNOWLEDGER (Separating_line_group_engraver
, break_aligned
);
148 ADD_TRANSLATOR (Separating_line_group_engraver
,
150 "Generate objects for computing spacing parameters.",