Stencil close
= font->find_by_name ("accidentals.rightparen");
- m.add_at_edge (X_AXIS, LEFT, Stencil (open), 0, 0);
- m.add_at_edge (X_AXIS, RIGHT, Stencil (close), 0, 0);
+ m.add_at_edge (X_AXIS, LEFT, Stencil (open), 0);
+ m.add_at_edge (X_AXIS, RIGHT, Stencil (close), 0);
return m;
}
if (acc.is_empty ())
me->warning (_ ("natural alteration glyph not found"));
else
- mol.add_at_edge (X_AXIS, LEFT, acc, 0.1, 0);
+ mol.add_at_edge (X_AXIS, LEFT, acc, 0.1);
}
if (to_boolean (me->get_property ("parenthesized")))
for (Real y = heads[LEFT]; y < heads[RIGHT];
y += squiggle.extent (Y_AXIS).length ())
- mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0, 0);
+ mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0);
mol.translate_axis (heads[LEFT], Y_AXIS);
if (dir)
- mol.add_at_edge (Y_AXIS, dir, arrow, 0, 0);
+ mol.add_at_edge (Y_AXIS, dir, arrow, 0);
return mol.smobbed_copy ();
}
return thin;
else if (str == "|." || (h == 0 && str == ":|"))
{
- 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, thick, 0);
+ m.add_at_edge (X_AXIS, LEFT, thin, kern);
}
else if (str == ".|" || (h == 0 && str == "|:"))
{
- 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, thick, 0);
+ m.add_at_edge (X_AXIS, RIGHT, thin, kern);
}
else if (str == ":|")
{
- 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);
+ 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);
}
else if (str == "|:")
{
- 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);
+ 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);
}
else if (str == ":|:")
{
- 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);
+ 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);
}
else if (str == ".|.")
{
- m.add_at_edge (X_AXIS, LEFT, thick, thinkern, 0);
- m.add_at_edge (X_AXIS, RIGHT, thick, kern, 0);
+ m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
+ m.add_at_edge (X_AXIS, RIGHT, thick, kern);
}
else if (str == "||")
{
should align to other side? this never appears
on the system-start?
*/
- m.add_at_edge (X_AXIS, RIGHT, thin, 0, 0);
- m.add_at_edge (X_AXIS, RIGHT, thin, thinkern, 0);
+ m.add_at_edge (X_AXIS, RIGHT, thin, 0);
+ m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);
}
else if (str == ":")
{
(me->layout ()->self_scm (), properties, quant_score));
if (!score.is_empty ())
- the_beam.add_at_edge (Y_AXIS, stem_dir, score, 1.0, 0);
+ the_beam.add_at_edge (Y_AXIS, stem_dir, score, 1.0);
}
#endif
for (int i = scm_to_int (c); i--;)
{
d.translate_axis (2 * dw, X_AXIS);
- mol.add_at_edge (X_AXIS, RIGHT, d, dw, 0);
+ mol.add_at_edge (X_AXIS, RIGHT, d, dw);
}
}
return mol.smobbed_copy ();
don't add another circle the hairpin is broken
*/
if (!broken[tip_dir])
- mol.add_at_edge (X_AXIS, tip_dir, Stencil (circle), 0, 0);
+ mol.add_at_edge (X_AXIS, tip_dir, Stencil (circle), 0);
}
mol.translate_axis (x_points[LEFT]
*/
class Stencil
{
- /*
- This provides the reference point of the symbol, for example with
- characters, it is on the base line of the character. Usually,
- ORIGIN is inside DIM_
- */
- Offset origin_;
Box dim_;
SCM expr_;
Stencil (Box, SCM s);
Stencil ();
- Offset origin () const;
SCM expr () const;
/**
Set dimensions to empty, or to (Interval (0, 0), Interval (0, 0) */
void set_empty (bool);
- Stencil moved_to_edge (Axis a, Direction d, const Stencil &m, Real padding,
- Real minimum) const;
-
- void add_at_edge (Axis a, Direction d, const Stencil &m, Real padding,
- Real minimum);
+ void add_at_edge (Axis a, Direction d, const Stencil &m, Real padding);
void add_stencil (Stencil const &m);
void translate (Offset);
Stencil translated (Offset) const;
&& last_pos > pos - 6)
padding = 0.3;
- mol.add_at_edge (X_AXIS, LEFT, acc, padding, 0);
+ mol.add_at_edge (X_AXIS, LEFT, acc, padding);
last_pos = pos;
}
}
Stencil mol;
do
- mol.add_at_edge (X_AXIS, RIGHT, m, 0, 0);
+ mol.add_at_edge (X_AXIS, RIGHT, m, 0);
while (m.extent (X_AXIS).length ()
&& mol.extent (X_AXIS).length ()
+ m.extent (X_AXIS).length () < dz[X_AXIS])
Stencil m = Lookup::round_filled_box (b, blot);
Stencil yb = Lookup::round_filled_box (Box (Interval (-0.5, 0.5) * ythick, Interval (-ss, ss)), blot);
- m.add_at_edge (X_AXIS, RIGHT, yb, 0, 0);
- m.add_at_edge (X_AXIS, LEFT, yb, 0, 0);
+ m.add_at_edge (X_AXIS, RIGHT, yb, 0);
+ m.add_at_edge (X_AXIS, LEFT, yb, 0);
m.align_to (X_AXIS, LEFT);
Stencil mol;
for (SCM s = mols; scm_is_pair (s); s = scm_cdr (s))
mol.add_at_edge (X_AXIS, LEFT, *unsmob_stencil (scm_car (s)),
- inner_padding, 0);
+ inner_padding);
mol.align_to (X_AXIS, LEFT);
mol.translate_axis (outer_padding_factor * inner_padding, X_AXIS);
properties,
ly_string2scm (when));
Stencil t = *unsmob_stencil (scm_mol);
- t.add_at_edge (Y_AXIS, DOWN, *unsmob_stencil (when_mol), 0.1, 0.1);
+ t.add_at_edge (Y_AXIS, DOWN, *unsmob_stencil (when_mol), 0.1);
t.align_to (X_AXIS, CENTER);
t.align_to (Y_AXIS, DOWN);
Stencil s = brew_slash (me);
for (int i = count; i--;)
- m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern, 0);
+ m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern);
Stencil d1 = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
Stencil 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, 0);
- m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern, 0);
+ m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern);
+ m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern);
return m;
}
Stencil tm = *unsmob_stencil (Text_interface::interpret_markup
(me->layout ()->self_scm (), properties,
quant_score));
- a.add_at_edge (Y_AXIS, get_grob_direction (me), tm, 1.0, 0);
+ a.add_at_edge (Y_AXIS, get_grob_direction (me), tm, 1.0);
}
#endif
return scm_from_bool (s->is_empty ());
}
-LY_DEFINE (ly_stencil_origin, "ly:stencil-origin",
- 2, 0, 0, (SCM stil, SCM axis),
- "Return a pair of numbers signifying the origin @var{stil} in "
- "@var{axis} direction (0 or 1 for x and y axis respectively).")
-{
- Stencil *s = unsmob_stencil (stil);
- SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil");
- SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
-
- return scm_from_double (s->origin ()[Axis (scm_to_int (axis))]);
-}
-
-LY_DEFINE (ly_stencil_moved_to_edge, "ly:stencil-moved-to-edge",
- 4, 2, 0, (SCM first, SCM axis, SCM direction, SCM second,
- SCM padding, SCM minimum),
- "Similar to @code{ly:stencil-combine-edge}, but returns "
- "@var{second} positioned to be next to @var{first}. ")
-{
- /*
- C&P from combine-at-edge.
-
- fixme: just used once.
- */
- Stencil *s1 = unsmob_stencil (first);
- Stencil *s2 = unsmob_stencil (second);
- Stencil first_stencil;
-
- SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
- SCM_ASSERT_TYPE (is_direction (direction), direction, SCM_ARG4, __FUNCTION__, "dir");
-
- Real p = 0.0;
- if (padding != SCM_UNDEFINED)
- {
- SCM_ASSERT_TYPE (scm_is_number (padding), padding, SCM_ARG5, __FUNCTION__, "number");
- p = scm_to_double (padding);
- }
- Real m = 0.0;
- if (minimum != SCM_UNDEFINED)
- {
- SCM_ASSERT_TYPE (scm_is_number (minimum), minimum, SCM_ARG6, __FUNCTION__, "number");
- m = scm_to_double (minimum);
- }
-
- if (s1)
- first_stencil = *s1;
-
- if (s2)
- return first_stencil.moved_to_edge (Axis (scm_to_int (axis)),
- Direction (scm_to_int (direction)),
- *s2, p, m).smobbed_copy ();
- else
- return Stencil ().smobbed_copy ();
-}
-
LY_DEFINE (ly_stencil_combine_at_edge, "ly:stencil-combine-at-edge",
4, 2, 0, (SCM first, SCM axis, SCM direction,
SCM second,
if (s2)
result.add_at_edge (Axis (scm_to_int (axis)),
- Direction (scm_to_int (direction)), *s2, p, m);
+ Direction (scm_to_int (direction)), *s2, p);
return result.smobbed_copy ();
}
{
return dim_;
}
-Offset
-Stencil::origin () const
-{
- return origin_;
-}
/*
* Rotate this stencil around the point [x, y]
expr_, SCM_UNDEFINED);
if (!is_empty ())
dim_.translate (o);
- origin_ += o;
}
void
translate_axis (-i.linear_combination (x), a);
}
-/* FIXME: unintuitive naming, you would expect *this to be moved.
- Kept (keeping?) API for compat with add_at_edge ().
-
- What is PADDING, what is MINIMUM, exactly? */
-Stencil
-Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s,
- Real padding, Real minimum) const
+/* See scheme Function. */
+void
+Stencil::add_at_edge (Axis a, Direction d, Stencil const &s, Real padding)
{
Interval my_extent = dim_[a];
Interval i (s.extent (a));
Stencil toadd (s);
toadd.translate_axis (offset, a);
-
- if (minimum > 0 && d * (-origin ()[a] + toadd.origin ()[a]) < minimum)
- toadd.translate_axis (-toadd.origin ()[a]
- + origin ()[a] + d * minimum, a);
-
- return toadd;
-}
-
-/* See scheme Function. */
-void
-Stencil::add_at_edge (Axis a, Direction d, Stencil const &s, Real padding,
- Real minimum)
-{
- add_stencil (moved_to_edge (a, d, s, padding, minimum));
+ add_stencil (toadd);
}
Stencil
idx += string (&text.c_str ()[i], 1);
Stencil m = Font_interface::get_default_font (e)->find_by_name (idx);
if (!m.is_empty ())
- mol.add_at_edge (X_AXIS, RIGHT, m, 0, 0);
+ mol.add_at_edge (X_AXIS, RIGHT, m, 0);
}
return mol.smobbed_copy ();
Stencil bracket = Lookup::filled_box (box);
Direction d = DOWN;
do
- bracket.add_at_edge (Y_AXIS, d, tips[d], -overlap, 0.0);
+ bracket.add_at_edge (Y_AXIS, d, tips[d], -overlap);
while (flip (&d) != DOWN);
bracket = Stencil (box, bracket.expr ());
Stencil m;
if (den)
{
- m.add_at_edge (Y_AXIS, UP, n, 0.0, 0);
- m.add_at_edge (Y_AXIS, DOWN, d, 0.0, 0);
+ m.add_at_edge (Y_AXIS, UP, n, 0.0);
+ m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
}
else
{
num.align_to (Y_AXIS, UP);
num.translate_axis (-0.5, Y_AXIS);
total.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
- - 1.0, 0);
+ - 1.0);
}
total.translate_axis (left, X_AXIS);
(let* ((m1 (interpret-markup layout props arg1))
(m2 (interpret-markup layout props arg2)))
- (ly:stencil-combine-at-edge m1 axis dir m2 0.0 0.0)
+ (ly:stencil-combine-at-edge m1 axis dir m2 0.0)
))
(define-builtin-markup-command (transparent layout props arg) (markup?)
(let ((th 0.1) ;; todo: take from GROB.
(m (interpret-markup layout props arg)))
(bracketify-stencil m Y th (* 2.5 th) th)))
-
-(define-builtin-markup-command (bracketed-y-column layout props indices args)
- (list? markup-list?)
- "Make a column of the markups in @var{args}, putting brackets around
-the elements marked in @var{indices}, which is a list of numbers.
-
-"
-;;
-;; DROPME? This command is a relic from the old figured bass implementation.
-;;
-
- (define (sublist lst start stop)
- (take (drop lst start) (- (1+ stop) start)))
-
- (define (stencil-list-extent ss axis)
- (cons
- (apply min (map (lambda (x) (car (ly:stencil-extent x axis))) ss))
- (apply max (map (lambda (x) (cdr (ly:stencil-extent x axis))) ss))))
-
-
- (define (stack-stencils-vertically stencils bskip last-stencil)
- (cond
- ((null? stencils) '())
- ((not (ly:stencil? last-stencil))
- (cons (car stencils)
- (stack-stencils-vertically (cdr stencils) bskip (car stencils))))
- (else
- (let* ((orig (car stencils))
- (dir (chain-assoc-get 'direction props DOWN))
- (new (ly:stencil-moved-to-edge last-stencil Y dir
- orig
- 0.1 bskip)))
-
- (cons new (stack-stencils-vertically (cdr stencils) bskip new))))))
-
- (define (make-brackets stencils indices acc)
- (if (and stencils
- (pair? indices)
- (pair? (cdr indices)))
- (let* ((encl (sublist stencils (car indices) (cadr indices)))
- (x-ext (stencil-list-extent encl X))
- (y-ext (stencil-list-extent encl Y))
- (thick 0.10)
- (pad 0.35)
- (protusion (* 2.5 thick))
- (lb
- (ly:stencil-translate-axis
- (ly:bracket Y y-ext thick protusion)
- (- (car x-ext) pad) X))
- (rb (ly:stencil-translate-axis
- (ly:bracket Y y-ext thick (- protusion))
- (+ (cdr x-ext) pad) X)))
-
- (make-brackets
- stencils (cddr indices)
- (append
- (list lb rb)
- acc)))
- acc))
-
- (let* ((stencils
- (map (lambda (x)
- (interpret-markup
- layout
- props
- x)) args))
- (leading
- (chain-assoc-get 'baseline-skip props))
- (stacked (stack-stencils-vertically
- (remove ly:stencil-empty? stencils) 1.25 #f))
- (brackets (make-brackets stacked indices '())))
-
- (apply ly:stencil-add
- (append stacked brackets))))
\f
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(ly:stencil-combine-at-edge
(draw-strings (- string-count 1) fret-range th size) X RIGHT
string-stencil
- gap 0))))
+ gap))))
(define (draw-fret-lines fret-count string-count th size)
- "Draw @var{fret-count} frets (horizontal lines) for a fret diagram
+ "Draw @var{fret-count} frets (horizontal lines) for a fret diagram
with @var{string-count} strings. Line thickness is given by @var{th},
fret & string spacing by @var{size}. "
- (let* ((fret-length (* (- string-count 1) size))
- (sth (* size th))
- (half-thickness (* sth 0.5))
- (gap (- size sth))
- (fret-line (ly:make-stencil (list 'draw-line sth half-thickness size (- fret-length half-thickness) size)
- (cons 0 fret-length)
- (cons (- size half-thickness) (+ size half-thickness)))))
- (if (= fret-count 1)
- fret-line
- (ly:stencil-combine-at-edge fret-line Y UP
- (draw-fret-lines (- fret-count 1) string-count th size)
- gap 0))))
-
+ (let* ((fret-length (* (- string-count 1) size))
+ (sth (* size th))
+ (half-thickness (* sth 0.5))
+ (gap (- size sth))
+ (fret-line (ly:make-stencil (list 'draw-line sth half-thickness size (- fret-length half-thickness) size)
+ (cons 0 fret-length)
+ (cons (- size half-thickness) (+ size half-thickness)))))
+ (if (= fret-count 1)
+ fret-line
+ (ly:stencil-combine-at-edge fret-line Y UP
+ (draw-fret-lines (- fret-count 1) string-count th size)
+ gap))))
+
(define (draw-thick-top-fret props string-count th size)
- "Draw a thick top fret for a fret diagram whose base fret is not 1."
- (let* ((sth (* th size))
-; (top-fret-thick (* sth (chain-assoc-get 'top-fret-thickness props 3.0)))
- (top-fret-thick (* sth 3.0))
-; (top-half-thick (* top-fret-thick 0.5))
- (half-thick (* sth 0.5))
- (x1 half-thick)
- (x2 (+ half-thick (* size (- string-count 1))))
- (y1 (- half-thick))
- (y2 (+ top-fret-thick half-thick))
- (x-extent (cons (- x1) x2))
- (y-extent (cons 0 y2)))
- (ly:make-stencil (list 'round-filled-box x1 x2 y1 y2 sth)
- x-extent y-extent)))
-
-
+ "Draw a thick top fret for a fret diagram whose base fret is not 1."
+ (let* ((sth (* th size))
+ ; (top-fret-thick (* sth (chain-assoc-get 'top-fret-thickness props 3.0)))
+ (top-fret-thick (* sth 3.0))
+ ; (top-half-thick (* top-fret-thick 0.5))
+ (half-thick (* sth 0.5))
+ (x1 half-thick)
+ (x2 (+ half-thick (* size (- string-count 1))))
+ (y1 (- half-thick))
+ (y2 (+ top-fret-thick half-thick))
+ (x-extent (cons (- x1) x2))
+ (y-extent (cons 0 y2)))
+ (ly:make-stencil (list 'round-filled-box x1 x2 y1 y2 sth)
+ x-extent y-extent)))
+
+
(define (draw-frets layout props fret-range string-count th size)
- "Draw the frets (horizontal lines) for a fret diagram with
+ "Draw the frets (horizontal lines) for a fret diagram with
@var{string-count} strings and frets as indicated in @var{fret-range}.
Line thickness is given by @var{th}, fret & string spacing by
@var{size}. "
(fret-length (* (- string-count 1) size))
(half-thickness (* th 0.5))
(base-fret (car fret-range)))
- (ly:stencil-combine-at-edge
- (draw-fret-lines fret-count string-count th size) Y UP
- (if (= base-fret 1)
- (draw-thick-top-fret props string-count th size)
- (draw-fret-lines 1 string-count th size))
- (- size th) 0)))
-
+ (ly:stencil-combine-at-edge
+ (draw-fret-lines fret-count string-count th size) Y UP
+ (if (= base-fret 1)
+ (draw-thick-top-fret props string-count th size)
+ (draw-fret-lines 1 string-count th size))
+ (- size th))))
+
(define (draw-dots layout props string-count fret-range size finger-code
dot-position dot-radius dot-thickness dot-list)
(if (not (null? xo-list))
(set! fret-diagram-stencil (ly:stencil-combine-at-edge
fret-diagram-stencil Y UP
- (draw-xo layout props string-count fret-range size xo-list) xo-padding 0)))
+ (draw-xo layout props string-count fret-range size xo-list) xo-padding)))
(if (> (car fret-range) 1)
(set! fret-diagram-stencil
(ly:stencil-combine-at-edge fret-diagram-stencil X label-dir
- (label-fret layout props string-count fret-range size) label-space 0)))
+ (label-fret layout props string-count fret-range size) label-space)))
(ly:stencil-aligned-to fret-diagram-stencil X alignment)
))
(set! head-stencil
(ly:stencil-combine-at-edge
stencil Y dir head-stencil
- sep 0.0))
+ sep))
;; add arrow markers
ly:stencil-combine-at-edge
ly:stencil-expr
ly:stencil-extent
- ly:stencil-moved-to-edge
ly:stencil-translate
ly:stencil-translate-axis
ly:stencil?
(set! annotation
(center-stencil-on-extent text-stencil))
(set! annotation
- (ly:stencil-combine-at-edge arrows X RIGHT annotation 0.5 0))
+ (ly:stencil-combine-at-edge arrows X RIGHT annotation 0.5))
(set! annotation
(ly:stencil-combine-at-edge annotation X LEFT
(center-stencil-on-extent dim-stencil)
- 0.5 0))
+ 0.5))
(set! annotation
(ly:make-stencil (list 'color color (ly:stencil-expr annotation))
(ly:stencil-extent annotation X)