X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftext-engraver.cc;h=3c18529ed74477ad328db1edfb42ebbd10b6bfd5;hb=74ee52246b9a7571a2d697df7aeaf3aa3bd09f45;hp=088ca5577c62f8b0da4992340d68064ae4427073;hpb=8aad615ea7bb31f49a0c2afc21eea5ff5de20437;p=lilypond.git diff --git a/lily/text-engraver.cc b/lily/text-engraver.cc index 088ca5577c..3c18529ed7 100644 --- a/lily/text-engraver.cc +++ b/lily/text-engraver.cc @@ -7,21 +7,24 @@ */ +#include "dimension-cache.hh" #include "engraver.hh" -#include "g-staff-side.hh" -#include "g-text-item.hh" -#include "text-def.hh" +#include "side-position-interface.hh" +#include "text-item.hh" +#include "musical-request.hh" #include "note-head.hh" #include "stem.hh" -#include "staff-sym.hh" +#include "staff-symbol.hh" +/** + typeset directions that are plain text. + */ class Text_engraver : public Engraver { - Link_array reqs_; - Link_array positionings_; - Link_array texts_; + Link_array reqs_; + Link_array texts_; public: - Text_engraver(); + VIRTUAL_COPY_CONS(Translator); protected: virtual bool do_try_music (Music* m); @@ -31,19 +34,13 @@ protected: virtual void acknowledge_element (Score_element_info); }; -Text_engraver::Text_engraver () -{ - -} +ADD_THIS_TRANSLATOR (Text_engraver); bool Text_engraver::do_try_music (Music *m) { - if (Script_req *r = dynamic_cast (m)) + if (Text_script_req *r = dynamic_cast (m)) { - Text_def * t = dynamic_cast (r->scriptdef_p_); - if (!t) - return false; reqs_.push (r); return true; } @@ -56,16 +53,21 @@ Text_engraver::acknowledge_element (Score_element_info i) { if (Note_head *n = dynamic_cast (i.elem_l_)) { - for (int i=0; i < positionings_.size (); i++) + for (int i=0; i < texts_.size (); i++) { - positionings_[i]->add_support (n); + Side_position_interface st (texts_[i]); + st.add_support (n); + if (st.get_axis( ) == X_AXIS + && !texts_[i]->parent_l (Y_AXIS)) + texts_[i]->set_parent (n, Y_AXIS); } } if (Stem *n = dynamic_cast (i.elem_l_)) { - for (int i=0; i < positionings_.size (); i++) + for (int i=0; i < texts_.size (); i++) { - positionings_[i]->add_support (n); + Side_position_interface st(texts_[i]); + st.add_support (n); } } } @@ -75,42 +77,51 @@ Text_engraver::do_process_requests () { for (int i=0; i < reqs_.size (); i++) { - Script_req * r = reqs_[i]; - Text_def * t= dynamic_cast (r->scriptdef_p_); + Text_script_req * r = reqs_[i]; - G_text_item *text = new G_text_item; - G_staff_side_item *ss = new G_staff_side_item; - ss->set_victim (text); - ss->dir_ = r->dir_; - Scalar p (get_property ("textstyle", 0)); // textStyle? - if (p.length_i ()) - text->style_str_ = p; - text->text_str_ = t->text_str_; + Text_item *text = new Text_item; + Side_position_interface stafy (text); - announce_element (Score_element_info (text, r)); - announce_element (Score_element_info (ss, r)); + SCM axisprop = get_property ("scriptHorizontal",0); + if (to_boolean (axisprop)) + { + stafy.set_axis (X_AXIS); + // text->set_parent (ss, Y_AXIS); + } + else + stafy.set_axis (Y_AXIS); + + text->set_elt_property ("script-priority", + gh_int2scm (200)); + if (r->get_direction ()) + stafy.set_direction (r->get_direction ()); + + text->set_elt_property ("text", + ly_str02scm ( r->text_str_.ch_C ())); + + if (r->style_str_.length_i ()) + text->set_elt_property ("style", ly_str02scm (r->style_str_.ch_C())); + + SCM empty = get_property ("textEmptyDimension", 0); + if (to_boolean (empty)) + { + text->set_empty (X_AXIS); + } + + announce_element (Score_element_info (text, r)); texts_.push (text); - positionings_.push (ss); } } void Text_engraver::do_pre_move_processing () { - Staff_symbol* s_l = get_staff_info().staff_sym_l_; for (int i=0; i < texts_.size (); i++) { - if (s_l != 0) - { - positionings_[i]->add_support (s_l); - } - typeset_element (texts_[i]); - typeset_element (positionings_[i]); } texts_.clear (); - positionings_.clear (); } void @@ -119,4 +130,3 @@ Text_engraver::do_post_move_processing () reqs_.clear (); } -ADD_THIS_TRANSLATOR(Text_engraver);