From: Jan Nieuwenhuizen Date: Thu, 29 Apr 2004 14:49:53 +0000 (+0000) Subject: * lily/page.cc (Page): Do not use ly_scheme_function for X-Git-Tag: release/2.3.1~35 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c71533641f8c21ce2531314baba00886f04f259e;p=lilypond.git * lily/page.cc (Page): Do not use ly_scheme_function for volatile/configurable variables (FIXME: better name). * lily/music-output-def.cc (c_lookup_variable): Rename (WAS: get_scmvar). --- diff --git a/ChangeLog b/ChangeLog index db7b10c0c7..726541eb4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-04-29 Jan Nieuwenhuizen + + * lily/page.cc (Page): Do not use ly_scheme_function for + volatile/configurable variables (FIXME: better name). + + * lily/music-output-def.cc (c_lookup_variable): Rename (WAS: + get_scmvar). + 2004-04-29 Han-Wen Nienhuys * scripts/convert-ly.py (FatalConversionError.subst): use diff --git a/input/test/markup-score.ly b/input/test/markup-score.ly index 098201a324..049862a8d6 100644 --- a/input/test/markup-score.ly +++ b/input/test/markup-score.ly @@ -31,12 +31,12 @@ inBed = \paper { %% #(paper-set-staff-size (* 11.0 pt)) raggedright = ##t - linewidth = 40\mm + linewidth = 0\mm indent = 0 \mm - %% #(define page-to-stencil page-stack-lines) - #(define (page-to-stencil page) - (box-stencil (page-stack-lines page) 0.1 0.5)) + #(define page-to-stencil page-stack-lines) + %%#(define (page-to-stencil page) + %% (box-stencil (page-stack-lines page) 0.1 0.5)) \context { \StaffContext @@ -44,22 +44,70 @@ inBed = \paper { } } +noCruft = \paper { + \context { + \StaffContext + %% Hmm, no effect ? + %% \override StaffSymbol #'print-function = ##f + %% Clef = \turnOff + %% StaffSymbol = \turnOff + %% TimeSignature = \turnOff + \override Clef #'print-function = ##f + \override StaffSymbol #'line-count = #0 + \override TimeSignature #'print-function = ##f + } +} + +noCruftInBed = \paper { + \inBed + + %%\noCruft + %%URGHSr + \context { + \StaffContext + %% Hmm, no effect ? + %% \override StaffSymbol #'print-function = ##f + %% Clef = \turnOff + %% StaffSymbol = \turnOff + %% TimeSignature = \turnOff + \override Clef #'print-function = ##f + \override StaffSymbol #'line-count = #0 + \override TimeSignature #'print-function = ##f + } +} + +tuning = \markup { + \score { \notes { \clef bass 1 } \paper{ \inBed }} +} + +#(define-public (my-footer paper page-number) + (let ((props (page-properties paper))) + (interpret-markup paper props + (markup #:fill-line ( #:line ( "Tuning: " tuning) ""))))) + +tempoChange = \markup { + %% wtf, no horizontal shift? + "" %%\kern #-10 + \translate #'(-15 . 0) + \score { \notes \times 2/3 { c'8 c' c' } \paper { \noCruftInBed }} + " =" + \score { \notes { c'8[ c'] } \paper { \noCruftInBed } } +} + \header { - title = "title" - subtitle = \markup { \fill-line < - "subtitle with score: " - \score { \relative \notes { a'^"Hi" b c } \paper { \inBed } } - "woo!" - > } - subsubtitle = "subsubtitle" + title = "Solo Cello Suites" + subtitle = "Suite IV" + subsubtitle = \markup { \fill-line < { "Originalstimmung: " \tuning } > } +} + +\paper { + #(define make-footer my-footer) } \relative { - a' b c d \break - a b c d \break - %% interesting bug: - %%a b^\markup { \score{ \notes\relative{ } \paper{ \inBed }}} c d - a b c d \break - a b c d \break + \time 4/8 + \times 2/3 { c'8 d e } \times 2/3 {c d e} + \time 4/8 + g8^\tempoChange a8 g8 a \break } diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc index 7657efec13..789710daba 100644 --- a/lily/gourlay-breaking.cc +++ b/lily/gourlay-breaking.cc @@ -79,8 +79,8 @@ Gourlay_breaking::do_solve () const Break_node first_node ; optimal_paths.push (first_node); - bool ragged_right = to_boolean (pscore_->paper_->get_scmvar ("raggedright")); - bool ragged_last = to_boolean (pscore_->paper_->get_scmvar ("raggedlast")); + bool ragged_right = to_boolean (pscore_->paper_->c_variable ("raggedright")); + bool ragged_last = to_boolean (pscore_->paper_->c_variable ("raggedlast")); Real worst_force = 0.0; for (int break_idx = 1; break_idx< breaks.size (); break_idx++) diff --git a/lily/include/music-output-def.hh b/lily/include/music-output-def.hh index e1b13accc1..bbaf79cfc4 100644 --- a/lily/include/music-output-def.hh +++ b/lily/include/music-output-def.hh @@ -36,7 +36,7 @@ public: void assign_context_def (SCM transdef); SCM find_context_def (SCM name) const; String outname_string () ; - SCM get_scmvar (String id) const; + SCM c_variable (String id) const; SCM lookup_variable (SCM sym) const; void set_variable (SCM, SCM sym); // fixme: dependencies diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc index 608b640ecb..baf6c66bd4 100644 --- a/lily/music-output-def.cc +++ b/lily/music-output-def.cc @@ -107,7 +107,15 @@ Music_output_def::print_smob (SCM s, SCM p, scm_print_state *) } SCM -Music_output_def::get_scmvar (String s) const +Music_output_def::lookup_variable (SCM sym) const +{ + SCM var = ly_module_lookup (scope_, sym); + + return scm_variable_ref (var); +} + +SCM +Music_output_def::c_variable (String s) const { return lookup_variable (ly_symbol2scm (s.to_str0 ())); } @@ -118,14 +126,6 @@ Music_output_def::set_variable (SCM sym, SCM val) scm_module_define (scope_, sym, val); } -SCM -Music_output_def::lookup_variable (SCM sym) const -{ - SCM var = ly_module_lookup (scope_, sym); - - return scm_variable_ref (var); -} - LY_DEFINE (ly_paper_lookup, "ly:paper-lookup", 2, 0,0, (SCM pap, SCM sym), "Lookup @var{sym} in @var{pap}. " diff --git a/lily/page.cc b/lily/page.cc index 85b7b7d875..86a3af963a 100644 --- a/lily/page.cc +++ b/lily/page.cc @@ -34,15 +34,14 @@ Page::Page (Paper_def *paper, int number) page_count_++; - SCM make_header = ly_scheme_function ("make-header"); - SCM make_footer = ly_scheme_function ("make-footer"); - - header_ = scm_call_2 (make_header, paper_->self_scm (), + header_ = scm_call_2 (paper_->c_variable ("make-header"), + paper_->self_scm (), scm_int2num (number_)); if (unsmob_stencil (header_)) unsmob_stencil (header_)->align_to (Y_AXIS, UP); - footer_ = scm_call_2 (make_footer, paper_->self_scm (), + footer_ = scm_call_2 (paper_->c_variable ("make-footer"), + paper_->self_scm (), scm_int2num (number_)); if (unsmob_stencil (footer_)) unsmob_stencil (footer_)->align_to (Y_AXIS, UP); diff --git a/lily/paper-book.cc b/lily/paper-book.cc index bb802e623f..d04112b9ec 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -19,7 +19,7 @@ // JUNKME SCM -stencil2line (Stencil* stil, bool is_title = false) +stencil2line (Stencil *stil, bool is_title = false) { static SCM z; if (!z) @@ -217,14 +217,14 @@ Paper_book::init () Paper_def *paper = papers_[0]; SCM scopes = this->scopes (0); - SCM make_tagline = ly_scheme_function ("make-tagline"); + SCM make_tagline = paper->c_variable ("make-tagline"); tagline_ = scm_call_2 (make_tagline, paper->self_scm (), scopes); Real tag_height = 0; if (Stencil *s = unsmob_stencil (tagline_)) tag_height = s->extent (Y_AXIS).length (); height_ += tag_height; - SCM make_copyright = ly_scheme_function ("make-copyright"); + SCM make_copyright = paper->c_variable ("make-copyright"); copyright_ = scm_call_2 (make_copyright, paper->self_scm (), scopes); Real copy_height = 0; if (Stencil *s = unsmob_stencil (copyright_)) @@ -269,7 +269,7 @@ Paper_book::pages () tag_height = s->extent (Y_AXIS).length (); SCM all = lines (); - SCM proc = paper->get_scmvar ("page-breaking"); + SCM proc = paper->c_variable ("page-breaking"); SCM breaks = scm_apply_0 (proc, scm_list_n (all, scm_make_real (height_), scm_make_real (text_height), scm_make_real (-copy_height), @@ -286,7 +286,8 @@ Paper_book::pages () for (int i = 0; i < page_count; i++) { if (i) - page = new Page (paper, i+1); + page = new Page (paper, i + 1); + int next = i + 1 < page_count ? ly_scm2int (scm_vector_ref (breaks, scm_int2num (i))) : 0; while ((!next && all != SCM_EOL) || line <= next) diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index e83dedf53f..deedd461a6 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -625,7 +625,7 @@ Spacing_spanner::musical_column_spacing (Grob *me, Item * lc, Item *rc, Real inc */ compound_fixed_note_space = compound_fixed_note_space get_paper ()->get_scmvar ("packed")); + bool packed = to_boolean (me->get_paper ()->c_variable ("packed")); Real strength, distance; /* diff --git a/ly/declarations-init.ly b/ly/declarations-init.ly index 48e17441ce..917e2bac90 100644 --- a/ly/declarations-init.ly +++ b/ly/declarations-init.ly @@ -76,6 +76,12 @@ melismaEnd = #(make-span-event 'ManualMelismaEvent STOP) #(define page-to-stencil ly:page-header-lines-footer-stencil) + #(define make-header plain-header) + #(define make-footer plain-footer) + %%#(define make-footer empty-markup) + #(define make-tagline TAGLINE-or-tagline-from-header) + #(define make-copyright copyright-from-header) + \include "engraver-init.ly" } diff --git a/scm/ly-from-scheme.scm b/scm/ly-from-scheme.scm index 0436f423e8..6a94976c92 100644 --- a/scm/ly-from-scheme.scm +++ b/scm/ly-from-scheme.scm @@ -2,9 +2,8 @@ ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; -;;;; (c) 2000--2004 Han-Wen Nienhuys -;;;; Jan Nieuwenhuizen - +;;;; (c) 2004 Nicolas Sceaux +;;;; Jan Nieuwenhuizen (define gen-lily-sym ;; Generate a lilyvartmpXX symbol, that may be (hopefully) unique. diff --git a/scm/page-layout.scm b/scm/page-layout.scm index d706f418dc..1a4c80199e 100644 --- a/scm/page-layout.scm +++ b/scm/page-layout.scm @@ -10,7 +10,7 @@ (variable-ref v) (if (module? (cdr modules)) (ly:modules-lookup (cdr modules) sym))))) -(define (page-properties paper) +(define-public (page-properties paper) (list (append `((linewidth . ,(ly:paper-get-number paper 'linewidth))) (ly:paper-lookup paper 'text-font-defaults)))) @@ -80,13 +80,13 @@ ("" (get 'opus)) #:fill-line (#:large #:bigger #:caps (get 'piece) ""))))))) -(define-public (make-header paper page-number) +(define-public (plain-header paper page-number) (let ((props (page-properties paper) )) (interpret-markup paper props (markup #:fill-line ("" #:bold (number->string page-number)))))) -(define-public (make-footer paper page-number) +(define-public (plain-footer paper page-number) (let ((props (page-properties paper))) (interpret-markup paper props @@ -96,7 +96,7 @@ (define TAGLINE (string-append "Engraved by LilyPond (version " (lilypond-version) ")")) -(define-public (make-tagline paper scopes) +(define-public (TAGLINE-or-tagline-from-header paper scopes) (let* ((props (page-properties paper)) (tagline-var (ly:modules-lookup scopes 'tagline)) (tagline (if (markup? tagline-var) tagline-var TAGLINE))) @@ -107,7 +107,7 @@ (markup #:fill-line (tagline ""))))) ((markup? tagline) (interpret-markup paper props tagline))))) -(define-public (make-copyright paper scopes) +(define-public (copyright-from-header paper scopes) (let ((props (page-properties paper)) (copyright (ly:modules-lookup scopes 'copyright)))