2 break-align-engraver.cc -- implement Break_align_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2006 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"
16 #include "translator.icc"
18 class Break_align_engraver
: public Engraver
24 void add_to_group (SCM
, Item
*);
26 void stop_translation_timestep ();
27 virtual void derived_mark () const;
29 TRANSLATOR_DECLARATIONS (Break_align_engraver
);
30 DECLARE_ACKNOWLEDGER (break_aligned
);
34 Break_align_engraver::stop_translation_timestep ()
36 column_alist_
= SCM_EOL
;
42 Break_align_engraver::Break_align_engraver ()
44 column_alist_
= SCM_EOL
;
50 Break_align_engraver::derived_mark () const
52 scm_gc_mark (column_alist_
);
56 Break_align_engraver::acknowledge_break_aligned (Grob_info inf
)
58 if (Item
*item
= dynamic_cast<Item
*> (inf
.grob ()))
61 Removed check for item->empty (X_AXIS). --hwn 20/1/04
63 if (item
->get_parent (X_AXIS
))
66 if (!Item::is_non_musical (item
))
69 SCM align_name
= item
->get_property ("break-align-symbol");
70 if (!scm_is_symbol (align_name
))
75 align_
= make_item ("BreakAlignment", SCM_EOL
);
77 Context
*origin
= inf
.origin_contexts (this)[0];
79 Translator_group
*tg
= origin
->implementation ();
80 Engraver
*random_source
= dynamic_cast<Engraver
*> (unsmob_translator (scm_car (tg
->get_simple_trans_list ())));
83 Make left edge appear to come from same context as clef/bar-line etc.
85 left_edge_
= random_source
->make_item ("LeftEdge", SCM_EOL
);
86 add_to_group (left_edge_
->get_property ("break-align-symbol"),
90 add_to_group (align_name
, item
);
95 Break_align_engraver::add_to_group (SCM align_name
, Item
*item
)
97 SCM s
= scm_assoc (align_name
, column_alist_
);
102 Grob
*e
= unsmob_grob (scm_cdr (s
));
103 group
= dynamic_cast<Item
*> (e
);
107 group
= make_item ("BreakAlignGroup", item
->self_scm ());
109 group
->set_property ("break-align-symbol", align_name
);
110 group
->set_parent (align_
, Y_AXIS
);
112 column_alist_
= scm_assoc_set_x (column_alist_
, align_name
, group
->self_scm ());
114 Break_align_interface::add_element (align_
, group
);
116 Axis_group_interface::add_element (group
, item
);
118 ADD_ACKNOWLEDGER (Break_align_engraver
, break_aligned
);
119 ADD_TRANSLATOR (Break_align_engraver
,
120 "Align grobs with corresponding @code{break-align-symbols} into "
121 "groups, and order the groups according to @code{breakAlignOrder}. "
122 "The left edge of the alignment gets a separate group, with a symbol @code{left-edge}. ",
123 /* create */ "BreakAlignment BreakAlignGroup LeftEdge",