2 break-align-engraver.cc -- implement Break_align_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2008 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
*);
26 void create_alignment (Grob_info
);
28 void stop_translation_timestep ();
29 virtual void derived_mark () const;
31 TRANSLATOR_DECLARATIONS (Break_align_engraver
);
32 DECLARE_ACKNOWLEDGER (break_aligned
);
33 DECLARE_ACKNOWLEDGER (break_alignable
);
37 Break_align_engraver::stop_translation_timestep ()
39 column_alist_
= SCM_EOL
;
45 Break_align_engraver::Break_align_engraver ()
47 column_alist_
= SCM_EOL
;
53 Break_align_engraver::derived_mark () const
55 scm_gc_mark (column_alist_
);
59 Break_align_engraver::acknowledge_break_alignable (Grob_info inf
)
62 create_alignment (inf
);
64 Grob
*g
= inf
.grob ();
66 if (!g
->get_parent (X_AXIS
))
67 g
->set_parent (align_
, X_AXIS
);
71 Break_align_engraver::acknowledge_break_aligned (Grob_info inf
)
73 if (Item
*item
= dynamic_cast<Item
*> (inf
.grob ()))
76 Removed check for item->empty (X_AXIS). --hwn 20/1/04
78 if (item
->get_parent (X_AXIS
))
81 if (!Item::is_non_musical (item
))
84 SCM align_name
= item
->get_property ("break-align-symbol");
85 if (!scm_is_symbol (align_name
))
89 create_alignment (inf
);
91 add_to_group (align_name
, item
);
96 Break_align_engraver::create_alignment (Grob_info inf
)
98 align_
= make_item ("BreakAlignment", SCM_EOL
);
100 Context
*origin
= inf
.origin_contexts (this)[0];
102 Translator_group
*tg
= origin
->implementation ();
103 Engraver
*random_source
= dynamic_cast<Engraver
*> (unsmob_translator (scm_car (tg
->get_simple_trans_list ())));
105 random_source
= this;
108 Make left edge appear to come from same context as clef/bar-line etc.
110 left_edge_
= random_source
->make_item ("LeftEdge", SCM_EOL
);
111 add_to_group (left_edge_
->get_property ("break-align-symbol"),
116 Break_align_engraver::add_to_group (SCM align_name
, Item
*item
)
118 SCM s
= scm_assoc (align_name
, column_alist_
);
123 Grob
*e
= unsmob_grob (scm_cdr (s
));
124 group
= dynamic_cast<Item
*> (e
);
128 group
= make_item ("BreakAlignGroup", item
->self_scm ());
130 group
->set_property ("break-align-symbol", align_name
);
131 group
->set_parent (align_
, Y_AXIS
);
133 column_alist_
= scm_assoc_set_x (column_alist_
, align_name
, group
->self_scm ());
135 Break_alignment_interface::add_element (align_
, group
);
137 Axis_group_interface::add_element (group
, item
);
140 ADD_ACKNOWLEDGER (Break_align_engraver
, break_aligned
);
141 ADD_ACKNOWLEDGER (Break_align_engraver
, break_alignable
);
142 ADD_TRANSLATOR (Break_align_engraver
,
144 "Align grobs with corresponding @code{break-align-symbols}"
145 " into groups, and order the groups according to"
146 " @code{breakAlignOrder}. The left edge of the alignment gets"
147 " a separate group, with a symbol @code{left-edge}.",