ly:stencil-get-expr). Update callers.
(ly:stencil-align-to!): Return stencil too.
* lily/paper-outputter.cc (output_page): Bugfix. Use page
stencil. Remove looped line-based page output.
(output_line): Use line stencil. Remove looped stencil-based line
output.
* lily/page.cc (ly:page-paper-lines): New function.
* input/test/markup-score.ly: New file.
* lily/book.cc (to_stencil): New method.
* lily/parser.yy (markup): Use it to grok \score.
2004-04-28 Jan Nieuwenhuizen <janneke@gnu.org>
+ * lily/stencil-scheme.cc (ly:stencil-expr): Rename (was:
+ ly:stencil-get-expr). Update callers.
+ (ly:stencil-align-to!): Return stencil too.
+
+ * lily/paper-outputter.cc (output_page): Bugfix. Use page
+ stencil. Remove looped line-based page output.
+ (output_line): Use line stencil. Remove looped stencil-based line
+ output.
+
+ * lily/page.cc (ly:page-paper-lines): New function.
+
* input/test/markup-score.ly: New file.
* scm/define-markup-commands.scm (stencil): New markup.
-
\header {
%% WIP
texidoc = "Use \\score block as markup command."
-
}
\version "2.3.1"
+%%;; Hmm - why is stencil so tall?
+#(define (page-stack-lines page)
+ (stack-stencils Y 1 0
+ (map ly:paper-line-stencil (ly:page-paper-lines page))))
+
+#(define (page-stack-lines page)
+ (let* ((urg-stencil (ly:stencil-align-to! (stack-stencils Y DOWN 0
+ (map ly:paper-line-stencil (ly:page-paper-lines page)))
+ Y DOWN))
+ (expr (ly:stencil-expr urg-stencil))
+ (xext (ly:stencil-extent urg-stencil X))
+ (yext (ly:stencil-extent urg-stencil Y)))
+ (ly:stencil-align-to!
+ ;; urgr
+ (ly:make-stencil expr xext (cons (* -0.25 (cdr yext)) 0))
+ Y CENTER)))
-\paper {
+inBed = \paper {
raggedright = ##t
- vsize = 30 \mm
- linewidth = 30\mm
+ linewidth = 40\mm
indent = 0 \mm
- hsize = 40\mm
+
+ %% #(define page-to-stencil page-stack-lines)
+ #(define (page-to-stencil page)
+ (box-stencil (page-stack-lines page) 0.1 0.5))
+
+ \context {
+ \StaffContext
+ minimumVerticalExtent = ##f
+ }
}
+
\header {
title = "title"
subtitle = \markup { \fill-line <
"subtitle with score: "
- \score { \relative \notes { a'^"Hi" b c } }
+ \score { \relative \notes { a'^"Hi" b c } \paper { \inBed } }
"woo!"
> }
subsubtitle = "subsubtitle"
}
-\paper {
- raggedright = ##f
- linewidth = 150\mm
- indent = 15\mm
- vsize = 298\mm
- hsize = 210 \mm
-}
-
\relative {
a' b c d \break
a b c d \break
+ %% interesting bug:
+ %%a b^\markup { \score{ \notes\relative{ <b'1 dis fis> } \paper{ \inBed }}} c d
+ a b c d \break
a b c d \break
}
for (int i = 0; i < score_count; i++)
{
Paper_def *paper = 0;
- SCM systems = scores_[i]->book_rendering ("", default_def, &paper);
+ SCM systems = scores_[i]->book_rendering ("<markup>", default_def,
+ &paper);
if (systems != SCM_UNDEFINED)
{
if (paper)
SCM pages = paper_book->pages ();
scm_gc_unprotect_object (paper_book->self_scm ());
if (pages != SCM_EOL)
- return unsmob_page (ly_car (pages))->to_stencil ();
+ {
+ progress_indication (_f ("paper output to `%s'...", "<markup>"));
+ return unsmob_page (ly_car (pages))->to_stencil ();
+ }
return SCM_EOL;
}
SCM
Page::to_stencil () const
{
- SCM proc = ly_scheme_function ("page-to-stencil");
+ SCM proc = paper_->lookup_variable (ly_symbol2scm ("page-to-stencil"));
return scm_call_1 (proc, self_scm ());
}
stack_stencils (stencil, s, &o);
o[Y_AXIS] += p->head_sep_;
}
+
for (SCM s = p->lines_; s != SCM_EOL; s = ly_cdr (s))
{
Paper_line *p = unsmob_paper_line (ly_car (s));
-#if 0 // ugh, parse error?
- Stencil line (Box (Interval (0, p->dim ()[X_AXIS]),
- Interval (0, p->dim ()[Y_AXIS])), SCM_EOL);
-#else
- Box x (Interval (0, p->dim ()[X_AXIS]),
- Interval (0, p->dim ()[Y_AXIS]));
- Stencil line (x, SCM_EOL);
-#endif
- line.add_stencil (*unsmob_stencil (p->to_stencil ()));
- stack_stencils (stencil, &line, &o);
-
+ stack_stencils (stencil, unsmob_stencil (p->to_stencil ()), &o);
/* Do not put vfill between title and its music, */
if (ly_cdr (s) != SCM_EOL
&& (!p->is_title () || vfill < 0))
return h;
}
+LY_DEFINE (ly_page_paper_lines, "ly:page-paper-lines",
+ 1, 0, 0, (SCM page),
+ "Return paper-lines from PAGE.")
+{
+ Page *p = unsmob_page (page);
+ SCM_ASSERT_TYPE (p, page, SCM_ARG1, __FUNCTION__, "page");
+ return p->lines_;
+}
Stencil stencil;
for (SCM s = stencils_; ly_c_pair_p (s); s = ly_cdr (s))
stencil.add_stencil (*unsmob_stencil (ly_car (s)));
+ Offset o = dim ();
+ Box x (Interval (0, o[X_AXIS]), Interval (0, o[Y_AXIS]));
+ stencil = Stencil (x, stencil.expr ());
return stencil.smobbed_copy ();
}
SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
return scm_int2num (int (pl->penalty ()));
}
+
+LY_DEFINE (ly_paper_line_stencil, "ly:paper-line-stencil",
+ 1, 0, 0, (SCM line),
+ "Return the height of @var{line}.")
+{
+ Paper_line *pl = unsmob_paper_line (line);
+ SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
+ return pl->to_stencil ();
+}
+
ly_quote_scm (ly_offset2scm (*origin)),
ly_quote_scm (ly_offset2scm (dim))));
-#if 1 /* FIXME: how stupid is this memorywise? */
output_stencil (unsmob_stencil (p->to_stencil ()));
-#else
- for (SCM s = p->stencils (); ly_c_pair_p (s); s = ly_cdr (s))
- output_expr (unsmob_stencil (ly_car (s))->expr (), Offset (0, 0));
-#endif
(*origin)[Y_AXIS] += dim[Y_AXIS];
output_scheme (scm_list_2 (ly_symbol2scm ("stop-system"),
{
output_scheme (scm_list_1 (ly_symbol2scm ("start-page")));
-#if 0 /* FIXME: how stupid is this, memorywise? */
-
output_scheme (scm_list_3 (ly_symbol2scm ("start-system"),
ly_quote_scm (ly_offset2scm (Offset (0, 0))),
ly_quote_scm (ly_offset2scm (Offset (0, 0)))));
output_stencil (unsmob_stencil (p->to_stencil ()));
output_scheme (scm_list_2 (ly_symbol2scm ("stop-system"), SCM_BOOL_T));
-#else
- Offset o (p->left_margin_, p->top_margin_);
- Real vfill = (p->line_count_ > 1
- ? (p->text_height () - p->height_) / (p->line_count_ - 1)
- : 0);
-
- Real coverage = p->height_ / p->text_height ();
- if (coverage < p->MIN_COVERAGE_)
- /* Do not space out a badly filled page. This is too simplistic
- (ie broken), because this should not vary too much between
- (subsequent?) pages in a book. */
- vfill = 0;
-
- if (unsmob_stencil (p->header_))
- {
- output_line (stencil2line (unsmob_stencil (p->header_)), &o, false);
- o[Y_AXIS] += p->head_sep_;
- }
- for (SCM s = p->lines_; s != SCM_EOL; s = ly_cdr (s))
- {
- SCM line = ly_car (s);
- output_line (line, &o,
- is_last && ly_cdr (s) != SCM_EOL
- && !unsmob_stencil (p->copyright_)
- && !unsmob_stencil (p->tagline_)
- && !unsmob_stencil (p->footer_));
-
- /* Do not put vfill between title and its music, */
- if (scm_pair_p (ly_cdr (s))
- && (!unsmob_paper_line (line)->is_title () || vfill < 0))
- o[Y_AXIS] += vfill;
- /* rather put extra just before the title. */
- if (ly_cdr (s) != SCM_EOL
- && (unsmob_paper_line (ly_cadr (s))->is_title () && vfill > 0))
- o[Y_AXIS] += vfill;
- }
-
- o[Y_AXIS] = p->vsize_ - p->bottom_margin_;
- if (unsmob_stencil (p->copyright_))
- o[Y_AXIS] -= unsmob_stencil (p->copyright_)->extent (Y_AXIS).length ();
- if (unsmob_stencil (p->tagline_))
- o[Y_AXIS] -= unsmob_stencil (p->tagline_)->extent (Y_AXIS).length ();
- if (unsmob_stencil (p->footer_))
- o[Y_AXIS] -= unsmob_stencil (p->footer_)->extent (Y_AXIS).length ();
-
- if (unsmob_stencil (p->copyright_))
- output_line (stencil2line (unsmob_stencil (p->copyright_)), &o,
- is_last
- && !unsmob_stencil (p->tagline_)
- && !unsmob_stencil (p->footer_));
- if (unsmob_stencil (p->tagline_))
- output_line (stencil2line (unsmob_stencil (p->tagline_)), &o,
- is_last && !unsmob_stencil (p->footer_));
- if (unsmob_stencil (p->footer_))
- output_line (stencil2line (unsmob_stencil (p->footer_)), &o, is_last);
-#endif
-
output_scheme (scm_list_2 (ly_symbol2scm ("stop-page"),
ly_bool2scm (is_last
&& !unsmob_stencil (p->footer_))));
%token WITH
/* escaped */
+/* FIXME: this sucks. The user will get to see these names:
+ syntax error, unexpected E_CHAR:
+ \
+ %%
+ */
%token E_CHAR E_EXCLAMATION E_SMALLER E_BIGGER E_OPEN E_CLOSE
%token E_LEFTSQUARE E_RIGHTSQUARE E_TILDE
%token E_BACKSLASH
SCM s = book->to_stencil (paper, THIS->header_);
$$ = scm_list_2 (ly_scheme_function ("stencil-markup"), s);
scm_gc_unprotect_object (score->self_scm ());
+ scm_gc_unprotect_object (book->self_scm ());
}
;
return new_s;
}
-LY_DEFINE (ly_stencil_expr, "ly:stencil-get-expr",
+LY_DEFINE (ly_stencil_expr, "ly:stencil-expr",
1, 0, 0, (SCM stil),
"Return the expression of @var{stil}.")
{
unsmob_stencil (stil)->align_to ((Axis)ly_scm2int (axis),
ly_scm2double (dir));
- return SCM_UNDEFINED;
+ return stil;
}
#(define page-breaking ly:ragged-page-breaks)
%%#(define page-breaking ly:optimal-page-breaks)
+ #(define page-to-stencil ly:page-header-lines-footer-stencil)
+
\include "engraver-init.ly"
}
#(define toplevel-book-handler default-toplevel-book-handler)
#(define toplevel-music-handler default-toplevel-music-handler)
#(define toplevel-score-handler default-toplevel-score-handler)
+
+#(define toplevel-score-handler default-toplevel-score-handler)
(define-public safe-mode? #f)
-;; Hmm
-(define-public page-to-stencil ly:page-header-lines-footer-stencil)
-
;; parser stuff.
(define-public (print-music-as-book parser music)
(let* ((score (ly:music-scorify music))