From 5376dae29a40c28dd8b5a419844c324c4e70ed32 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 22:47:08 +0000 Subject: [PATCH] lilypond-1.3.34 --- input/bugs/k.fly | 2 ++ lily/clef-engraver.cc | 2 +- lily/command-request.cc | 22 ++++++++++------ lily/engraver.cc | 4 ++- lily/include/command-request.hh | 4 ++- lily/include/key-def.hh | 4 ++- lily/include/key-item.hh | 15 ++++------- lily/key-engraver.cc | 11 +++++--- lily/key-item.cc | 46 +++++++++++++-------------------- lily/key-performer.cc | 4 +-- lily/lookup.cc | 27 ++++++++++++------- lily/parser.yy | 24 ++++++++++++----- 12 files changed, 94 insertions(+), 71 deletions(-) create mode 100644 input/bugs/k.fly diff --git a/input/bugs/k.fly b/input/bugs/k.fly new file mode 100644 index 0000000000..b7d1761124 --- /dev/null +++ b/input/bugs/k.fly @@ -0,0 +1,2 @@ + +\key e; c2 \clef "treble";\key es; c \break c1 diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index 835b2c5760..cffdd3f340 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -124,7 +124,7 @@ Clef_engraver::acknowledge_element (Score_element_info info) } else if (Key_item *k = dynamic_cast(it_l)) { - k-> set_c_position (c0_position_i_); + k->set_elt_property ("c0-position", gh_int2scm (c0_position_i_)); } } } diff --git a/lily/command-request.cc b/lily/command-request.cc index 58f4d434d0..68016b6683 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -106,17 +106,25 @@ Tempo_req::do_equal_b (Request const *r) const void Key_change_req::do_print () const { -#ifndef NPRINT - for (int i=0; i < key_.pitch_arr_.size (); i++) - { - key_.pitch_arr_[i].print (); - } +#if 0 + key_->print(); #endif } Key_change_req::Key_change_req () { + key_ = 0; +} +Key_change_req::Key_change_req (Key_change_req const&s) + : Request (s) +{ + key_ = new Key_def (*s.key_); } +Key_change_req::~Key_change_req () +{ + delete key_; +} + Break_req::Break_req () { @@ -134,8 +142,6 @@ Mark_req::do_equal_b (Request const * r) const void Key_change_req::transpose (Musical_pitch p) { - key_.transpose (p); + key_->transpose (p); } - - diff --git a/lily/engraver.cc b/lily/engraver.cc index 40bc87f9c1..2211e8ac32 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -25,7 +25,9 @@ void Engraver::announce_element (Score_element_info i) { Score_element * e = i.elem_l_; - group (e, "interfaces").add_thing (ly_symbol2scm (e->name())); + + if (e->get_elt_property ("interfaces") == SCM_EOL) + group (e, "interfaces").add_thing (ly_symbol2scm (e->name())); if (!i.origin_trans_l_) i.origin_trans_l_ = this; diff --git a/lily/include/command-request.hh b/lily/include/command-request.hh index c21b1d0b3c..5f138b28b0 100644 --- a/lily/include/command-request.hh +++ b/lily/include/command-request.hh @@ -106,7 +106,9 @@ class Key_change_req : public Request { public: Key_change_req (); - Key_def key_; + ~Key_change_req(); + Key_change_req(Key_change_req const &); + Key_def *key_; protected: VIRTUAL_COPY_CONS(Music); diff --git a/lily/include/key-def.hh b/lily/include/key-def.hh index 84eb0a3d0f..2b9fdccff2 100644 --- a/lily/include/key-def.hh +++ b/lily/include/key-def.hh @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1999 Jan Nieuwenhuizen + (c) 1999--2000 Jan Nieuwenhuizen */ @@ -15,6 +15,8 @@ /** Universal key definition (Should rename class Key to 'Accidentals'?) + + FIXME: merge key.hh and key-def.hh classes. */ class Key_def { diff --git a/lily/include/key-item.hh b/lily/include/key-item.hh index 55f320c9c9..d8a7f295a0 100644 --- a/lily/include/key-item.hh +++ b/lily/include/key-item.hh @@ -11,28 +11,23 @@ #include "array.hh" -/// An item which places accidentals at the start of the line +/** An item which places accidentals at the start of the line + + TODO: Schemify me. + */ class Key_item :public Item { Array pitch_arr_; Array acc_arr_; Array old_pitch_arr_; Array old_acc_arr_; - int c0_position_; - public: - bool multi_octave_b_; - - int get_c_position () const; - - VIRTUAL_COPY_CONS(Score_element); - Key_item (); void add (int pitch, int acc); void add_old (int pitch, int acc); - void set_c_position (int); + int calculate_position(int p, int a) const; protected: diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index b9f0ec4e29..88ca9e102c 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -131,6 +131,9 @@ Key_engraver::do_pre_move_processing () void Key_engraver::read_req (Key_change_req const * r) { + if (!r->key_) + return; + old_accidental_idx_arr_ = accidental_idx_arr_; key_.clear (); SCM prop = get_property ("keyOctaviation"); @@ -139,9 +142,9 @@ Key_engraver::read_req (Key_change_req const * r) accidental_idx_arr_.clear (); - if (r->key_.ordinary_key_b_) + if (r->key_->ordinary_key_b_) { - int no_of_acc = r->key_.ordinary_accidentals_i (); + int no_of_acc = r->key_->ordinary_accidentals_i (); // Hmm, can't these be handled/constructed by Key_change_req? if (no_of_acc < 0) @@ -181,9 +184,9 @@ Key_engraver::read_req (Key_change_req const * r) } else // Special key { - for (int i = 0; i < r->key_.pitch_arr_.size (); i ++) + for (int i = 0; i < r->key_->pitch_arr_.size (); i ++) { - Musical_pitch m_l =r->key_.pitch_arr_[i]; + Musical_pitch m_l =r->key_->pitch_arr_[i]; if (key_.multi_octave_b_) key_.set (m_l); else diff --git a/lily/key-item.cc b/lily/key-item.cc index 52d76b5769..e6b8df7b44 100644 --- a/lily/key-item.cc +++ b/lily/key-item.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1996, 1997--2000 Han-Wen Nienhuys + (c) 1996--2000 Han-Wen Nienhuys keyplacement by Mats Bengtsson */ @@ -23,27 +23,9 @@ const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */ Key_item::Key_item () { set_elt_property ("breakable", SCM_BOOL_T); - set_c_position (0); + set_elt_property ("c0-position", gh_int2scm (0)); } -int -Key_item::get_c_position () const -{ - // Find the c in the range -4 through 2 - int from_bottom_pos = c0_position_ + 4; - from_bottom_pos = from_bottom_pos%7; - from_bottom_pos = (from_bottom_pos + 7)%7; // Precaution to get positive. - return from_bottom_pos - 4; -} - - -void -Key_item::set_c_position (int c0) -{ - c0_position_ = c0; -} - - void Key_item::add (int p, int a) { @@ -64,27 +46,35 @@ Key_item::calculate_position(int p, int a) const { if (to_boolean (get_elt_property ("multi-octave"))) { - return p + c0_position_; + return p + gh_scm2int (get_elt_property ("c0-position")); } else { - if ((a<0 && ((p>FLAT_TOP_PITCH) || (p+get_c_position ()>4)) && (p+get_c_position ()>1)) + // Find the c in the range -4 through 2 + int from_bottom_pos = gh_scm2int (get_elt_property ("c0-position")) + 4; + from_bottom_pos = from_bottom_pos%7; + from_bottom_pos = (from_bottom_pos + 7)%7; // Precaution to get positive. + int c0 = from_bottom_pos - 4; + + + if ((a<0 && ((p>FLAT_TOP_PITCH) || (p+c0>4)) && (p+c0>1)) || - (a>0 && ((p>SHARP_TOP_PITCH) || (p+get_c_position ()>5)) && (p+get_c_position ()>2))) + (a>0 && ((p>SHARP_TOP_PITCH) || (p+c0>5)) && (p+c0>2))) { p -= 7; /* Typeset below c_position */ } /* Provide for the four cases in which there's a glitch */ /* it's a hack, but probably not worth */ /* the effort of finding a nicer solution. dl. */ - if (get_c_position ()==2 && a>0 && p==3) + if (c0==2 && a>0 && p==3) p -= 7; - if (get_c_position ()==-3 && a>0 && p==-1) + if (c0==-3 && a>0 && p==-1) p += 7; - if (get_c_position ()==-4 && a<0 && p==-1) + if (c0==-4 && a<0 && p==-1) p += 7; - if (get_c_position ()==-2 && a<0 && p==-3) + if (c0==-2 && a<0 && p==-3) p += 7; - return p + get_c_position (); + + return p + c0; } } diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 6c4132a451..ea2668b926 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -37,9 +37,9 @@ Key_performer::do_print () const void Key_performer::do_process_music () { - if (key_req_l_) + if (key_req_l_ && key_req_l_->key_) { - audio_p_ = new Audio_key (key_req_l_->key_); + audio_p_ = new Audio_key (*key_req_l_->key_); Audio_element_info info (audio_p_, key_req_l_); announce_element (info); key_req_l_ = 0; diff --git a/lily/lookup.cc b/lily/lookup.cc index 0f422458ee..fc4d696d93 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -273,27 +273,36 @@ Lookup::text (String style, String text, Paper_def *paper_l) Array lines = String_convert::split_arr (text, '\n'); - Molecule mol; - Real kern = paper_l->get_var ("line_kern"); - for (i = 0; i< lines.size (); i++) + for (int i=0; i < lines.size (); i++) { - /* - Huh? This way we'll still see \foo sequences in ps output. - */ - String str = lines[i]; + String str (lines[i]); if (output_global_ch == "tex") str = sanitise_TeX_string (str); else if (output_global_ch == "ps") str = sanitise_PS_string (str); + lines[i] = str; + } + + + SCM first = gh_list (ly_symbol2scm ("text"), + ly_str02scm (lines[0].ch_C()), + SCM_UNDEFINED); + first = fontify_atom (metric_l, first); + + + Molecule mol (metric_l->text_dimension (lines[0]), first); + + for (i = 1; i < lines.size (); i++) + { SCM line = (gh_list (ly_symbol2scm ("text"), - ly_str02scm (str.ch_C ()), + ly_str02scm (lines[i].ch_C ()), SCM_UNDEFINED)); line = fontify_atom (metric_l, line); mol.add_at_edge (Y_AXIS, DOWN, - Molecule (metric_l->text_dimension (str), line), + Molecule (metric_l->text_dimension (lines[i]), line), kern); } diff --git a/lily/parser.yy b/lily/parser.yy index db172c5e26..3b9df13d04 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -5,7 +5,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1999 Han-Wen Nienhuys + (c) 1997--2000 Han-Wen Nienhuys Jan Nieuwenhuizen */ @@ -1039,19 +1039,31 @@ verbose_command_req: $$ = new Clef_change_req (ly_scm2string ($2)); } + | KEY { + Key_change_req *key_p= new Key_change_req; + key_p->key_ = 0; + $$ = key_p; + } /* UGH. optional. */ + | KEY NOTENAME_PITCH optional_modality { Key_change_req *key_p= new Key_change_req; - key_p->key_.pitch_arr_.push (*$2); - key_p->key_.ordinary_key_b_ = true; - key_p->key_.modality_i_ = $3; + Key_def d; + d.pitch_arr_.push (*$2); + d.ordinary_key_b_ = true; + d.modality_i_ = $3; + + key_p->key_ = new Key_def (d); $$ = key_p; delete $2; } | KEYSIGNATURE pitch_list { Key_change_req *key_p= new Key_change_req; - key_p->key_.pitch_arr_ = *$2; - key_p->key_.ordinary_key_b_ = false; + Key_def d; + d.pitch_arr_ = *$2; + d.ordinary_key_b_ = false; + + key_p->key_ = new Key_def(d); $$ = key_p; delete $2; } -- 2.39.5