Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Delta Between Two Patch Sets: scm/music-functions.scm

Issue 6730044: Issue 2445: Add measure counter to LilyPond Base URL: http://git.savannah.gnu.org/gitweb/?p=lilypond.git/trunk/
Left Patch Set: fix for broken measures Created 12 years, 5 months ago
Right Patch Set: fixes based on David's review Created 12 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 ;;;; This file is part of LilyPond, the GNU music typesetter. 1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;; 2 ;;;;
3 ;;;; Copyright (C) 1998--2012 Jan Nieuwenhuizen <janneke@gnu.org> 3 ;;;; Copyright (C) 1998--2012 Jan Nieuwenhuizen <janneke@gnu.org>
4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl> 4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
5 ;;;; 5 ;;;;
6 ;;;; LilyPond is free software: you can redistribute it and/or modify 6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by 7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or 8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version. 9 ;;;; (at your option) any later version.
10 ;;;; 10 ;;;;
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 (if (pair? es) 377 (if (pair? es)
378 (set! (ly:music-property music 'elements) 378 (set! (ly:music-property music 'elements)
379 (map unfold-repeats es))) 379 (map unfold-repeats es)))
380 (if (ly:music? e) 380 (if (ly:music? e)
381 (set! (ly:music-property music 'element) 381 (set! (ly:music-property music 'element)
382 (unfold-repeats e))) 382 (unfold-repeats e)))
383 music)) 383 music))
384 384
385 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 385 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
386 ;; property setting music objs. 386 ;; property setting music objs.
387
388 (define-safe-public (check-grob-path path #:optional parser location
389 #:key
390 (start 0)
391 default
392 (min 1)
393 max)
394 "Check a grob path specification @var{path}, a symbol list (or a
395 single symbol), for validity and possibly complete it. Returns the
396 completed specification, or @code{#f} if invalid. If optional
397 @var{parser} is given, a syntax error is raised in that case,
398 optionally using @var{location}. If an optional keyword argument
399 @code{#:start @var{start}} is given, the parsing starts at the given
400 index in the sequence @samp{Context.Grob.property.sub-property...},
401 with the default of @samp{0} implying the full path.
402
403 If there is no valid first element of @var{path} fitting at the given
404 path location, an optionally given @code{#:default @var{default}} is
405 used as the respective element instead without checking it for
406 validity at this position.
407
408 The resulting path after possibly prepending @var{default} can be
409 constrained in length by optional arguments @code{#:min @var{min}} and
410 @code{#:max @var{max}}, defaulting to @samp{1} and unlimited,
411 respectively."
412 (let ((path (if (symbol? path) (list path) path)))
413 ;; A Guile 1.x bug specific to optargs precludes moving the
414 ;; defines out of the let
415 (define (unspecial? s)
416 (not (or (object-property s 'is-grob?)
417 (object-property s 'backend-type?))))
418 (define (grob? s)
419 (object-property s 'is-grob?))
420 (define (property? s)
421 (object-property s 'backend-type?))
422 (define (check c p) (c p))
423
424 (let* ((checkers
425 (and (< start 3)
426 (drop (list unspecial? grob? property?) start)))
427 (res
428 (cond
429 ((null? path)
430 ;; tricky. Should we make use of the default when the
431 ;; list is empty? In most cases, this question should be
432 ;; academical as an empty list can only be generated by
433 ;; Scheme and is likely an error. We consider this a case
434 ;; of "no valid first element, and default given".
435 ;; Usually, invalid use cases should be caught later using
436 ;; the #:min argument, and if the user explicitly does not
437 ;; catch this, we just follow through.
438 (if default (list default) '()))
439 ((not checkers)
440 ;; no checkers, so we have a valid first element and just
441 ;; take the path as-is.
442 path)
443 (default
444 (if ((car checkers) (car path))
445 (and (every check (cdr checkers) (cdr path))
446 path)
447 (and (every check (cdr checkers) path)
448 (cons default path))))
449 (else
450 (and (every check checkers path)
451 path)))))
452 (if (and res
453 (if max (<= min (length res) max)
454 (<= min (length res))))
455 res
456 (begin
457 (if parser
458 (ly:parser-error parser
459 (format #f (_ "bad grob property path ~a")
460 path)
461 location))
462 #f)))))
387 463
388 (define-public (make-grob-property-set grob gprop val) 464 (define-public (make-grob-property-set grob gprop val)
389 "Make a @code{Music} expression that sets @var{gprop} to @var{val} in 465 "Make a @code{Music} expression that sets @var{gprop} to @var{val} in
390 @var{grob}. Does a pop first, i.e., this is not an override." 466 @var{grob}. Does a pop first, i.e., this is not an override."
391 (make-music 'OverrideProperty 467 (make-music 'OverrideProperty
392 'symbol grob 468 'symbol grob
393 'grob-property gprop 469 'grob-property gprop
394 'grob-value val 470 'grob-value val
395 'pop-first #t)) 471 'pop-first #t))
396 472
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 (num (ly:stencil-aligned-to num X (ly:grob-property grob 'self-alignmen t-X))) 2010 (num (ly:stencil-aligned-to num X (ly:grob-property grob 'self-alignmen t-X)))
1935 (num 2011 (num
1936 (ly:stencil-translate-axis 2012 (ly:stencil-translate-axis
1937 num 2013 num
1938 (+ (interval-length break-alignment-L-ext) 2014 (+ (interval-length break-alignment-L-ext)
1939 (* 0.5 2015 (* 0.5
1940 (- (car break-alignment-R-ext) 2016 (- (car break-alignment-R-ext)
1941 (cdr break-alignment-L-ext)))) 2017 (cdr break-alignment-L-ext))))
1942 X))) 2018 X)))
1943 num)) 2019 num))
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b