]> git.donarmstrong.com Git - lilypond.git/commitdiff
2002-12-06 Han-Wen Nienhuys <hanwen@cs.uu.nl>
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 7 Dec 2002 12:40:50 +0000 (12:40 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 7 Dec 2002 12:40:50 +0000 (12:40 +0000)
* lily/molecule-scheme.cc: move scheme functions to separate file.

* lily/font-metric.cc  (ly_get_glyph): new function.

* scm/new-markup.scm (column-markup): use baseline-skip for columns.
(italic-markup, dynamic-markup): new functions
(font-markup): new function

* lily/molecule.cc (ly_molecule_combined_at_edge): optional
padding and minimum

30 files changed:
ChangeLog
input/regression/new-markup-syntax.ly
lily/accidental.cc
lily/ambitus.cc
lily/arpeggio.cc
lily/bar-line.cc
lily/beam.cc
lily/break-align-interface.cc
lily/chord-name.cc
lily/dots.cc
lily/font-metric.cc
lily/include/molecule.hh
lily/key-signature-interface.cc
lily/lexer.ll
lily/line-spanner.cc
lily/lookup.cc
lily/molecule-scheme.cc [new file with mode: 0644]
lily/molecule.cc
lily/multi-measure-rest.cc
lily/percent-repeat-item.cc
lily/spanner.cc
lily/sustain-pedal.cc
lily/text-item.cc
lily/text-spanner.cc
lily/time-signature.cc
lily/volta-bracket.cc
ly/params-init.ly
scm/molecule.scm
scm/new-markup.scm
scm/tex.scm

index 6f4381a337d787fa39afe3add50065ef81f580ec..7478c88c9c6da6a20df6d03fde18ecaabda936b1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2002-12-06  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * lily/molecule-scheme.cc: move scheme functions to separate file.
+
+       * lily/font-metric.cc  (ly_get_glyph): new function. 
+       
+       * scm/new-markup.scm (column-markup): use baseline-skip for columns.
+       (italic-markup, dynamic-markup): new functions
+       (font-markup): new function
+
+       * lily/molecule.cc (ly_molecule_combined_at_edge): optional
+       padding and minimum
+
 2002-12-07  Rune Zedeler  <rz@daimi.au.dk>
 
        * lily/accidental-engraver.cc:
@@ -23,6 +36,8 @@
 
 2002-12-05  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
+       * lily/molecule.cc (ly_translate_molecule): new function
+
        * python/GNUmakefile (INSTALLATION_DIR1): install Python module
        into libdir
 
index bd6725b3848f845e68f1d9622f9f3a12847868f2..5a71629707d36ee0121c78dc1fee473c8bf27048 100644 (file)
@@ -9,10 +9,17 @@ texidoc = "New markup syntax."
   \notes
    {
     \property Voice.TextScript \set #'molecule-callback = #brew-new-markup-molecule
-    f'-\markup { foo \bold bar \column < baz bazr >
-               \override #'(font-family . music) \lookup #"noteheads-0"
-       }
-
+    f'-\markup { foo
+               \raise #0.2 \bold bar
+               \column < baz bazr >
+               \hspace #2.0
+               \override #'(font-family . music) {
+                       \lookup #"noteheads-0"
+                       \char #53
+               }
+               \italic Norsk
+               \dynamic sfzp
+       }       
     c''4
     }
 }
index 11f0a0184c743a5d00489a8c1c7b661cc7fecf46..cbbbec7f2cade6daac4ffec37380a1d977f81d0a 100644 (file)
@@ -18,8 +18,8 @@ parenthesize (Grob*me, Molecule m)
 {
   Molecule open = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-leftparen"));
   Molecule close = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-rightparen"));
-  m.add_at_edge (X_AXIS, LEFT, Molecule (open), 0);
-  m.add_at_edge (X_AXIS, RIGHT, Molecule (close), 0);
+  m.add_at_edge (X_AXIS, LEFT, Molecule (open), 0,0);
+  m.add_at_edge (X_AXIS, RIGHT, Molecule (close), 0,0);
 
   return m;
 }
@@ -203,7 +203,7 @@ Accidental_interface::brew_molecule (SCM smob)
        }
       else
        {
-         mol.add_at_edge (X_AXIS,  RIGHT, acc, 0.1);
+         mol.add_at_edge (X_AXIS,  RIGHT, acc, 0.1,0);
        }
     }
 
index 35c7fcc30d5120a36d99aba5fe5c46167ad4615f..5ecf59a459c597368eebe9dda9de3459cf946f71 100644 (file)
@@ -108,7 +108,7 @@ add_accidentals (Item *me, Molecule *head, int num_acc,
                                         accidentals_style +
                                         to_string (pitch->alteration_)));
       accidental.translate_axis (yoffs, Y_AXIS);
-      head->add_at_edge (X_AXIS,  LEFT, accidental, 0.1);
+      head->add_at_edge (X_AXIS,  LEFT, accidental, 0.1, 0);
     }
   if (num_acc == 2)
     {
@@ -117,7 +117,7 @@ add_accidentals (Item *me, Molecule *head, int num_acc,
                                      accidentals_style +
                                      to_string ("0")));
       natural.translate_axis (yoffs, Y_AXIS);
-      head->add_at_edge (X_AXIS,  LEFT, natural, 0.1);
+      head->add_at_edge (X_AXIS,  LEFT, natural, 0.1, 0);
     }
 }
 
index 8944cc61bef5e1fb79cfb803154e12da4e87538b..0d3531f6b26ef68b13a0c86af8523c2bba4bb3d2 100644 (file)
@@ -78,13 +78,13 @@ Arpeggio::brew_molecule (SCM smob)
   Real y = heads[LEFT];
   while (y < heads[RIGHT] - arrow_space)
     {
-      mol.add_at_edge (Y_AXIS, UP,squiggle, 0.0);
+      mol.add_at_edge (Y_AXIS, UP,squiggle, 0.0, 0);
       y+= squiggle. extent (Y_AXIS).length ();
     }
   mol.translate_axis (heads[LEFT], Y_AXIS);
   if (dir)
     mol.add_at_edge (Y_AXIS, dir,
-                    fm->find_by_name ("scripts-arpeggio-arrow-" + to_string (dir)), 0.0);
+                    fm->find_by_name ("scripts-arpeggio-arrow-" + to_string (dir)), 0.0, 0);
   
   return mol.smobbed_copy () ;
 }
index 717da932c181a846cf7db819fcbd92f0eab9ee09..5fa03b00ac4a613639e6375e3a81ede66703be8a 100644 (file)
@@ -84,48 +84,47 @@ Bar_line::compound_barline (Grob*me, String str, Real h)
     }
   else if (str == "|." || (h == 0 && str == ":|"))
     {
-      m.add_at_edge (X_AXIS, LEFT, thick, 0);      
-      m.add_at_edge (X_AXIS, LEFT, thin, kern);
+      m.add_at_edge (X_AXIS, LEFT, thick, 0, 0);      
+      m.add_at_edge (X_AXIS, LEFT, thin, kern,0 );
     }
   else if (str == ".|" || (h == 0 && str == "|:"))
     {
-      m.add_at_edge (X_AXIS, RIGHT, thick, 0);
-      m.add_at_edge (X_AXIS, RIGHT, thin, kern);
+      m.add_at_edge (X_AXIS, RIGHT, thick, 0, 0);
+      m.add_at_edge (X_AXIS, RIGHT, thin, kern, 0);
     }
   else if (str == ":|")
     {
-      m.add_at_edge (X_AXIS, LEFT, thick, 0);
-      m.add_at_edge (X_AXIS, LEFT, thin, kern);
-      m.add_at_edge (X_AXIS, LEFT, colon, kern);      
+      m.add_at_edge (X_AXIS, LEFT, thick, 0, 0);
+      m.add_at_edge (X_AXIS, LEFT, thin, kern, 0);
+      m.add_at_edge (X_AXIS, LEFT, colon, kern, 0);      
     }
   else if (str == "|:")
     {
-      m.add_at_edge (X_AXIS, RIGHT, thick, 0);
-      m.add_at_edge (X_AXIS, RIGHT, thin, kern);
-      m.add_at_edge (X_AXIS, RIGHT, colon, kern);      
+      m.add_at_edge (X_AXIS, RIGHT, thick, 0, 0);
+      m.add_at_edge (X_AXIS, RIGHT, thin, kern, 0);
+      m.add_at_edge (X_AXIS, RIGHT, colon, kern, 0);      
     }
   else if (str == ":|:")
     {
-      m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
-      m.add_at_edge (X_AXIS, LEFT, colon, kern);      
-      m.add_at_edge (X_AXIS, RIGHT, thick, kern);
-      m.add_at_edge (X_AXIS, RIGHT, colon, kern);      
+      m.add_at_edge (X_AXIS, LEFT, thick, thinkern, 0);
+      m.add_at_edge (X_AXIS, LEFT, colon, kern, 0);
+      m.add_at_edge (X_AXIS, RIGHT, thick, kern, 0);
+      m.add_at_edge (X_AXIS, RIGHT, colon, kern, 0);      
     }
   else if (str == ".|.")
     {
-      m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
-      m.add_at_edge (X_AXIS, RIGHT, thick, kern);      
+      m.add_at_edge (X_AXIS, LEFT, thick, thinkern, 0);
+      m.add_at_edge (X_AXIS, RIGHT, thick, kern, 0);
     }
   else if (str == "||")
     {
-      m.add_at_edge (X_AXIS, RIGHT, thin, 0);
-      m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);      
+      m.add_at_edge (X_AXIS, RIGHT, thin, 0, 0);
+      m.add_at_edge (X_AXIS, RIGHT, thin, thinkern, 0);
     }
 
   return m;
 }
 
-
 Molecule
 Bar_line::simple_barline (Grob*,Real w, Real h) 
 {
index 849826446834a8ac5337e67af890c922b30df372..c675c0c05276330e151c6514d5676e25be5260f2 100644 (file)
@@ -475,7 +475,7 @@ Beam::brew_molecule (SCM grob)
 
       
       Molecule tm = Text_item::text2molecule (me, scm_makfrom0str (str.to_str0 ()), properties);
-      the_beam.add_at_edge (Y_AXIS, UP, tm, 5.0);
+      the_beam.add_at_edge (Y_AXIS, UP, tm, 5.0, 0);
     }
 #endif
     
index 8b1ccce998aaf4a76bf9db38d4d801bd717871e9..7913212244ba12624895e48aa0a602c4d89ee19d 100644 (file)
@@ -231,23 +231,21 @@ Break_align_interface::do_alignment (Grob *me)
 
 
 ADD_INTERFACE (Break_aligned_interface, "break-aligned-interface",
-  "Items that are aligned in prefatory matter.
-
-The spacing of these items is controlled by the space-alist
-property. It contains a list break-align-symbols with a specification
-of the associated space. The space definition is either (extra-space
-. @var{number}), which adds space after the symbol, (minimum-space
-. @var{ms}), which pads the space until it it is @var{ms}.
-
-
-Special keys for the alist are 'first-note and 'next-note, signifyign
-the first note on a line, and the next note halfway a line.
-
-Rules for this spacing are much more complicated than this. 
-See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147
-
-
-",
+              //
+"Items that are aligned in prefatory matter.\n"
+"\n"
+"The spacing of these items is controlled by the space-alist\n"
+"property. It contains a list break-align-symbols with a specification\n"
+"of the associated space. The space definition is either (extra-space\n"
+". @var{number}), which adds space after the symbol, (minimum-space\n"
+". @var{ms}), which pads the space until it it is @var{ms}.\n"
+"\n"
+"\n"
+"Special keys for the alist are 'first-note and 'next-note, signifyign\n"
+"the first note on a line, and the next note halfway a line.\n"
+"\n"
+"Rules for this spacing are much more complicated than this. \n"
+"See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147\n",
   "break-align-symbol break-alignment-done space-alist");
 
 ADD_INTERFACE (Break_align_interface, "break-alignment-interface",
index 861121054df05bce1c88df576e7d190f94498295..97c69f02e8bce44cf8817b1f512437237752a62c 100644 (file)
@@ -56,7 +56,7 @@ Chord_name::brew_molecule (SCM smob)
       Molecule m;
       m.set_empty (false);
       mol.add_at_edge (X_AXIS, RIGHT, m, gh_scm2double (space)*
-                      Staff_symbol_referencer::staff_space (me));
+                      Staff_symbol_referencer::staff_space (me), 0);
     }
 
   return mol.smobbed_copy ();
index c048131e6a655304837d3c1b8a20417873a2bdd0..8654c627b00c7be1189e213e5d9e8360a98f1ec7 100644 (file)
@@ -66,7 +66,7 @@ Dots::brew_molecule (SCM d)
       for (int i = gh_scm2int (c); i--;)
        {
          d.translate_axis (2*dw,X_AXIS);
-         mol.add_at_edge (X_AXIS, RIGHT, d, dw);
+         mol.add_at_edge (X_AXIS, RIGHT, d, dw, 0);
        }
     }
   return mol.smobbed_copy ();
index c3374a4b026b95ad5e86dad31117f724c44c5c68..93592ee4cf0285f5fbc5e23f431f6b3fa792f991 100644 (file)
@@ -156,6 +156,17 @@ LY_DEFINE(ly_find_glyph_by_name, "ly:find-glyph-by-name", 2 , 0, 0,
   return fm->find_by_name (ly_scm2string (name)).smobbed_copy ();
 }
 
+LY_DEFINE(ly_get_glyph, "ly:get-glyph", 2 , 0, 0,
+         (SCM font, SCM index),
+         "This function retrieves a Molecule for the glyph numbered @var{index} in "
+"@var{font}. ")
+{
+  Font_metric *fm = unsmob_metrics (font);
+  SCM_ASSERT_TYPE(fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
+  SCM_ASSERT_TYPE(gh_number_p (index), index, SCM_ARG2, __FUNCTION__, "number");
+
+  return fm->get_char_molecule (gh_scm2int (index)).smobbed_copy ();
+}
 
 LY_DEFINE(ly_text_dimension,"ly:text-dimension", 2 , 0, 0,
          (SCM font, SCM text),
@@ -172,10 +183,6 @@ LY_DEFINE(ly_text_dimension,"ly:text-dimension", 2 , 0, 0,
   
   return gh_cons (ly_interval2scm (b[X_AXIS]), ly_interval2scm(b[Y_AXIS]));
 }
-
-
-
-
   
 Molecule
 Font_metric::get_char_molecule (int code)  const
index a1b887066f840c23c0d782e9324bdebc887a0436..8397851713f364c6af82ca1173756ab94ba79b83 100644 (file)
@@ -58,7 +58,8 @@ public:
   /**
      Set dimensions to empty, or to (Interval (0,0),Interval (0,0) */
   void set_empty (bool);
-  void add_at_edge (Axis a, Direction d, const Molecule &m, Real padding);
+  void add_at_edge (Axis a, Direction d, const Molecule &m, Real padding,
+                   Real minimum);
   void add_molecule (Molecule const &m);
   void translate (Offset);
   
index 76bf41d2b0468b9ac766c8163bb25a71cbda6ff6..b4d78d20a0dc3d6bb6b48fa4ea1b77f9e9c1e223 100644 (file)
@@ -141,7 +141,7 @@ Key_signature_interface::brew_molecule (SCM smob)
          SCM what = ly_caar (s);
          int pos = alteration_pos (what, alteration, c0p);
          acc.translate_axis (pos * inter, Y_AXIS);
-         mol.add_at_edge (X_AXIS, LEFT, acc, 0);
+         mol.add_at_edge (X_AXIS, LEFT, acc, 0, 0);
        }
     }
 
@@ -158,7 +158,7 @@ Key_signature_interface::brew_molecule (SCM smob)
       Interval x (0, inter);
       Interval y (0,0);
 
-      mol.add_at_edge (X_AXIS, LEFT, Lookup::blank (Box (x,y)),0);
+      mol.add_at_edge (X_AXIS, LEFT, Lookup::blank (Box (x,y)), 0, 0);
 
       Molecule natural;
       if (gh_pair_p (old))
@@ -184,7 +184,7 @@ Key_signature_interface::brew_molecule (SCM smob)
                needed to prevent collisions.
               */
              Real padding = 0.1 ;
-             mol.add_at_edge (X_AXIS, LEFT, m, padding);
+             mol.add_at_edge (X_AXIS, LEFT, m, padding, 0);
             }
         }
     }
index c78ee41cb6cdafbce2bf626bb92db31702ccd478..e9ea32de7b545dd3e99d00c182b20774c999cd3b 100644 (file)
@@ -135,7 +135,7 @@ HYPHEN              --
        // windows-suck-suck-suck
 }
 
-<INITIAL,chords,incl,lyrics,notes,figures>{
+<INITIAL,chords,incl,markup,lyrics,notes,figures>{
   "%{" {
        yy_push_state (longcomment);
   }
@@ -445,7 +445,7 @@ HYPHEN              --
                String str (YYText() + 1);
                SCM s = lookup_markup_command (str);
 
-               if (gh_pair_p (s)) {
+               if (gh_pair_p (s) && gh_symbol_p (gh_cdr (s)) ) {
                        yylval.scm = gh_car(s);
                        SCM tag = gh_cdr(s);
                        if (tag == ly_symbol2scm("markup0"))
index 2ea7b57c64e92cd0195e4ba28def412281a53e67..fad5b352513cb5f3d71048f3af2c2525caa5f1b6 100644 (file)
@@ -123,7 +123,7 @@ Line_spanner::line_molecule (Grob* me, Real thick, Real dx, Real dy)
                                                           SCM_UNDEFINED));
       Molecule m = fm->find_by_name ("scripts-trill-element");
       do
-       mol.add_at_edge (X_AXIS, RIGHT, m, 0);
+       mol.add_at_edge (X_AXIS, RIGHT, m, 0,0);
       while (m.extent (X_AXIS).length ()
             && mol.extent (X_AXIS).length ()
             + m.extent (X_AXIS).length () < dx);
index 1783f95467c40024f04cc64c5b79405b6978da3d..db0b03365890c9275a3ed7a7cfa7893551f699e1 100644 (file)
@@ -105,7 +105,7 @@ Lookup::line (Real th, Offset f, Offset t)
 Molecule
 Lookup::blank (Box b) 
 {
-  return Molecule (b, SCM_EOL);
+  return Molecule (b, scm_makfrom0str (""));
 }
 
 Molecule
diff --git a/lily/molecule-scheme.cc b/lily/molecule-scheme.cc
new file mode 100644 (file)
index 0000000..353b9a5
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+  molecule-scheme.cc -- implement Molecule
+
+  source file of the GNU LilyPond music typesetter
+
+  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include "molecule.hh"
+#include "font-metric.hh"
+
+LY_DEFINE(ly_set_molecule_extent_x,"ly:set-molecule-extent!", 3 , 0, 0, 
+         (SCM mol, SCM axis, SCM np),
+         "Set the extent (@var{extent} must be a pair of numbers) of @var{mol} in \n"
+"@var{axis} direction (0 or 1 for x- and y-axis respectively).\n"
+"\n"
+"Note that an extent @code{(A . B)} is an interval and hence @code{A} is\n"
+"smaller than @code{B}, and is often negative.\n"
+)
+{
+  Molecule* m = unsmob_molecule (mol);
+  SCM_ASSERT_TYPE (m, mol, SCM_ARG1, __FUNCTION__, "molecule");
+  SCM_ASSERT_TYPE (ly_axis_p (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
+  SCM_ASSERT_TYPE (ly_number_pair_p (np), np, SCM_ARG3, __FUNCTION__, "number pair");
+
+  Interval iv = ly_scm2interval (np);
+  m->dim_[Axis (gh_scm2int (axis))] = iv;
+
+  return SCM_UNDEFINED;
+}
+
+
+LY_DEFINE(ly_translate_molecule,"ly:molecule-translate-axis", 3, 0, 0, 
+         (SCM mol, SCM amount, SCM axis),
+         "Return a @var{mol}, but translated by @var{amount} in @var{axis} direction")
+{
+  Molecule* m = unsmob_molecule (mol);
+  SCM_ASSERT_TYPE (m, mol, SCM_ARG1, __FUNCTION__, "molecule");
+  SCM_ASSERT_TYPE (gh_number_p (amount), amount, SCM_ARG2, __FUNCTION__, "number pair");
+  SCM_ASSERT_TYPE (ly_axis_p (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+
+
+  Molecule q (*m);
+  q.translate_axis (gh_scm2double (amount), Axis (gh_scm2int (axis)));
+
+  return q.smobbed_copy();
+}
+
+LY_DEFINE(ly_get_molecule_extent,
+         "ly:get-molecule-extent", 2 , 0, 0,  (SCM mol, SCM axis),
+         "Return a pair of numbers signifying the extent of @var{mol} in "
+"@var{axis} direction (0 or 1 for x and y axis respectively)."
+)
+{
+  Molecule *m = unsmob_molecule (mol);
+  SCM_ASSERT_TYPE (m, mol, SCM_ARG1, __FUNCTION__, "molecule");
+  SCM_ASSERT_TYPE (ly_axis_p (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
+  return ly_interval2scm (m->extent (Axis (gh_scm2int (axis))));
+}
+
+
+LY_DEFINE(ly_molecule_combined_at_edge,
+         "ly:combine-molecule-at-edge",
+         4, 2, 0,  (SCM first, SCM axis, SCM direction,
+                    SCM second,
+                    SCM padding,
+                    SCM minimum),
+         "Construct a molecule by putting @var{second} next to "
+"@var{first}. @var{axis} can be 0 (x-axis) or 1 (y-axis), @var{direction} can be "
+"-1 (left or down) or 1 (right or up). "
+"The molecules are juxtaposed with  @var{padding} as extra space. If "
+"this puts the reference points closer than @var{minimum}, they are moved "
+"by the latter amount.")
+
+{
+  Molecule * m1 = unsmob_molecule (first);
+  Molecule * m2 = unsmob_molecule (second);
+  Molecule result;
+
+
+  SCM_ASSERT_TYPE(ly_axis_p (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+  SCM_ASSERT_TYPE(ly_dir_p (direction), direction, SCM_ARG4, __FUNCTION__, "dir");
+
+  Real p = 0.0;
+  if (padding != SCM_UNDEFINED)
+    {
+      SCM_ASSERT_TYPE(gh_number_p (padding), padding, SCM_ARG5, __FUNCTION__, "number");
+      p = gh_scm2double (padding);
+    }
+  Real m =0.0;
+  if (minimum != SCM_UNDEFINED)
+    {
+      SCM_ASSERT_TYPE(gh_number_p (minimum), minimum, SCM_ARG6, __FUNCTION__, "number");
+      m = gh_scm2double (minimum);
+    }
+  
+  if (m1)
+    result = *m1;
+  if (m2)
+    result.add_at_edge (Axis (gh_scm2int (axis)), Direction (gh_scm2int (direction)),
+                       *m2, p, m);
+
+  return result.smobbed_copy ();
+}
+
+/*
+  FIXME: support variable number of arguments "
+ */
+LY_DEFINE(ly_add_molecule , 
+         "ly:add-molecule", 2, 0, 0, (SCM first, SCM second),
+         "Combine two molecules."
+         )
+{
+  Molecule * m1 = unsmob_molecule (first);
+  Molecule * m2 = unsmob_molecule (second);
+  Molecule result;
+
+
+  if (m1)
+    result = *m1;
+  if (m2)
+    result.add_molecule (*m2);
+
+  return result.smobbed_copy ();
+}
+
+LY_DEFINE(ly_make_molecule,
+         "ly:make-molecule", 3, 0, 0,  (SCM expr, SCM xext, SCM yext),
+         " \n"
+"The objective of any typesetting system is to put ink on paper in the \n"
+"right places. For LilyPond, this final stage is left to the @TeX{} and \n"
+"the printer subsystem. For lily, the last stage in processing a score is \n"
+"outputting a description of what to put where.  This description roughly \n"
+"looks like \n"
+"@example \n"
+"        PUT glyph AT (x,y) \n"
+"        PUT glyph AT (x,y) \n"
+"        PUT glyph AT (x,y)  \n"
+"@end example \n"
+"you merely have to look at the tex output of lily to see this. \n"
+"Internally these instructions are encoded in Molecules.@footnote{At some \n"
+"point LilyPond also contained Atom-objects, but they have been replaced \n"
+"by Scheme expressions, making the name outdated.}  A molecule is \n"
+"what-to-print-where information that also contains dimension information \n"
+"(how large is this glyph?). \n"
+" \n"
+"Conceptually, Molecules can be constructed from Scheme code, by \n"
+"translating a Molecule and by combining two molecules. In BNF \n"
+"notation: \n"
+" \n"
+"@example \n"
+"Molecule  :: COMBINE Molecule Molecule \n"
+"           | TRANSLATE Offset Molecule \n"
+"           | GLYPH-DESCRIPTION \n"
+"           ; \n"
+"@end example \n"
+" \n"
+"If you are interested in seeing how this information is stored, you \n"
+"can run with the @code{-f scm} option. The scheme expressions are then \n"
+"dumped in the output file.")
+{
+  SCM_ASSERT_TYPE (ly_number_pair_p (xext), xext, SCM_ARG2, __FUNCTION__, "number pair");
+  SCM_ASSERT_TYPE (ly_number_pair_p (yext), yext, SCM_ARG3, __FUNCTION__, "number pair");  
+
+  Box b (ly_scm2interval (xext), ly_scm2interval(yext));
+  Molecule m (b, expr);
+  return m.smobbed_copy ();
+}
+
+
+SCM
+fontify_atom (Font_metric const * met, SCM f)
+{
+  if (f == SCM_EOL)
+    return f;
+  else
+    return  scm_list_n (ly_symbol2scm ("fontify"),
+                       ly_quote_scm (met->description_), f, SCM_UNDEFINED);
+}
+
+LY_DEFINE(ly_fontify_atom,"ly:fontify-atom", 2, 0, 0, 
+         (SCM met, SCM f),
+         "Add a font selection command for the font metric @var{met} to @var{f}.")
+{
+  SCM_ASSERT_TYPE(unsmob_metrics (met), met, SCM_ARG1, __FUNCTION__, "font metric");
+
+  return fontify_atom (unsmob_metrics (met), f);
+}
+LY_DEFINE(ly_align_to_x,"ly:align-to!", 3, 0, 0,  (SCM mol, SCM axis, SCM dir),
+         "Align @var{mol} using its own extents.")
+{
+  SCM_ASSERT_TYPE(unsmob_molecule (mol), mol, SCM_ARG1, __FUNCTION__, "molecule");
+  SCM_ASSERT_TYPE(ly_axis_p (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
+  SCM_ASSERT_TYPE(ly_dir_p (dir), dir, SCM_ARG3, __FUNCTION__, "dir");
+
+  unsmob_molecule (mol)->align_to ((Axis)gh_scm2int (axis), Direction (gh_scm2int (dir)));
+
+  return SCM_UNDEFINED;
+}
index 9e63f4ba3afce9d1b74dffa64ae010b96e2a9852..8560aaef1d3433489e42a426f4aa722ad2f67a37 100644 (file)
@@ -115,8 +115,12 @@ Molecule::align_to (Axis a, Direction d)
   translate_axis (-r, a);
 }
 
+/*
+  See scheme Function.
+ */
 void
-Molecule::add_at_edge (Axis a, Direction d, Molecule const &m, Real padding)
+Molecule::add_at_edge (Axis a, Direction d, Molecule const &m, Real padding,
+                      Real minimum)
 {
   Real my_extent= empty_b () ? 0.0 : dim_[a][d];
   Interval i (m.extent (a));
@@ -129,168 +133,15 @@ Molecule::add_at_edge (Axis a, Direction d, Molecule const &m, Real padding)
   else
     his_extent = i[-d];      
 
-  Real offset = my_extent -  his_extent;
+  Real offset = (my_extent -  his_extent)  + d*padding;
+  if (minimum > 0  && fabs (offset) <  minimum)
+    offset = sign (offset) * minimum; 
+  
   Molecule toadd (m);
-  toadd.translate_axis (offset + d * padding, a);
+  toadd.translate_axis (offset, a);
   add_molecule (toadd);
 }
 
-LY_DEFINE(ly_set_molecule_extent_x,"ly:set-molecule-extent!", 3 , 0, 0, 
-         (SCM mol, SCM axis, SCM np),
-         "Set the extent (@var{extent} must be a pair of numbers) of @var{mol} in \n"
-"@var{axis} direction (0 or 1 for x- and y-axis respectively).\n"
-"\n"
-"Note that an extent @code{(A . B)} is an interval and hence @code{A} is\n"
-"smaller than @code{B}, and is often negative.\n"
-)
-{
-  Molecule* m = unsmob_molecule (mol);
-  SCM_ASSERT_TYPE (m, mol, SCM_ARG1, __FUNCTION__, "molecule");
-  SCM_ASSERT_TYPE (ly_axis_p (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
-  SCM_ASSERT_TYPE (ly_number_pair_p (np), np, SCM_ARG3, __FUNCTION__, "number pair");
-
-  Interval iv = ly_scm2interval (np);
-  m->dim_[Axis (gh_scm2int (axis))] = iv;
-
-  return SCM_UNDEFINED;
-}
-
-LY_DEFINE(ly_get_molecule_extent,
-         "ly:get-molecule-extent", 2 , 0, 0,  (SCM mol, SCM axis),
-         "Return a pair of numbers signifying the extent of @var{mol} in "
-"@var{axis} direction (0 or 1 for x and y axis respectively)."
-)
-{
-  Molecule *m = unsmob_molecule (mol);
-  SCM_ASSERT_TYPE (m, mol, SCM_ARG1, __FUNCTION__, "molecule");
-  SCM_ASSERT_TYPE (ly_axis_p (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
-  return ly_interval2scm (m->extent (Axis (gh_scm2int (axis))));
-}
-
-
-LY_DEFINE(ly_molecule_combined_at_edge,
-         "ly:combine-molecule-at-edge",
-         5 , 0, 0,  (SCM first, SCM axis, SCM direction,
-                     SCM second, SCM padding),
-         "Construct a molecule by putting @var{second} next to "
-"@var{first}. @var{axis} can be 0 (x-axis) or 1 (y-axis), @var{direction} can be "
-"-1 (left or down) or 1 (right or up).  @var{padding} specifies extra "
-"space to add in between measured in global staff space.")
-
-{
-  Molecule * m1 = unsmob_molecule (first);
-  Molecule * m2 = unsmob_molecule (second);
-  Molecule result;
-
-
-  SCM_ASSERT_TYPE(ly_axis_p (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
-  SCM_ASSERT_TYPE(ly_dir_p (direction), direction, SCM_ARG3, __FUNCTION__, "dir");
-  SCM_ASSERT_TYPE(gh_number_p (padding), padding, SCM_ARG4, __FUNCTION__, "number");
-
-  if (m1)
-    result = *m1;
-  if (m2)
-    result.add_at_edge (Axis (gh_scm2int (axis)), Direction (gh_scm2int (direction)),
-                       *m2, gh_scm2double (padding));
-
-  return result.smobbed_copy ();
-}
-
-/*
-  FIXME: support variable number of arguments "
- */
-LY_DEFINE(ly_add_molecule , 
-         "ly:add-molecule", 2, 0,0,(SCM first, SCM second),
-         "Combine two molecules."
-         )
-{
-  Molecule * m1 = unsmob_molecule (first);
-  Molecule * m2 = unsmob_molecule (second);
-  Molecule result;
-
-
-  if (m1)
-    result = *m1;
-  if (m2)
-    result.add_molecule (*m2);
-
-  return result.smobbed_copy ();
-}
-
-LY_DEFINE(ly_make_molecule,
-         "ly:make-molecule", 3, 0, 0,  (SCM expr, SCM xext, SCM yext),
-         " \n"
-"The objective of any typesetting system is to put ink on paper in the \n"
-"right places. For LilyPond, this final stage is left to the @TeX{} and \n"
-"the printer subsystem. For lily, the last stage in processing a score is \n"
-"outputting a description of what to put where.  This description roughly \n"
-"looks like \n"
-"@example \n"
-"        PUT glyph AT (x,y) \n"
-"        PUT glyph AT (x,y) \n"
-"        PUT glyph AT (x,y)  \n"
-"@end example \n"
-"you merely have to look at the tex output of lily to see this. \n"
-"Internally these instructions are encoded in Molecules.@footnote{At some \n"
-"point LilyPond also contained Atom-objects, but they have been replaced \n"
-"by Scheme expressions, making the name outdated.}  A molecule is \n"
-"what-to-print-where information that also contains dimension information \n"
-"(how large is this glyph?). \n"
-" \n"
-"Conceptually, Molecules can be constructed from Scheme code, by \n"
-"translating a Molecule and by combining two molecules. In BNF \n"
-"notation: \n"
-" \n"
-"@example \n"
-"Molecule  :: COMBINE Molecule Molecule \n"
-"           | TRANSLATE Offset Molecule \n"
-"           | GLYPH-DESCRIPTION \n"
-"           ; \n"
-"@end example \n"
-" \n"
-"If you are interested in seeing how this information is stored, you \n"
-"can run with the @code{-f scm} option. The scheme expressions are then \n"
-"dumped in the output file.")
-{
-  SCM_ASSERT_TYPE (ly_number_pair_p (xext), xext, SCM_ARG2, __FUNCTION__, "number pair");
-  SCM_ASSERT_TYPE (ly_number_pair_p (yext), yext, SCM_ARG3, __FUNCTION__, "number pair");  
-
-  Box b (ly_scm2interval (xext), ly_scm2interval(yext));
-  Molecule m (b, expr);
-  return m.smobbed_copy ();
-}
-
-SCM
-fontify_atom (Font_metric const * met, SCM f)
-{
-  if (f == SCM_EOL)
-    return f;
-  else
-    return  scm_list_n (ly_symbol2scm ("fontify"),
-                       ly_quote_scm (met->description_), f, SCM_UNDEFINED);
-}
-
-LY_DEFINE(ly_fontify_atom,"ly:fontify-atom", 2, 0, 0, 
-         (SCM met, SCM f),
-         "Add a font selection command for the font metric @var{met} to @var{f}.")
-{
-  SCM_ASSERT_TYPE(unsmob_metrics (met), met, SCM_ARG1, __FUNCTION__, "font metric");
-
-  return fontify_atom (unsmob_metrics (met), f);
-}
-LY_DEFINE(ly_align_to_x,"ly:align-to!", 3, 0, 0,  (SCM mol, SCM axis, SCM dir),
-         "Align @var{mol} using its own extents.")
-{
-  SCM_ASSERT_TYPE(unsmob_molecule (mol), mol, SCM_ARG1, __FUNCTION__, "molecule");
-  SCM_ASSERT_TYPE(ly_axis_p (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
-  SCM_ASSERT_TYPE(ly_dir_p (dir), dir, SCM_ARG3, __FUNCTION__, "dir");
-
-  unsmob_molecule (mol)->align_to ((Axis)gh_scm2int (axis), Direction (gh_scm2int (dir)));
-
-  return SCM_UNDEFINED;
-}
-
 
 
 /*
index e50e73b20f510d27c6f97c64c111a60624445b68..3f946fe9ab4a6f96ecd45e48e19c847ce78405d6 100644 (file)
@@ -189,8 +189,8 @@ Multi_measure_rest::big_rest (Grob *me, Real width)
   Molecule m =  Lookup::filledbox (b);
   Molecule yb = Lookup::filledbox (Box (Interval (-0.5, 0.5)* ythick, Interval (-ss, ss)));
 
-  m.add_at_edge (X_AXIS, RIGHT, yb, 0);
-  m.add_at_edge (X_AXIS, LEFT, yb, 0);
+  m.add_at_edge (X_AXIS, RIGHT, yb, 0, 0);
+  m.add_at_edge (X_AXIS, LEFT, yb, 0, 0);
 
   m.align_to (X_AXIS, LEFT);
   
@@ -278,7 +278,7 @@ Multi_measure_rest::church_rest (Grob*me, Font_metric *musfont, int measures,
   Molecule mol; 
   for (SCM  s = mols; gh_pair_p (s); s = gh_cdr(s))
     {
-      mol.add_at_edge (X_AXIS, LEFT, *unsmob_molecule (gh_car (s)), inner_padding);
+      mol.add_at_edge (X_AXIS, LEFT, *unsmob_molecule (gh_car (s)), inner_padding, 0);
     }
   mol.align_to (X_AXIS, LEFT);
   mol.translate_axis (outer_padding_factor *  inner_padding, X_AXIS);
index 47b219927073c3d8e7b0e88c2dd811757f48c851..cff3824d8284ce342a95d23c87415daaf33af3e1 100644 (file)
@@ -44,15 +44,15 @@ Percent_repeat_item_interface::x_percent (Grob *me, int count,
 
   for (int i  = count; i--;)
     {
-      m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern);
+      m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern,0);
     }
   Molecule d1 = Font_interface::get_default_font (me)->find_by_name ("dots-dot");
   Molecule d2  =  d1;
   d1.translate_axis (0.5, Y_AXIS );
   d2.translate_axis (-0.5, Y_AXIS);
   
-  m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern);
-  m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern);
+  m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern,0);
+  m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern,0);
 
   return m;
 }
index bc2d9bdd12a8f4047cd911529342727903476587..21562baff74763b16a35c9013b2d5579723d84e4 100644 (file)
@@ -351,11 +351,10 @@ unsmob_spanner (SCM s )
 
 ADD_INTERFACE(Spanner,
              "spanner-interface",
-             "
-Other grobs have a shape that depends on the horizontal spacing. For
-example, slur, beam, tie, etc. These grobs form a subtype called
-@code{Spanner}. All spanners have two span-points (these must be
-@code{Item}s), one on the left and one on the right. The left bound is
-also the X-reference point of the spanner.
-",
+"Other grobs have a shape that depends on the horizontal spacing. For\n"
+"example, slur, beam, tie, etc. These grobs form a subtype called\n"
+"@code{Spanner}. All spanners have two span-points (these must be\n"
+"@code{Item}s), one on the left and one on the right. The left bound is\n"
+"also the X-reference point of the spanner.\n"
+,
              "minimum-length");
index c679e55ed00d24f82e583b5b80a436a775515218..07061ea01cd6dbabe73dbbd7636e44186e055de6 100644 (file)
@@ -58,7 +58,7 @@ Sustain_pedal::brew_molecule (SCM smob)
        idx += String (&text.to_bytes ()[i], 1);
       Molecule m = Font_interface::get_default_font (e)->find_by_name (idx);
       if (!m.empty_b ())
-       mol.add_at_edge (X_AXIS, RIGHT, m, 0);
+       mol.add_at_edge (X_AXIS, RIGHT, m, 0, 0);
     }
     
   return mol.smobbed_copy ();
index 47a7426c27cb0e07755fa8122c1f8e3fbaee71fb..c1a63c94c3b3e0c11a37df39046dee5ab6646c6f 100644 (file)
@@ -241,7 +241,7 @@ Text_item::brew_molecule (SCM smob)
       Molecule m;
       m.set_empty (false);
       mol.add_at_edge (X_AXIS, RIGHT, m, gh_scm2double (space)
-                      * Staff_symbol_referencer::staff_space (me));
+                      * Staff_symbol_referencer::staff_space (me), 0);
     }
   return mol.smobbed_copy (); 
 }
index 8a7efdc6d3b46f7cdb6f25516da3aa0d7aed5ce9..78eed39b679d832ff757f926fbc199b98339c142 100644 (file)
@@ -168,14 +168,14 @@ Text_spanner::brew_molecule (SCM smob)
     m = edge[LEFT];
 
   if (!edge_line[LEFT].empty_b ())
-    m.add_at_edge (X_AXIS, RIGHT, edge_line[LEFT], 0);
+    m.add_at_edge (X_AXIS, RIGHT, edge_line[LEFT], 0,0);
   if (!line.empty_b ())
     m.add_at_edge (X_AXIS, RIGHT, line,
-                  edge_line[LEFT].empty_b () ? 0 : -thick/2);
+                  edge_line[LEFT].empty_b () ? 0 : -thick/2, 0);
   if (!edge_line[RIGHT].empty_b ())
-    m.add_at_edge (X_AXIS, RIGHT, edge_line[RIGHT], -thick/2);
+    m.add_at_edge (X_AXIS, RIGHT, edge_line[RIGHT], -thick/2, 0);
   if (!edge[RIGHT].empty_b ())
-    m.add_at_edge (X_AXIS, RIGHT, edge[RIGHT], 0);
+    m.add_at_edge (X_AXIS, RIGHT, edge[RIGHT], 0, 0);
   m.translate_axis (broken_left + extra_off[LEFT] + shorten[LEFT], X_AXIS);
 
   return m.smobbed_copy ();
index 35da64f305d9f4bf49eef7b36c0e7293ac849d6c..af1e98ca0f82458286fb79255a64cdbfe4e439f8 100644 (file)
@@ -106,8 +106,8 @@ Time_signature::numbered_time_signature (Grob*me,int num, int den)
   Molecule m;
   if (den)
     {
-      m.add_at_edge (Y_AXIS, UP, n, 0.0);
-      m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
+      m.add_at_edge (Y_AXIS, UP, n, 0.0, 0);
+      m.add_at_edge (Y_AXIS, DOWN, d, 0.0,0);
     }
   else
     {
index 4bfc99013004a09c3d6334a1cc7fac05ff0a0269..56dbc877f23a0c407166f680926e10b7861a71fd 100644 (file)
@@ -109,7 +109,7 @@ Volta_bracket_interface::brew_molecule (SCM smob)
   Molecule num = Text_item::text2molecule (me, text, properties);
 
   mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
-                  - 1.0);
+                  - 1.0, 0);
   mol.translate_axis (left, X_AXIS);
   return mol.smobbed_copy ();
 }
index c92c7c81c22c341f7caa60406acce89f32b97402..555a5dd71bb4e815efd314b3a863778fd3c083e6 100644 (file)
@@ -52,11 +52,14 @@ interscoreline = 4. \mm
 \translator { \TabVoiceContext }
 
 
-
+%%
+%% TODO: baseline-skip should come from the font.
+%%
 #(define font-defaults
       '((font-family . music)
        (font-relative-size . 0)
        (font-shape . upright)
+       (baseline-skip . 2) 
        (font-series . medium)
        ))
 
index 1335e9af5a6a5dceac1379bcea50d2d5fea41360..0e3f21ecaa673c03b38d249ea69cc43d8704f683 100644 (file)
   ))
 
 
+(define-public (stack-lines dir padding baseline mols)
+  "Stack vertically with a baseline-skip."
+  (if (null? mols)
+      '()
+      (if (pair? mols)
+         (ly:combine-molecule-at-edge (car mols) Y dir 
+                                      (stack-lines Y dir padding (cdr mols))
+                                      padding baseline 
+                                      )
+         )
+  ))
 
 
 (define-public (fontify-text font-metric text)
index dcd7407d48da0604df5153b7fb2a46999886c1e3..4dfb2cbdb71c89217bfc9169228cef8ebacdb847 100644 (file)
 (define-public (combine-markup grob props . rest)
    (combine-molecule-list (map (lambda (x) (interpret-markup grob props x)) (car rest))))
 
-(define-public (bold-markup grob props . rest)
-   (interpret-markup grob (cons (cons '(font-series . bold) (car props)) (cdr props)) (car rest))
-  )
+(define (font-markup qualifier value)
+  (lambda (grob props . rest)
+    (interpret-markup grob (cons (cons `(,qualifier . ,value) (car props)) (cdr props)) (car rest))
+  
+  ))
+
+(define-public bold-markup
+  (font-markup 'font-series 'bold))
+(define-public dynamic-markup
+  (font-markup 'font-family 'dynamic))
+(define-public italic-markup
+  (font-markup 'font-shape 'italic))
 
 (define-public (column-markup grob props . rest)
-  (stack-molecules
-   Y -1 0.0 
+  (stack-lines
+   -1 0.0 (cdr (chain-assoc 'baseline-skip props))
    (map (lambda (x) (interpret-markup grob props x)) (car rest)))
   )
 
    (car rest))
   )
 
+(define-public (char-markup grob props . rest)
+  (ly:get-glyph  (ly:get-font grob props) (car rest))
+                
+  )
+(define-public (raise-markup grob props  . rest)
+  (ly:molecule-translate-axis (interpret-markup grob props (cadr rest))
+                             (car rest) Y)
+  )
+
+;; this is too simplistic: doesn't do backup for negative dimensions.
+(define (hspace-markup grob props . rest)
+  (ly:make-molecule "" (cons 0 (car rest)) '(-1 . 1) )
+  )
+
 (define-public (override-markup grob props . rest)
   "Tack the 1st args in REST onto PROPS."
   (interpret-markup grob (cons (list (car rest)) props)
           (cons music-markup 'scm0)
           (cons override-markup 'scm0-markup1)
           (cons lookup-markup 'scm0)
+          (cons raise-markup 'scm0-markup1)
+          (cons italic-markup 'markup0)
+          (cons dynamic-markup 'markup0)
+          (cons char-markup 'scm0)
+          (cons hspace-markup 'scm0)
+          
           ))
 
+
 (define markup-module (current-module))
 
 (define-public (lookup-markup-command code)
index af3470c02eed53d8a43f21d7acbcb4788b757ab8..378821ac6d716201339d6ea150fd6466c401e1bf 100644 (file)
@@ -81,6 +81,9 @@
     
     ))
 
+(define (blank)
+  "")
+
 (define (dot x y radius)
   (embedded-ps (list 'dot x y radius)))