X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbreak-align-engraver.cc;h=c4d9bc893cc3d011e5994c3e5cc5fa1823a5cddd;hb=b592e19981c26c381a4347a615f97abbd0838666;hp=21551ad5b29db6b28a3c2dc813c8a251767f9e05;hpb=f68bbd7a1ed1b0e7146bbbffcbcbb7f9c9bda3cc;p=lilypond.git diff --git a/lily/break-align-engraver.cc b/lily/break-align-engraver.cc index 21551ad5b2..c4d9bc893c 100644 --- a/lily/break-align-engraver.cc +++ b/lily/break-align-engraver.cc @@ -3,12 +3,12 @@ source file of the GNU LilyPond music typesetter - (c) 1999--2001 Han-Wen Nienhuys + (c) 1999--2002 Han-Wen Nienhuys */ #include "engraver.hh" #include "protected-scm.hh" -#include "break-align-item.hh" +#include "break-align-interface.hh" #include "item.hh" #include "align-interface.hh" #include "axis-group-interface.hh" @@ -16,8 +16,9 @@ class Break_align_engraver : public Engraver { - Item *align_l_; + Item *align_; Protected_scm column_alist_; + void add_to_group (SCM,Item*); protected: virtual void finalize (); virtual void acknowledge_grob (Grob_info i); @@ -25,19 +26,14 @@ protected: void add_column (SCM); public: - VIRTUAL_COPY_CONS (Translator); - Break_align_engraver (); + TRANSLATOR_DECLARATIONS(Break_align_engraver); }; - - -ADD_THIS_TRANSLATOR (Break_align_engraver); - void Break_align_engraver::add_column (SCM smob) { Grob * e = unsmob_grob (smob); - Break_align_interface::add_element (align_l_,e); + Break_align_interface::add_element (align_,e); typeset_grob (e); } @@ -70,10 +66,10 @@ Break_align_engraver::stop_translation_timestep () column_alist_ = SCM_EOL; - if (align_l_) + if (align_) { - typeset_grob (align_l_); - align_l_ = 0; + typeset_grob (align_); + align_ = 0; } } @@ -81,77 +77,69 @@ Break_align_engraver::stop_translation_timestep () Break_align_engraver::Break_align_engraver () { column_alist_ = SCM_EOL; - align_l_ =0; + align_ =0; } void Break_align_engraver::acknowledge_grob (Grob_info inf) { - if (Item * item_l = dynamic_cast (inf.elem_l_)) + if (Item * item = dynamic_cast (inf.grob_)) { - if (item_l->empty_b (X_AXIS) || item_l->parent_l (X_AXIS)) + if (item->empty_b (X_AXIS) || item->get_parent (X_AXIS)) return; - SCM bp=item_l->get_grob_property ("breakable"); + SCM bp=item->get_grob_property ("breakable"); bool breakable = (to_boolean (bp)); if (!breakable) return ; - SCM align_name = item_l->get_grob_property ("break-align-symbol"); + SCM align_name = item->get_grob_property ("break-align-symbol"); if (!gh_symbol_p (align_name)) return ; - if (!align_l_) + if (!align_) { - align_l_ = new Item (get_property ("BreakAlignment")); - Break_align_interface::set_interface (align_l_); - announce_grob (align_l_,0); - - SCM edge_sym = ly_symbol2scm ("Left_edge_item"); - Item * edge = new Item (get_property ("LeftEdge")); - - + align_ = new Item (get_property ("BreakAlignment")); - /* - If the element is empty, it will be ignored in the break - alignment stuff. + announce_grob (align_, SCM_EOL); - TODO: switch off ignoring empty stuff? - */ - edge->set_extent_callback (Grob::point_dimension_callback_proc, X_AXIS); - - /* - We must have left-edge in the middle. Instrument-names - are left to left-edge, so they don't enter the staff. - */ - align_l_->set_grob_property ("self-alignment-X", edge->self_scm ()); - - announce_grob (edge, 0); - column_alist_ = scm_assoc_set_x (column_alist_, edge_sym, edge->self_scm ()); + Item * edge = new Item (get_property ("LeftEdge")); + add_to_group (edge->get_grob_property ("break-align-symbol"), edge); + announce_grob(edge, SCM_EOL); } + + add_to_group (align_name, item); + } +} - SCM s = scm_assoc (align_name, column_alist_); - - Item * group = 0; - - if (s != SCM_BOOL_F) - { - Grob *e = unsmob_grob (ly_cdr (s)); - group = dynamic_cast (e); - } - else - { - group = new Item (get_property ("BreakAlignGroup")); +void +Break_align_engraver::add_to_group(SCM align_name, Item*item) +{ + SCM s = scm_assoc (align_name, column_alist_); + Item * group = 0; - Axis_group_interface::set_interface (group); - Axis_group_interface::set_axes (group, X_AXIS,X_AXIS); + if (s != SCM_BOOL_F) + { + Grob *e = unsmob_grob (ly_cdr (s)); + group = dynamic_cast (e); + } + else + { + group = new Item (get_property ("BreakAlignGroup")); - group->set_grob_property ("break-align-symbol", align_name); - group->set_parent (align_l_, Y_AXIS); - announce_grob (group, 0); - column_alist_ = scm_assoc_set_x (column_alist_, align_name, group->self_scm ()); + group->set_grob_property ("break-align-symbol", align_name); + group->set_parent (align_, Y_AXIS); + announce_grob(group, item->self_scm()); + + column_alist_ = scm_assoc_set_x (column_alist_, align_name, group->self_scm ()); - } - Axis_group_interface::add_element (group, item_l); } + Axis_group_interface::add_element (group, item); } + +ENTER_DESCRIPTION(Break_align_engraver, +/* descr */ "Align grobs with corresponding break-align-symbols into groups, and order the groups according to breakAlignOrder", +/* creats*/ "BreakAlignment BreakAlignGroup LeftEdge", +/* acks */ "break-aligned-interface" +,/* reads */ "breakAlignOrder", +/* write */ "");