2 break-align-engraver.cc -- implement Break_align_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "protected-scm.hh"
10 #include "break-align-interface.hh"
11 #include "align-interface.hh"
12 #include "axis-group-interface.hh"
14 #include "translator-group.hh"
17 #include "translator.icc"
19 class Break_align_engraver
: public Engraver
25 void add_to_group (SCM
, Item
*);
27 void stop_translation_timestep ();
28 virtual void derived_mark () const;
30 TRANSLATOR_DECLARATIONS (Break_align_engraver
);
31 DECLARE_ACKNOWLEDGER (break_aligned
);
35 Break_align_engraver::stop_translation_timestep ()
37 column_alist_
= SCM_EOL
;
43 Break_align_engraver::Break_align_engraver ()
45 column_alist_
= SCM_EOL
;
51 Break_align_engraver::derived_mark () const
53 scm_gc_mark (column_alist_
);
57 Break_align_engraver::acknowledge_break_aligned (Grob_info inf
)
59 if (Item
*item
= dynamic_cast<Item
*> (inf
.grob ()))
62 Removed check for item->empty (X_AXIS). --hwn 20/1/04
64 if (item
->get_parent (X_AXIS
))
67 if (!Item::is_non_musical (item
))
70 SCM align_name
= item
->get_property ("break-align-symbol");
71 if (!scm_is_symbol (align_name
))
76 align_
= make_item ("BreakAlignment", SCM_EOL
);
78 Context
*origin
= inf
.origin_contexts (this)[0];
80 Translator_group
*tg
= origin
->implementation ();
81 Engraver
*random_source
= dynamic_cast<Engraver
*> (unsmob_translator (scm_car (tg
->get_simple_trans_list ())));
84 Make left edge appear to come from same context as clef/bar-line etc.
86 left_edge_
= random_source
->make_item ("LeftEdge", SCM_EOL
);
87 add_to_group (left_edge_
->get_property ("break-align-symbol"),
91 add_to_group (align_name
, item
);
96 Break_align_engraver::add_to_group (SCM align_name
, Item
*item
)
98 SCM s
= scm_assoc (align_name
, column_alist_
);
103 Grob
*e
= unsmob_grob (scm_cdr (s
));
104 group
= dynamic_cast<Item
*> (e
);
108 group
= make_item ("BreakAlignGroup", item
->self_scm ());
110 group
->set_property ("break-align-symbol", align_name
);
111 group
->set_parent (align_
, Y_AXIS
);
113 column_alist_
= scm_assoc_set_x (column_alist_
, align_name
, group
->self_scm ());
115 Break_alignment_interface::add_element (align_
, group
);
117 Axis_group_interface::add_element (group
, item
);
119 ADD_ACKNOWLEDGER (Break_align_engraver
, break_aligned
);
120 ADD_TRANSLATOR (Break_align_engraver
,
121 "Align grobs with corresponding @code{break-align-symbols} into "
122 "groups, and order the groups according to @code{breakAlignOrder}. "
123 "The left edge of the alignment gets a separate group, with a symbol @code{left-edge}. ",
124 /* create */ "BreakAlignment "