2 score-align-reg.cc -- implement Score_priority_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
10 #include "horizontal-group-item.hh"
11 #include "score-priority-grav.hh"
13 #include "assoc-iter.hh"
14 #include "break-align-item.hh"
17 Score_priority_engraver::Score_priority_engraver()
22 Score_priority_engraver::do_pre_move_processing()
24 for (Assoc_iter
<int, Horizontal_group_item
*> i(align_p_assoc_
); i
.ok() ; i
++)
28 typeset_element (i
.val ());
32 align_p_assoc_
.clear ();
36 Score_priority_engraver::acknowledge_element (Score_elem_info inf
)
38 Item
* item_l
= inf
.elem_l_
->item ();
39 if (item_l
&& item_l
->breakable_b_
&& !item_l
->empty_b ())
42 Don't try to eat up our (probable) parent.
44 if (inf
.origin_grav_l_arr_
.size () <= 1 &&
45 item_l
->is_type_b (Break_align_item::static_name ()))
49 int priority
=item_l
->break_priority_i_
;
50 Horizontal_group_item
* hg
=0;
51 if (!align_p_assoc_
.elt_b(priority
))
53 hg
= new Horizontal_group_item
;
54 announce_element (Score_elem_info (hg
,0));
55 align_p_assoc_
[priority
] = hg
;
56 hg
->break_priority_i_
= priority
;
57 hg
->breakable_b_
= true;
60 hg
= align_p_assoc_
[priority
];
62 Score_elem
* unbound_elem
= inf
.elem_l_
;
64 while (unbound_elem
->axis_group_l_a_
[X_AXIS
])
66 /* We might have added inf.elem_l_ earlier because we added one
67 of its children. We don't want to add ourselves to ourself
69 if (unbound_elem
->axis_group_l_a_
[X_AXIS
] == hg
)
71 unbound_elem
= unbound_elem
->axis_group_l_a_
[X_AXIS
];
74 hg
->add_element (unbound_elem
);
78 IMPLEMENT_IS_TYPE_B1(Score_priority_engraver
, Engraver
);
79 ADD_THIS_TRANSLATOR(Score_priority_engraver
);