]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.34
authorfred <fred>
Tue, 26 Mar 2002 22:47:08 +0000 (22:47 +0000)
committerfred <fred>
Tue, 26 Mar 2002 22:47:08 +0000 (22:47 +0000)
12 files changed:
input/bugs/k.fly [new file with mode: 0644]
lily/clef-engraver.cc
lily/command-request.cc
lily/engraver.cc
lily/include/command-request.hh
lily/include/key-def.hh
lily/include/key-item.hh
lily/key-engraver.cc
lily/key-item.cc
lily/key-performer.cc
lily/lookup.cc
lily/parser.yy

diff --git a/input/bugs/k.fly b/input/bugs/k.fly
new file mode 100644 (file)
index 0000000..b7d1761
--- /dev/null
@@ -0,0 +1,2 @@
+
+\key e; c2 \clef "treble";\key es;  c \break c1
index 835b2c57604ae4bea51cf02678024d63d41bc810..cffdd3f34059e624483b5fa71dc419e22d8c591c 100644 (file)
@@ -124,7 +124,7 @@ Clef_engraver::acknowledge_element (Score_element_info info)
        }
       else if (Key_item *k = dynamic_cast<Key_item*>(it_l))
        {
-         k-> set_c_position (c0_position_i_);
+         k->set_elt_property ("c0-position", gh_int2scm (c0_position_i_));
        }
     } 
 }
index 58f4d434d03c28bfffe80a78f364c063a8c1a1a4..68016b6683e80d7b9d9df7628f78390168014aa6 100644 (file)
@@ -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);
 }
 
-
-                          
index 40bc87f9c1b649e976aba629e106f3cd4db9bc65..2211e8ac324a1c260f0f69c88c82c08307605b30 100644 (file)
@@ -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;
index c21b1d0b3c07b912be8cc2d0224e2114ad1fd9d5..5f138b28b0123e725cae52805fb67d597f66160d 100644 (file)
@@ -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);
index 84eb0a3d0fb770a072aa8de5bfda477431dccce2..2b9fdccff205d216baff6f2e39a082cc0016f710 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 1999--2000 Jan Nieuwenhuizen <janneke@gnu.org>
   
  */
 
@@ -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
 {
index 55f320c9c9bed87d35eeae45b52700c0e7603822..d8a7f295a05f5f5948b0ce5d42ec51af045d46ae 100644 (file)
 #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<int> pitch_arr_;
   Array<int> acc_arr_;
   Array<int> old_pitch_arr_;
   Array<int> 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:
index b9f0ec4e29f0f4c528c86548e1977b0015557ac0..88ca9e102cf3b2b12ba04caf7221bf913616c0a3 100644 (file)
@@ -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
index 52d76b5769a477ddaeedb8402cb848c7daa74bc8..e6b8df7b4493e1f14fea0f5f2df3e7c5d41775f3 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996, 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
   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;
   }
 }
 
index 6c4132a451e8e9105bc1c7019c2a85f19a8d507f..ea2668b926c91bd2419836b5f32e0a4d71fbdf8d 100644 (file)
@@ -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;
index 0f422458eea29ee76480df753352c08e08e63fa6..fc4d696d93656fa456f7bb1e132ba0671e51b9cd 100644 (file)
@@ -273,27 +273,36 @@ Lookup::text (String style, String text, Paper_def *paper_l)
   
   Array<String> 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);
     }
 
index db172c5e2637aed600150165a28c9a94452bb2b3..3b9df13d0425c7cc095d65f6e7f6cb4ce6b0dff5 100644 (file)
@@ -5,7 +5,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
            Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
@@ -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;
        }