2 score-align-reg.cc -- implement Score_priority_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "horizontal-group-item.hh"
11 #include "score-priority-engraver.hh"
13 #include "dictionary-iter.hh"
14 #include "break-align-item.hh"
17 Score_priority_engraver::Score_priority_engraver()
19 align_p_tab_.hash_func_ = int_hash;
23 Score_priority_engraver::do_pre_move_processing()
25 for (Hash_table_iter<int, Horizontal_group_item*> i(align_p_tab_);
30 typeset_element (i.val ());
34 align_p_tab_.clear ();
38 Score_priority_engraver::acknowledge_element (Score_element_info inf)
40 Item * item_l = dynamic_cast <Item *> (inf.elem_l_);
41 if (item_l && item_l->breakable_b_ && !item_l->empty_b ())
44 Don't try to eat up our (probable) parent.
46 if (inf.origin_grav_l_arr_.size () <= 1 &&
47 dynamic_cast<Break_align_item *> (item_l))
51 int priority =item_l->break_priority_i_;
52 Horizontal_group_item * hg =0;
53 if (!align_p_tab_.elem_b(priority))
55 hg = new Horizontal_group_item;
56 announce_element (Score_element_info (hg,0));
57 align_p_tab_[priority] = hg;
58 hg->break_priority_i_ = priority;
59 hg->breakable_b_ = true;
62 hg = align_p_tab_[priority];
64 Score_element * unbound_elem = inf.elem_l_;
69 while (unbound_elem->parent_l (X_AXIS))
71 /* We might have added inf.elem_l_ earlier because we added one
72 of its children. We don't want to add ourselves to ourself
74 Graphical_element * e = unbound_elem->parent_l (X_AXIS);
77 unbound_elem = dynamic_cast<Score_element*> (e);
80 hg->add_element (unbound_elem);
85 ADD_THIS_TRANSLATOR(Score_priority_engraver);