2005-03-29 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/stencil-scheme.cc (LY_DEFINE): change to
+ ly:stencil-aligned-to, non mutating.
+
+ * scm/safe-lily.scm (lambda): remove ly:stencil-set-extent!
+
+ * lily/stencil-scheme.cc: remove ly:stencil-set-extent!
+
* lily/quote-iterator.cc (derived_mark): call
Music_wrapper_iterator::derived_mark() too.
+++ /dev/null
-
-\version "2.5.2"
-
-\header { texidoc=" You can write stencil callbacks in Scheme, thus
-providing custom glyphs for notation elements. A simple example is
-adding parentheses to existing stencil callbacks.
-
-The parenthesized beam is less successful due to implementation of the
-Beam. The note head is also rather naive, since the extent of the
-parens are also not seen by accidentals.
-"
-
-}
-
-#(define (parenthesize-callback callback)
- "Construct a function that will do CALLBACK and add parentheses.
-Example usage:
-
- \\property NoteHead \\override #'print-function
- =
- #(parenthesize-callback Note_head::print)
-
-"
-
-
- (define (parenthesize-stencil grob)
- "This function adds parentheses to the original callback for
-GROB. The dimensions of the stencil is not affected.
-"
-
- (let* ((fn (ly:get-default-font grob))
- (pclose (ly:font-get-glyph fn "accidentals.rightparen"))
- (popen (ly:font-get-glyph fn "accidentals.leftparen"))
- (subject (callback grob))
-
- ; remember old size
- (subject-dim-x (ly:stencil-extent subject 0))
- (subject-dim-y (ly:stencil-extent subject 1)))
-
- ; add parens
- (set! subject
- (ly:stencil-combine-at-edge
- (ly:stencil-combine-at-edge subject 0 1 pclose 0.2)
- 0 -1 popen 0.2))
-
- ; revert old size.
- (ly:stencil-set-extent! subject 0 subject-dim-x)
- (ly:stencil-set-extent! subject 1 subject-dim-y)
- subject))
- parenthesize-stencil)
-
-
-\layout { raggedright = ##t }
-\relative c' {
- c4 e
-
- \override NoteHead #'print-function
- =
- #(parenthesize-callback Note_head::print)
- g bes
- \revert NoteHead #'print-function
- \override Beam #'print-function
- =
- #(parenthesize-callback Beam::print)
-
- a8 gis8 a2.
-
-}
-
-
-
*/
#include "music-wrapper-iterator.hh"
-
#include "music-wrapper.hh"
Music_wrapper_iterator::Music_wrapper_iterator ()
/*
TODO: naming add/combine.
*/
-/*
- UGH. Junk all mutators.
-*/
-LY_DEFINE (ly_stencil_set_extent_x, "ly:stencil-set-extent!",
- 3, 0, 0, (SCM stil, SCM axis, SCM np),
- "Set the extent of @var{stil} "
- "(@var{extent} must be a pair of numbers) "
- "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");
- SCM_ASSERT_TYPE (is_number_pair (np), np, SCM_ARG3, __FUNCTION__,
- "number pair");
-
- Interval iv = ly_scm2interval (np);
- s->dim_[Axis (scm_to_int (axis))] = iv;
-
- return SCM_UNSPECIFIED;
-}
LY_DEFINE (ly_translate_stencil_axis, "ly:stencil-translate-axis",
3, 0, 0, (SCM stil, SCM amount, SCM axis),
return s.smobbed_copy ();
}
-LY_DEFINE (ly_stencil_align_to_x, "ly:stencil-align-to!",
+LY_DEFINE (ly_stencil_aligned_to, "ly:stencil-aligned-to",
3, 0, 0, (SCM stil, SCM axis, SCM dir),
"Align @var{stil} using its own extents. "
"@var{dir} is a number -1, 1 are left and right respectively. "
- "Other values are interpolated (so 0 means the center. ")
+ "Other values are interpolated (so 0 means the center).")
{
SCM_ASSERT_TYPE (unsmob_stencil (stil), stil, SCM_ARG1, __FUNCTION__, "stencil");
SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
SCM_ASSERT_TYPE (scm_is_number (dir), dir, SCM_ARG3, __FUNCTION__, "number");
- unsmob_stencil (stil)->align_to ((Axis)scm_to_int (axis),
- scm_to_double (dir));
- return stil;
+ Stencil target = *unsmob_stencil (stil);
+
+ target.align_to ((Axis)scm_to_int (axis),
+ scm_to_double (dir));
+ return target.smobbed_copy ();
}
LY_DEFINE (ly_stencil_fonts, "ly:stencil-fonts",
%% Toplevel initialisation file.
+% switch on debugging.
+#(if (and #t (defined? 'set-debug-cell-accesses!))
+ (set-debug-cell-accesses! 5000))
+
#(define-public midi-debug #f)
#(define $globalheader #f)
#(define version-seen? #f)
-#(if (defined? 'set-debug-cell-accesses!) (set-debug-cell-accesses 5000))
-
\maininput
%% there is a problem at the end of the input file
(begin
(ly:warn "No systems found in \\score markup. Did you forget \\layout?")
empty-markup)
- (begin
- (let* ((stencil (ly:paper-system-stencil (vector-ref systems 0))))
-
- (ly:stencil-align-to! stencil Y CENTER)
- stencil)))))
+ (let* ((stencil (ly:paper-system-stencil (vector-ref systems 0))))
+
+ (ly:stencil-aligned-to stencil Y CENTER)
+ ))))
(def-markup-command (simple layout props str) (string?)
"A simple text string; @code{\\markup @{ foo @}} is equivalent with
(def-markup-command (center-align layout props args) (markup-list?)
"Put @code{args} in a centered column. "
(let* ((mols (map (lambda (x) (interpret-markup layout props x)) args))
- (cmols (map (lambda (x) (ly:stencil-align-to! x X CENTER)) mols)))
+ (cmols (map (lambda (x) (ly:stencil-aligned-to x X CENTER)) mols)))
(stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) cmols)))
(def-markup-command (vcenter layout props arg) (markup?)
"Align @code{arg} to its Y center. "
(let* ((mol (interpret-markup layout props arg)))
- (ly:stencil-align-to! mol Y CENTER)
- mol))
+ (ly:stencil-aligned-to mol Y CENTER)
+ ))
(def-markup-command (hcenter layout props arg) (markup?)
"Align @code{arg} to its X center. "
(let* ((mol (interpret-markup layout props arg)))
- (ly:stencil-align-to! mol X CENTER)
- mol))
+ (ly:stencil-aligned-to mol X CENTER)))
(def-markup-command (right-align layout props arg) (markup?)
"Align @var{arg} on its right edge. "
(let* ((m (interpret-markup layout props arg)))
- (ly:stencil-align-to! m X RIGHT)
- m))
+ (ly:stencil-aligned-to m X RIGHT)))
(def-markup-command (left-align layout props arg) (markup?)
"Align @var{arg} on its left edge. "
(let* ((m (interpret-markup layout props arg)))
- (ly:stencil-align-to! m X LEFT)
- m))
+ (ly:stencil-aligned-to m X LEFT)))
(def-markup-command (general-align layout props axis dir arg) (integer? number? markup?)
"Align @var{arg} in @var{axis} direction to the @var{dir} side."
(let* ((m (interpret-markup layout props arg)))
- (ly:stencil-align-to! m axis dir)
- m))
+ (ly:stencil-aligned-to m axis dir)))
(def-markup-command (halign layout props dir arg) (number? markup?)
"Set horizontal alignment. If @var{dir} is @code{-1}, then it is
left-aligned, while @code{+1} is right. Values in between interpolate
alignment accordingly."
(let* ((m (interpret-markup layout props arg)))
- (ly:stencil-align-to! m X dir)
- m))
+ (ly:stencil-aligned-to m X dir)))
(def-markup-command (musicglyph layout props glyph-name) (string?)
"This is converted to a musical symbol, e.g. @code{\\musicglyph
"Make a fraction of two markups."
(let* ((m1 (interpret-markup layout props arg1))
(m2 (interpret-markup layout props arg2)))
- (ly:stencil-align-to! m1 X CENTER)
- (ly:stencil-align-to! m2 X CENTER)
+ (set! m1 (ly:stencil-aligned-to m1 X CENTER))
+ (set! m2 (ly:stencil-aligned-to m2 X CENTER))
(let* ((x1 (ly:stencil-extent m1 X))
(x2 (ly:stencil-extent m2 X))
(line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
;; should stack mols separately, to maintain LINE on baseline
(stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
- (ly:stencil-align-to! stack Y CENTER)
- (ly:stencil-align-to! stack X LEFT)
+ (set! stack
+ (ly:stencil-aligned-to stack Y CENTER))
+ (set! stack
+ (ly:stencil-aligned-to stack X LEFT))
;; should have EX dimension
;; empirical anyway
(ly:stencil-translate-axis stack 0.75 Y))))
(def-markup-command (strut layout props) ()
"Create a box of the same height as the space in the current font."
(let ((m (Text_interface::interpret_markup layout props " ")))
- (ly:stencil-set-extent! m X '(1000 . -1000))
- m))
+ (ly:make-stencil (ly:stencil-expr m)
+ (ly:stencil-extent m X)
+ '(1000 . -1000))))
(define number->mark-letter-vector (make-vector 25 #\A))
(- size th) 0)))
-(define (centered-stencil stencil)
- "Center stencil @var{stencil} in both the X and Y directions"
- (let* ((output-stencil stencil))
-; (if (= (cadr (ly:version)) 3)
- (begin
- (ly:stencil-align-to! output-stencil Y 0)
- (ly:stencil-align-to! output-stencil X 0)
- output-stencil)))
-; (ly:stencil-align-to (ly:stencil-align-to text-stencil X 0) Y 0))))
-
(define (draw-dots layout props string-count fret-range size finger-code dot-position dot-radius dot-list)
"Make dots for fret diagram."
(let* ((scale-dot-radius (* size dot-radius))
(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)))
- (ly:stencil-align-to! fret-diagram-stencil X alignment)
- fret-diagram-stencil))
+ (ly:stencil-aligned-to fret-diagram-stencil X alignment)
+ ))
(def-markup-command (fret-diagram layout props definition-string)
(string?)
(let ((x (/ (- (cdr (ly:stencil-extent slur 0))
(/ (cdr (ly:stencil-extent text 0)) 2.0))
-2.0)))
-
- (ly:stencil-set-extent! text 0 (cons x x))
- (ly:stencil-align-to! text 0 1)))))
-
-;; (ly:stencil-combine-at-edge slur 1 1 text -0.6)
+ (set! text
+ (ly:make-stencil (ly:stencil-expr text)
+ (cons x x)
+ (ly:stencil-extent text Y)))
+
+ (ly:stencil-aligned-to text X RIGHT)))))
(define-public guitar-tuning '(4 -1 -5 -10 -15 -20))
(text-stencil
(Text_interface::interpret_markup layout props text)))
- (ly:stencil-align-to! text-stencil X CENTER)
- (ly:stencil-align-to! text-stencil Y CENTER)
- (ly:stencil-add text-stencil circle)
+
+ (ly:stencil-add
+ (centered-stencil text-stencil)
+ circle)
))
ly:spanner-get-bound
ly:spanner?
ly:stencil-add
- ly:stencil-align-to!
+ ly:stencil-aligned-to
ly:stencil-combine-at-edge
ly:stencil-expr
ly:stencil-extent
ly:stencil-moved-to-edge
- ly:stencil-set-extent!
ly:stencil-translate
ly:stencil-translate-axis
ly:stencil?
(car stils) axis dir (stack-stencils-padding-list axis dir (cdr padding) (cdr stils))
(car padding)))))
+(define-public (centered-stencil stencil)
+ "Center stencil @var{stencil} in both the X and Y directions"
+
+ (ly:stencil-aligned-to
+ (ly:stencil-aligned-to stencil X CENTER)
+ Y CENTER))
+
(define-public (stack-lines dir padding baseline stils)
"Stack vertically with a baseline-skip."
(if (null? stils)
'\\encoding: smart recode latin1..utf-8. Remove ly:point-and-click'))
+def conv (str):
+ if re.search ("ly:stencil-set-extent!", str):
+ sys.stderr.write ('\n')
+ sys.stderr.write (NOT_SMART % "ly:stencil-set-extent!")
+ sys.stderr.write ('\n')
+ sys.stderr.write ('use (set! VAR (ly:make-stencil (ly:stencil-expr VAR) X-EXT Y-EXT))\n')
+ raise FatalConversionError ()
+ return str
+
+conversions.append (((2, 5, 17),
+ conv,
+ 'ly:stencil-set-extent! removed'))
+
+
################################
# END OF CONVERSIONS
################################