summaryrefslogtreecommitdiff
path: root/lily
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@xs4all.nl>2002-12-07 12:40:50 +0000
committerHan-Wen Nienhuys <hanwen@xs4all.nl>2002-12-07 12:40:50 +0000
commitd7be2ca7f331d94c9525bb0658f7e767c5e39230 (patch)
treec01c03496312ef2063db106ddf8844ad6c5c43fd /lily
parent4e743ebfc914a45b270fe2a93ee5789eae78be26 (diff)
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
Diffstat (limited to 'lily')
-rw-r--r--lily/accidental.cc6
-rw-r--r--lily/ambitus.cc4
-rw-r--r--lily/arpeggio.cc4
-rw-r--r--lily/bar-line.cc37
-rw-r--r--lily/beam.cc2
-rw-r--r--lily/break-align-interface.cc32
-rw-r--r--lily/chord-name.cc2
-rw-r--r--lily/dots.cc2
-rw-r--r--lily/font-metric.cc15
-rw-r--r--lily/include/molecule.hh3
-rw-r--r--lily/key-signature-interface.cc6
-rw-r--r--lily/lexer.ll4
-rw-r--r--lily/line-spanner.cc2
-rw-r--r--lily/lookup.cc2
-rw-r--r--lily/molecule-scheme.cc200
-rw-r--r--lily/molecule.cc169
-rw-r--r--lily/multi-measure-rest.cc6
-rw-r--r--lily/percent-repeat-item.cc6
-rw-r--r--lily/spanner.cc13
-rw-r--r--lily/sustain-pedal.cc2
-rw-r--r--lily/text-item.cc2
-rw-r--r--lily/text-spanner.cc8
-rw-r--r--lily/time-signature.cc4
-rw-r--r--lily/volta-bracket.cc2
24 files changed, 294 insertions, 239 deletions
diff --git a/lily/accidental.cc b/lily/accidental.cc
index 11f0a0184c..cbbbec7f2c 100644
--- a/lily/accidental.cc
+++ b/lily/accidental.cc
@@ -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);
}
}
diff --git a/lily/ambitus.cc b/lily/ambitus.cc
index 35c7fcc30d..5ecf59a459 100644
--- a/lily/ambitus.cc
+++ b/lily/ambitus.cc
@@ -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);
}
}
diff --git a/lily/arpeggio.cc b/lily/arpeggio.cc
index 8944cc61be..0d3531f6b2 100644
--- a/lily/arpeggio.cc
+++ b/lily/arpeggio.cc
@@ -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 () ;
}
diff --git a/lily/bar-line.cc b/lily/bar-line.cc
index 717da932c1..5fa03b00ac 100644
--- a/lily/bar-line.cc
+++ b/lily/bar-line.cc
@@ -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)
{
diff --git a/lily/beam.cc b/lily/beam.cc
index 8498264468..c675c0c052 100644
--- a/lily/beam.cc
+++ b/lily/beam.cc
@@ -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
diff --git a/lily/break-align-interface.cc b/lily/break-align-interface.cc
index 8b1ccce998..7913212244 100644
--- a/lily/break-align-interface.cc
+++ b/lily/break-align-interface.cc
@@ -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",
diff --git a/lily/chord-name.cc b/lily/chord-name.cc
index 861121054d..97c69f02e8 100644
--- a/lily/chord-name.cc
+++ b/lily/chord-name.cc
@@ -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 ();
diff --git a/lily/dots.cc b/lily/dots.cc
index c048131e6a..8654c627b0 100644
--- a/lily/dots.cc
+++ b/lily/dots.cc
@@ -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 ();
diff --git a/lily/font-metric.cc b/lily/font-metric.cc
index c3374a4b02..93592ee4cf 100644
--- a/lily/font-metric.cc
+++ b/lily/font-metric.cc
@@ -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
diff --git a/lily/include/molecule.hh b/lily/include/molecule.hh
index a1b887066f..8397851713 100644
--- a/lily/include/molecule.hh
+++ b/lily/include/molecule.hh
@@ -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);
diff --git a/lily/key-signature-interface.cc b/lily/key-signature-interface.cc
index 76bf41d2b0..b4d78d20a0 100644
--- a/lily/key-signature-interface.cc
+++ b/lily/key-signature-interface.cc
@@ -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);
}
}
}
diff --git a/lily/lexer.ll b/lily/lexer.ll
index c78ee41cb6..e9ea32de7b 100644
--- a/lily/lexer.ll
+++ b/lily/lexer.ll
@@ -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"))
diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc
index 2ea7b57c64..fad5b35251 100644
--- a/lily/line-spanner.cc
+++ b/lily/line-spanner.cc
@@ -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);
diff --git a/lily/lookup.cc b/lily/lookup.cc
index 1783f95467..db0b033658 100644
--- a/lily/lookup.cc
+++ b/lily/lookup.cc
@@ -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
index 0000000000..353b9a589d
--- /dev/null
+++ b/lily/molecule-scheme.cc
@@ -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;
+}
diff --git a/lily/molecule.cc b/lily/molecule.cc
index 9e63f4ba3a..8560aaef1d 100644
--- a/lily/molecule.cc
+++ b/lily/molecule.cc
@@ -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;
-}
-
/*
diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc
index e50e73b20f..3f946fe9ab 100644
--- a/lily/multi-measure-rest.cc
+++ b/lily/multi-measure-rest.cc
@@ -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);
diff --git a/lily/percent-repeat-item.cc b/lily/percent-repeat-item.cc
index 47b2199270..cff3824d82 100644
--- a/lily/percent-repeat-item.cc
+++ b/lily/percent-repeat-item.cc
@@ -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;
}
diff --git a/lily/spanner.cc b/lily/spanner.cc
index bc2d9bdd12..21562baff7 100644
--- a/lily/spanner.cc
+++ b/lily/spanner.cc
@@ -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");
diff --git a/lily/sustain-pedal.cc b/lily/sustain-pedal.cc
index c679e55ed0..07061ea01c 100644
--- a/lily/sustain-pedal.cc
+++ b/lily/sustain-pedal.cc
@@ -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 ();
diff --git a/lily/text-item.cc b/lily/text-item.cc
index 47a7426c27..c1a63c94c3 100644
--- a/lily/text-item.cc
+++ b/lily/text-item.cc
@@ -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 ();
}
diff --git a/lily/text-spanner.cc b/lily/text-spanner.cc
index 8a7efdc6d3..78eed39b67 100644
--- a/lily/text-spanner.cc
+++ b/lily/text-spanner.cc
@@ -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 ();
diff --git a/lily/time-signature.cc b/lily/time-signature.cc
index 35da64f305..af1e98ca0f 100644
--- a/lily/time-signature.cc
+++ b/lily/time-signature.cc
@@ -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
{
diff --git a/lily/volta-bracket.cc b/lily/volta-bracket.cc
index 4bfc990130..56dbc877f2 100644
--- a/lily/volta-bracket.cc
+++ b/lily/volta-bracket.cc
@@ -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 ();
}