2 break-align-engraver.cc -- implement Break_align_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "protected-scm.hh"
11 #include "break-align-interface.hh"
13 #include "align-interface.hh"
14 #include "axis-group-interface.hh"
17 class Break_align_engraver : public Engraver
20 Protected_scm column_alist_;
21 void add_to_group (SCM,Item*);
23 virtual void finalize ();
24 virtual void acknowledge_grob (Grob_info i);
25 virtual void stop_translation_timestep ();
26 void add_column (SCM);
29 TRANSLATOR_DECLARATIONS(Break_align_engraver);
33 Break_align_engraver::add_column (SCM smob)
35 Grob * e = unsmob_grob (smob);
36 Break_align_interface::add_element (align_l_,e);
41 Break_align_engraver::finalize ()
43 column_alist_ = SCM_EOL;
47 Break_align_engraver::stop_translation_timestep ()
49 SCM order = get_property ("breakAlignOrder");
50 for (; gh_pair_p (order); order = ly_cdr (order))
52 SCM p = scm_assoc (ly_car (order), column_alist_);
55 add_column (ly_cdr (p));
56 column_alist_ = scm_assoc_remove_x (column_alist_, ly_car (order));
60 for (SCM p = column_alist_; gh_pair_p (p); p = ly_cdr (p))
62 SCM pair = ly_car (p);
63 add_column (ly_cdr (pair));
67 column_alist_ = SCM_EOL;
71 typeset_grob (align_l_);
77 Break_align_engraver::Break_align_engraver ()
79 column_alist_ = SCM_EOL;
84 Break_align_engraver::acknowledge_grob (Grob_info inf)
86 if (Item * item_l = dynamic_cast <Item *> (inf.grob_l_))
88 if (item_l->empty_b (X_AXIS) || item_l->get_parent (X_AXIS))
91 SCM bp=item_l->get_grob_property ("breakable");
92 bool breakable = (to_boolean (bp));
96 SCM align_name = item_l->get_grob_property ("break-align-symbol");
97 if (!gh_symbol_p (align_name))
102 align_l_ = new Item (get_property ("BreakAlignment"));
104 announce_grob (align_l_, SCM_EOL);
106 Item * edge = new Item (get_property ("LeftEdge"));
107 add_to_group (edge->get_grob_property ("break-align-symbol"), edge);
108 announce_grob(edge, SCM_EOL);
111 add_to_group (align_name, item_l);
116 Break_align_engraver::add_to_group(SCM align_name, Item*item_l)
118 SCM s = scm_assoc (align_name, column_alist_);
123 Grob *e = unsmob_grob (ly_cdr (s));
124 group = dynamic_cast<Item*> (e);
128 group = new Item (get_property ("BreakAlignGroup"));
130 group->set_grob_property ("break-align-symbol", align_name);
131 group->set_parent (align_l_, Y_AXIS);
132 announce_grob(group, item_l->self_scm());
134 column_alist_ = scm_assoc_set_x (column_alist_, align_name, group->self_scm ());
137 Axis_group_interface::add_element (group, item_l);
140 ENTER_DESCRIPTION(Break_align_engraver,
141 /* descr */ "Align grobs with corresponding break-align-symbols into groups, and order the groups according to breakAlignOrder",
142 /* creats*/ "BreakAlignment BreakAlignGroup LeftEdge",
143 /* acks */ "grob-interface", // break-aligned-interface ?
144 /* reads */ "breakAlignOrder",