]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.0.4
authorfred <fred>
Sun, 24 Mar 2002 20:13:55 +0000 (20:13 +0000)
committerfred <fred>
Sun, 24 Mar 2002 20:13:55 +0000 (20:13 +0000)
VERSION
init/property.ly
lily/VERSION
lily/include/text-def.hh
lily/lyric-engraver.cc
lily/parser.yy
lily/script-engraver.cc
lily/text-def.cc

diff --git a/VERSION b/VERSION
index 7453b04628d795bcf6be18e3a284d22f238e14c4..875f4fb000c286e6b48ade0c08c864b528d0aa51 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1,7 +1,7 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=0
-PATCH_LEVEL=3
+PATCH_LEVEL=4
 MY_PATCH_LEVEL=
 
 # use the above to send patches, always empty for released version:
index 75d8f106697595b561a776ae657372faea32f4fb..a53eccbf6ef3abaf5240eee9560975261adf116d 100644 (file)
@@ -29,6 +29,10 @@ slurydirection               -1      force stem down         \slurdown
 slurydirection         0       stem direction free     \slurboth
 slurydirection         1       force stem up           \slurup
 
+textalignment          -1      left alignment of text
+textalignment          0       center alignment of text
+textalignment          1       right alignment of text
+
 [Score?]
 beamslopedamping       0       no damping              \beamslopeproportional  
 beamslopedamping       1       damping1)               \beamslopedamped
index 7453b04628d795bcf6be18e3a284d22f238e14c4..875f4fb000c286e6b48ade0c08c864b528d0aa51 100644 (file)
@@ -1,7 +1,7 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=0
-PATCH_LEVEL=3
+PATCH_LEVEL=4
 MY_PATCH_LEVEL=
 
 # use the above to send patches, always empty for released version:
index 296350de453461239a03edb7566b557178c47216..e4b42d12330a7065aaf733e445d35bbb18b52853 100644 (file)
@@ -36,6 +36,8 @@ public:
   Text_def();
   virtual void print() const;
   virtual Interval width (Paper_def*) const;
+private:
+  Real guess_width_f(Atom&) const;
 };
 
 #endif // TEXT_DEF_HH
index 8ed3989043f69944ed4c1cad1f4e7d59bf2c2bc4..ceba7c467e16cbc683b119e006a322e5072c83ab 100644 (file)
@@ -44,6 +44,11 @@ Lyric_engraver::do_process_requests()
        {
          td_p->style_str_ = style;
        }
+      Scalar alignment = get_property ("textalignment");
+      if (alignment.isnum_b())
+       {
+         td_p->align_dir_= (Direction)(int)alignment;
+       }
       
       lyric_item_p_ =  new Text_item (td_p);
 
index 4b9ec9fd2f86a2891a145c40231b29ca0d6ff51c..5df3722a0a5997cdab847897f6fe7670ba5bb84a 100644 (file)
@@ -1112,7 +1112,7 @@ script_req:
 gen_script_def:
        text_def        { 
                $$ = $1;
-               ((Text_def*) $$)->align_dir_ = CENTER; /* UGH */
+               ((Text_def*) $$)->align_dir_ = LEFT; /* UGH */
        }
        | mudela_script { 
                $$ = $1;
index 435e312729ed365241da483aa725374fca0c64c1..671ca17e38f425cfb13c26ecb41aea0f3bca7efa 100644 (file)
@@ -69,6 +69,11 @@ Script_engraver::do_pre_move_processing()
            {
              td_l->style_str_= style;
            }
+         Scalar alignment = get_property ("textalignment");
+         if (alignment.isnum_b())
+           {
+             td_l->align_dir_= (Direction)(int)alignment;
+           }
        }
       typeset_element (script_p);
     }
index b0dbaf5611c667eea0e2d1163dfa3908603f71a2..6c1664017b558d6fefcf0ccc7db90981bde7829d 100644 (file)
@@ -12,6 +12,7 @@
 #include "molecule.hh"
 #include "text-def.hh"
 #include "dimension.hh"
+#include <ctype.h>
 
 Direction
 Text_def::staff_dir () const
@@ -21,16 +22,29 @@ Text_def::staff_dir () const
   return DOWN;
 }
 
+Real
+Text_def::guess_width_f(Atom& a) const
+{
+  // Count each TeX command as one character, ugh
+  int index, length=0;
+  int total_length=text_str_.length_i();
+  const char* str=text_str_.ch_C();
+  for (index=0;index<total_length;index++) {
+    length++;
+    if (str[index]=='\\')
+      for (index++;(index < total_length) && isalpha(str[index]);index++)
+       ;
+  }
+  return length * a.dim_.x ().length (); // ugh
+}
+
 Interval
 Text_def::width (Paper_def * p) const
 {
   Atom a = get_atom (p,CENTER);
 
-  /* TODO: check string for \texcommand
-   */
 
-  Real guess_width_f = text_str_.length_i() * a.dim_.x ().length (); // ugh
-  Interval i (0, guess_width_f);
+  Interval i (0, guess_width_f(a));
   i += - (align_dir_ + 1)* i.center();
   return i;
 }
@@ -62,8 +76,7 @@ Text_def::get_atom (Paper_def *p, Direction) const
 {
   Atom a= p->lookup_l(0)->text (style_str_, text_str_);
 
-  Real guess_width_f = text_str_.length_i() * a.dim_.x ().length (); // ugh
-  a.translate_axis (-(align_dir_ + 1)* guess_width_f/ 2, X_AXIS);
+  a.translate_axis (-(align_dir_ + 1)* guess_width_f (a) / 2, X_AXIS);
   
   return a;
 }