2 ' separating-line-group-engraver.cc -- implement Separating_line_group_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "separating-group-spanner.hh"
11 #include "separation-item.hh"
12 #include "paper-column.hh"
13 #include "paper-def.hh"
14 #include "engraver.hh"
15 #include "axis-group-interface.hh"
16 #include "note-spacing.hh"
17 #include "group-interface.hh"
18 #include "accidental-placement.hh"
22 Item
* staff_spacing_
;
23 Link_array
<Item
> note_spacings_
;
32 return !staff_spacing_
&& !note_spacings_
.size ();
36 note_spacings_
.clear();
40 class Separating_line_group_engraver
: public Engraver
45 Item
* last_musical_malt_
;
47 Spacings current_spacings_
;
48 Spacings last_spacings_
;
52 virtual void acknowledge_grob (Grob_info
);
53 virtual void initialize ();
54 virtual void finalize ();
55 virtual void stop_translation_timestep ();
56 virtual void start_translation_timestep ();
58 TRANSLATOR_DECLARATIONS(Separating_line_group_engraver
);
61 Separating_line_group_engraver::Separating_line_group_engraver ()
69 Separating_line_group_engraver::initialize ()
71 sep_span_
= new Spanner (get_property ("SeparatingGroupSpanner"));
73 announce_grob(sep_span_
, SCM_EOL
);
74 sep_span_
->set_bound (LEFT
, unsmob_grob (get_property ("currentCommandColumn")));
78 Separating_line_group_engraver::finalize ()
80 SCM ccol
= get_property ("currentCommandColumn");
81 Grob
*column
= unsmob_grob (ccol
);
83 sep_span_
->set_bound (RIGHT
, unsmob_grob (ccol
));
84 typeset_grob (sep_span_
);
87 for (int i
= 0 ; i
< last_spacings_
.note_spacings_
.size(); i
++)
89 Pointer_group_interface::add_grob (last_spacings_
.note_spacings_
[i
],
90 ly_symbol2scm ("right-items" ),
94 if(last_spacings_
.staff_spacing_
95 && last_spacings_
.staff_spacing_
->get_column () == column
)
97 last_spacings_
.staff_spacing_
->suicide ();
102 Separating_line_group_engraver::acknowledge_grob (Grob_info i
)
104 Item
* it
= dynamic_cast <Item
*> (i
.grob_
);
107 if (it
->get_parent (X_AXIS
)
108 && it
->get_parent (X_AXIS
)
109 ->has_extent_callback_b(Axis_group_interface::group_extent_callback_proc
, X_AXIS
))
113 if (to_boolean (it
->get_grob_property ("no-spacing-rods")))
116 if (Note_spacing::has_interface (it
))
118 current_spacings_
.note_spacings_
.push (it
);
122 bool ib
=Item::breakable_b (it
);
123 Item
*&p_ref_ (ib
? break_malt_
128 p_ref_
= new Item (get_property ("SeparationItem"));
131 p_ref_
->set_grob_property ("breakable", SCM_BOOL_T
);
132 announce_grob(p_ref_
, SCM_EOL
);
134 if (p_ref_
== break_malt_
)
136 Item
*it
= new Item (get_property ("StaffSpacing"));
137 current_spacings_
.staff_spacing_
= it
;
138 it
->set_grob_property ("left-items", gh_cons (break_malt_
->self_scm (), SCM_EOL
));
140 announce_grob(it
, SCM_EOL
);
142 if (int i
= last_spacings_
.note_spacings_
.size ())
145 Pointer_group_interface::add_grob (last_spacings_
.note_spacings_
[i
],
146 ly_symbol2scm ("right-items"),
150 else if (last_spacings_
.staff_spacing_
)
153 last_spacings_
.staff_spacing_
->set_grob_property ("right-items",
154 gh_cons (break_malt_
->self_scm(), SCM_EOL
));
159 if (Accidental_placement::has_interface (it
))
160 Separation_item::add_conditional_item (p_ref_
, it
);
162 Separation_item::add_item (p_ref_
,it
);
166 Separating_line_group_engraver::start_translation_timestep ()
172 Separating_line_group_engraver::stop_translation_timestep ()
176 Separating_group_spanner::add_spacing_unit (sep_span_
, break_malt_
);
177 typeset_grob (break_malt_
);
182 if (Item
* sp
= current_spacings_
.staff_spacing_
)
185 TODO: should really look at the left-items of following
189 Pointer_group_interface::add_grob (sp
, ly_symbol2scm ("right-items"),
196 if (!current_spacings_
.empty ())
198 last_spacings_
= current_spacings_
;
201 current_spacings_
.clear ();
205 Separating_group_spanner::add_spacing_unit (sep_span_
, musical_malt_
);
206 typeset_grob (musical_malt_
);
213 ENTER_DESCRIPTION(Separating_line_group_engraver
,
214 /* descr */ "Generates objects for computing spacing parameters.",
215 /* creats*/ "SeparationItem SeparatingGroupSpanner",
217 /* acks */ "item-interface",