2 break-align-engraver.cc -- implement Break_align_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "protected-scm.hh"
11 #include "break-align-item.hh"
13 #include "align-interface.hh"
14 #include "axis-group-interface.hh"
17 class Break_align_engraver : public Engraver
20 Protected_scm column_alist_;
22 virtual void do_removal_processing ();
23 virtual void acknowledge_grob(Grob_info i);
24 virtual void stop_translation_timestep ();
25 void add_column (SCM);
28 VIRTUAL_COPY_CONS(Translator);
29 Break_align_engraver ();
34 ADD_THIS_TRANSLATOR(Break_align_engraver);
37 Break_align_engraver::add_column (SCM smob)
39 Grob * e = unsmob_element (smob);
40 Break_align_interface::add_element (align_l_,e);
45 Break_align_engraver::do_removal_processing ()
47 column_alist_ = SCM_EOL;
51 Break_align_engraver::stop_translation_timestep ()
53 SCM order = get_property ("breakAlignOrder");
54 for (; gh_pair_p (order); order = gh_cdr (order))
56 SCM p = scm_assoc ( gh_car (order), column_alist_);
59 add_column (gh_cdr (p));
60 column_alist_ = scm_assoc_remove_x (column_alist_, gh_car (order));
64 for (SCM p = column_alist_; gh_pair_p (p); p = gh_cdr (p))
66 SCM pair = gh_car (p);
67 add_column (gh_cdr (pair));
71 column_alist_ = SCM_EOL;
75 typeset_grob (align_l_);
81 Break_align_engraver::Break_align_engraver ()
83 column_alist_ = SCM_EOL;
88 Break_align_engraver::acknowledge_grob (Grob_info inf)
90 if (Item * item_l = dynamic_cast <Item *> (inf.elem_l_))
92 if (item_l->empty_b (X_AXIS) || item_l->parent_l (X_AXIS))
95 SCM bp=item_l->get_grob_property ("breakable");
96 bool breakable = (to_boolean (bp));
100 SCM align_name = item_l->get_grob_property ("break-align-symbol");
101 if (!gh_symbol_p (align_name))
106 align_l_ = new Item (get_property ("BreakAlignment"));
107 Break_align_interface::set_interface (align_l_);
108 announce_grob (align_l_,0);
110 SCM edge_sym = ly_symbol2scm ("Left_edge_item");
111 Item * edge = new Item (get_property ("LeftEdge"));
114 We must have left-edge in the middle. Instrument-names
115 are left to left-edge, so they don't enter the staff.
117 align_l_->set_grob_property ("self-alignment-X", edge->self_scm ());
121 If the element is empty, it will be ignored in the break
124 TODO: switch off ignoring empty stuff?
126 edge->set_extent_callback (Grob::point_dimension_callback_proc, X_AXIS);
128 align_l_->set_grob_property ("self-alignment-X", edge->self_scm ());
130 announce_grob (edge, 0);
131 column_alist_ = scm_assoc_set_x (column_alist_, edge_sym, edge->self_scm ());
134 SCM s = scm_assoc (align_name, column_alist_);
140 Grob *e = unsmob_element (gh_cdr(s));
141 group = dynamic_cast<Item*> (e);
145 group = new Item (get_property ("BreakAlignGroup"));
147 Axis_group_interface::set_interface (group);
148 Axis_group_interface::set_axes (group, X_AXIS,X_AXIS);
150 group->set_grob_property ("break-align-symbol", align_name);
151 group->set_parent (align_l_, Y_AXIS);
152 announce_grob (group, 0);
153 column_alist_ = scm_assoc_set_x (column_alist_, align_name, group->self_scm ());
156 Axis_group_interface::add_element (group, item_l);