* lily/parser.yy (markup): Use it to grok \score.
+2004-04-28 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * lily/book.cc (to_stencil): New method.
+
+ * lily/parser.yy (markup): Use it to grok \score.
+
2004-04-27 Jan Nieuwenhuizen <janneke@gnu.org>
+ * lily/stencil.cc (expr): Rename (was: get_expr). Update callers.
+
* lily/paper-book.cc (pages): Change signature. Update callers.
* lily/include/page.hh:
#ifndef OFFSET_HH
#define OFFSET_HH
+#include "flower-proto.hh"
#include "real.hh"
#include "axes.hh"
#include "arithmetic-operator.hh"
-struct Offset;
-
Offset complex_multiply (Offset, Offset);
Offset complex_divide (Offset, Offset);
Offset complex_exp (Offset);
/** 2d vector
- should change to Complex
+ should change to Complex -- how is vector == complex?
+
+ ughr wat een beerput
*/
-struct Offset {
+class Offset
+{
public:
Real coordinate_a_[NO_AXES];
- Real &operator[] (Axis i) {
+ Real &operator[] (Axis i)
+ {
return coordinate_a_[i];
}
- Real operator[] (Axis i) const{
+
+ Real operator[] (Axis i) const
+ {
return coordinate_a_[i];
}
- Offset& operator+= (Offset o) {
- (*this)[X_AXIS] += o[X_AXIS];
- (*this)[Y_AXIS] += o[Y_AXIS];
+ Offset& operator+= (Offset o)
+ {
+ (*this)[X_AXIS] += o[X_AXIS];
+ (*this)[Y_AXIS] += o[Y_AXIS];
return *this;
}
- Offset operator - () const {
+
+ Offset operator - () const
+ {
Offset o = *this;
o[X_AXIS] = - o[X_AXIS];
o[Y_AXIS] = - o[Y_AXIS];
return o;
}
- Offset& operator-= (Offset o) {
- (*this)[X_AXIS] -= o[X_AXIS];
- (*this)[Y_AXIS] -= o[Y_AXIS];
+
+ Offset& operator-= (Offset o)
+ {
+ (*this)[X_AXIS] -= o[X_AXIS];
+ (*this)[Y_AXIS] -= o[Y_AXIS];
return *this;
}
- Offset &scale (Offset o) {
- (*this)[X_AXIS] *= o[X_AXIS];
- (*this)[Y_AXIS] *= o[Y_AXIS];
+ Offset &scale (Offset o)
+ {
+ (*this)[X_AXIS] *= o[X_AXIS];
+ (*this)[Y_AXIS] *= o[Y_AXIS];
return *this;
}
- Offset &operator *= (Real a) {
- (*this)[X_AXIS] *= a;
- (*this)[Y_AXIS] *= a;
+
+ Offset &operator *= (Real a)
+ {
+ (*this)[X_AXIS] *= a;
+ (*this)[Y_AXIS] *= a;
return *this;
}
- Offset (Real ix , Real iy) {
+ Offset (Real ix , Real iy)
+ {
coordinate_a_[X_AXIS] =ix;
coordinate_a_[Y_AXIS] =iy;
}
- Offset () {
- coordinate_a_[X_AXIS]=
- coordinate_a_[Y_AXIS]=
- 0.0;
+
+ Offset ()
+ {
+ coordinate_a_[X_AXIS] = coordinate_a_[Y_AXIS]= 0.0;
}
String to_string () const;
- void mirror (Axis);
+ Offset& mirror (Axis a)
+ {
+ coordinate_a_[a] = - coordinate_a_[a];
+ return *this;
+ }
+
Real arg () const;
Real length () const;
- Offset operator *= (Offset z2) {
+
+ //wtf, How is Offset a Complex? is this used?
+ Offset operator *= (Offset z2)
+ {
*this = complex_multiply (*this,z2);
return *this;
}
return o1;
}
+inline Offset
+mirror (Offset o, Axis a)
+{
+ o.mirror (a);
+ return o;
+}
+
-#endif // OFFSET_HH
+#endif /* OFFSET_HH */
/// "cccc"
String to_string (char c, int n = 1);
String to_string (int i, char const* format = 0);
-String to_string (double f , char const* format = 0);
+String to_string (double f, char const* format = 0);
String to_string (long b);
String to_string (bool b);
String to_string (char const* format, ... );
{
return sqrt (sqr (coordinate_a_[X_AXIS]) + sqr (coordinate_a_[Y_AXIS]));
}
-void
-Offset::mirror (Axis a)
-{
- coordinate_a_[a] = - coordinate_a_[a];
-}
SCM
Ambitus::print (SCM smob)
{
- Item *me = (Item *)unsmob_grob (smob);
- Stencil stencil = Stencil ();
+ Item *me = (Item*) unsmob_grob (smob);
+ Stencil stencil;
SCM scm_note_head_style = me->get_property ("note-head-style");
String note_head_style;
text_stil->translate (z2);
fr.add_stencil (*text_stil);
- fr = Stencil (orig_extent, fr.get_expr ());
+ fr = Stencil (orig_extent, fr.expr ());
return fr.smobbed_copy ();
}
#include "music-output-def.hh"
#include "music-output.hh"
#include "music.hh"
+#include "page.hh"
#include "paper-book.hh"
#include "paper-def.hh"
#include "score.hh"
paper_book->output (outname);
scm_gc_unprotect_object (paper_book->self_scm ());
}
+
+/* FIXME: WIP, this is a hack. Return first page as stencil. */
+SCM
+Book::to_stencil (Music_output_def *default_def, SCM header)
+{
+ Paper_book *paper_book = new Paper_book ();
+ int score_count = scores_.size ();
+ for (int i = 0; i < score_count; i++)
+ {
+ Paper_def *paper = 0;
+ SCM systems = scores_[i]->book_rendering ("", default_def, &paper);
+ if (systems != SCM_UNDEFINED)
+ {
+ if (paper)
+ paper_book->papers_.push (paper);
+ paper_book->scores_.push (systems);
+ paper_book->headers_.push (header);
+ }
+ }
+
+ 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 ();
+ return SCM_EOL;
+}
}
- Stencil out = Stencil ();
+ Stencil out;
Array<Offset> points;
points.clear ();
int size = bottom_points.size ();
// ugr.
mol = Stencil (m->extent_box (),
- scm_list_n (origin, m->get_expr (), SCM_UNDEFINED)
+ scm_list_n (origin, m->expr (), SCM_UNDEFINED)
). smobbed_copy ();
m = unsmob_stencil (mol);
Book ();
Book (Book const&);
void process (String outname, Music_output_def*, SCM header);
+ SCM to_stencil (Music_output_def*, SCM header);
};
DECLARE_UNSMOB (Book,book);
#include "lily-proto.hh"
#include "smobs.hh"
-/* WIP -- moving toward flexible stencil based output. */
+/* WIP -- moving toward flexible stencil based output.
+ Rename to Paper_page? */
class Page
{
DECLARE_SMOBS (Page, );
public:
static int page_count_;
+ static Real MIN_COVERAGE_;
Paper_def *paper_;
int number_;
int line_count_;
Real head_sep_;
Real text_width_;
- /* available area for text. */
- Real text_height ();
-
Page (Paper_def*, int);
- void output (Paper_outputter*, bool);
+
+ /* available area for text. */
+ Real text_height () const;
+ SCM to_stencil () const;
};
DECLARE_UNSMOB (Page, page);
void output_stencil (Stencil*);
void output_header (Paper_def*, SCM, int, bool);
void output_line (SCM, Offset*, bool);
+ void output_page (Page*, bool);
};
#endif /* PAPER_OUTPUTTER_HH */
For example,
Complex_smob::Complex_smob () {
- scm_member_ =SCM_EOL;
+ scm_member_ = SCM_EOL;
smobify_self ();
scm_member_ = <..what you want to store..>
}
- after creation, the self_scm() field of a complex smob is protected
- from Garbage Collection. This protection should be removed once the
- object is put into another (reachable) Scheme data structure, ie.
+ after construction, the self_scm () field of a complex smob is
+ protected from Garbage Collection. This protection should be
+ removed once the object is put into another (reachable) Scheme data
+ structure, i.e.
- Complex_smob * p = new Complex_smob;
+ Complex_smob *p = new Complex_smob;
list = scm_cons (p->self_scm (), list);
scm_gc_unprotect_object (p->self_scm ());
- Complex smobs are made with DECLARE_SMOBS(Classname,) in the class
+ Complex smobs are made with DECLARE_SMOBS (Classname,) in the class
declaration.
CALLING INTERFACE
For implementating a class, the following should be provided
- - an equal_p() function (a default is in the
+ - an equal_p () function (a default is in the
IMPLEMENT_DEFAULT_EQUAL_P macro in ly-smobs.icc)
- mark_smob () function, that calls scm_gc_mark () on all Scheme
- a print_smob () function, that displays a representation for
debugging purposes
- - A call to one of the IMPLEMENT_SMOBS or IMPLEMENT_SIMPLE_SMOBS macros
- from file "ly-smobs.icc"
-
+ - A call to one of the IMPLEMENT_SMOBS or IMPLEMENT_SIMPLE_SMOBS macros
+ from file "ly-smobs.icc"
*/
-#define DECLARE_SIMPLE_SMOBS(CL,dummy) \
+#define DECLARE_SIMPLE_SMOBS(CL, dummy) \
public: \
SCM smobbed_copy () const; \
DECLARE_BASE_SMOBS(CL)
#define DECLARE_BASE_SMOBS(CL) \
- friend class Non_existant_class ; \
-private:\
+ friend class Non_existent_class; \
+private: \
static scm_t_bits smob_tag_; \
static SCM mark_smob (SCM); \
static size_t free_smob (SCM s); \
Stencil ();
Offset origin () const;
- SCM get_expr () const;
+ SCM expr () const;
/**
Set dimensions to empty, or to (Interval (0,0),Interval (0,0) */
{
Real staff_space = Staff_symbol_referencer::staff_space (me);
Real height = 0.6 * staff_space;
- Stencil stencil = Stencil ();
+ Stencil stencil;
if (add_cauda)
{
return SCM_UNSPECIFIED;
}
-static Music_output_def*
+Music_output_def*
get_paper (My_lily_parser *parser)
{
SCM id = parser->lexer_->lookup_identifier ("$defaultpaper");
{
Grob *staff = Staff_symbol_referencer::get_staff_symbol (me);
Real inter_f = Staff_symbol_referencer::staff_space (me)/2;
- int line_count = (abs (pos) < interspaces)
- ? 0
- : (abs (pos) - interspaces) / 2;
- Stencil stencil = Stencil ();
-
-
+ int line_count = ((abs (pos) < interspaces)
+ ? 0
+ : (abs (pos) - interspaces) / 2);
+ Stencil stencil;
if (line_count)
{
Real ledgerlinethickness =
b = Stencil (Box (b.extent (X_AXIS),
Interval (0.1,0.1)),
- b.get_expr ());
+ b.expr ());
b.translate_axis (bracket_span_points[LEFT], X_AXIS);
text.translate_axis (span_points[LEFT], X_AXIS);
(c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
*/
+#include "dimensions.hh"
#include "ly-module.hh"
#include "page.hh"
#include "paper-def.hh"
#include "stencil.hh"
#include "warn.hh"
-// JUNKME
-SCM
-stencil2line (Stencil* stil, bool is_title = false)
-{
- static SCM z;
- if (!z)
- z = scm_permanent_object (ly_offset2scm (Offset (0, 0)));
- Offset dim = Offset (stil->extent (X_AXIS).length (),
- stil->extent (Y_AXIS).length ());
- Paper_line *pl = new Paper_line (dim, scm_cons (stil->smobbed_copy (),
- SCM_EOL),
- -10001 * is_title, is_title);
-
- return scm_gc_unprotect_object (pl->self_scm ());
-}
-
-static Real const MIN_COVERAGE = 0.66;
-
int Page::page_count_ = 0;
+Real Page::MIN_COVERAGE_ = 0.66;
Page::Page (Paper_def *paper, int number)
{
Page::print_smob (SCM smob, SCM port, scm_print_state*)
{
Page *p = (Page*) ly_cdr (smob);
-
scm_puts ("#<", port);
scm_puts (classname (p), port);
scm_puts (to_string (p->number_).to_str0 (), port);
return 1;
}
-void
-Page::output (Paper_outputter *out, bool is_last)
+static void
+stack_stencils (Stencil &a, Stencil *b, Offset *origin)
{
- progress_indication ("[" + to_string (number_));
- out->output_scheme (scm_list_1 (ly_symbol2scm ("start-page")));
- Offset o (left_margin_, top_margin_);
- Real vfill = line_count_ > 1 ? (text_height () - height_) / (line_count_ - 1)
- : 0;
-
- Real coverage = height_ / text_height ();
- if (coverage < MIN_COVERAGE)
+ Real height = b->extent (Y_AXIS).length ();
+ if (height > 50 CM)
+ {
+ programming_error (to_string ("Improbable stencil height: %f", height));
+ height = 50 CM;
+ }
+ Offset o = *origin;
+ o.mirror (Y_AXIS);
+ b->translate (o);
+ a.add_stencil (*b);
+ (*origin)[Y_AXIS] += height;
+}
+
+SCM
+Page::to_stencil () const
+{
+ SCM proc = ly_scheme_function ("page-to-stencil");
+ return scm_call_1 (proc, self_scm ());
+}
+
+LY_DEFINE (ly_page_header_lines_footer_stencil, "ly:page-header-lines-footer-stencil",
+ 1, 0, 0, (SCM page),
+ "Simple header, lines, footer stencil from PAGE.")
+{
+ Page *p = unsmob_page (page);
+ SCM_ASSERT_TYPE (p, page, SCM_ARG1, __FUNCTION__, "page");
+
+ Stencil stencil;
+ 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 (header_))
+ if (Stencil *s = unsmob_stencil (p->header_))
{
- out->output_line (stencil2line (unsmob_stencil (header_)), &o, false);
- o[Y_AXIS] += head_sep_;
+ stack_stencils (stencil, s, &o);
+ o[Y_AXIS] += p->head_sep_;
}
- for (SCM s = lines_; s != SCM_EOL; s = ly_cdr (s))
+ for (SCM s = p->lines_; s != SCM_EOL; s = ly_cdr (s))
{
- SCM line = ly_car (s);
- out->output_line (line, &o,
- is_last && ly_cdr (s) != SCM_EOL && !unsmob_stencil (copyright_)
- && !unsmob_stencil (tagline_) && !unsmob_stencil (footer_));
+ 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);
/* Do not put vfill between title and its music, */
- if (scm_pair_p (ly_cdr (s))
- && (!unsmob_paper_line (line)->is_title () || vfill < 0))
+ if (ly_cdr (s) != SCM_EOL
+ && (!p->is_title () || vfill < 0))
o[Y_AXIS] += vfill;
/* rather put extra just before the title. */
if (ly_cdr (s) != SCM_EOL
o[Y_AXIS] += vfill;
}
- o[Y_AXIS] = vsize_ - bottom_margin_;
- if (unsmob_stencil (copyright_))
- o[Y_AXIS] -= unsmob_stencil (copyright_)->extent (Y_AXIS).length ();
- if (unsmob_stencil (tagline_))
- o[Y_AXIS] -= unsmob_stencil (tagline_)->extent (Y_AXIS).length ();
- if (unsmob_stencil (footer_))
- o[Y_AXIS] -= unsmob_stencil (footer_)->extent (Y_AXIS).length ();
-
- if (unsmob_stencil (copyright_))
- out->output_line (stencil2line (unsmob_stencil (copyright_)), &o,
- is_last && !unsmob_stencil (tagline_) && !unsmob_stencil (footer_));
- if (unsmob_stencil (tagline_))
- out->output_line (stencil2line (unsmob_stencil (tagline_)), &o,
- is_last && !unsmob_stencil (footer_));
- if (unsmob_stencil (footer_))
- out->output_line (stencil2line (unsmob_stencil (footer_)), &o, is_last);
- out->output_scheme (scm_list_2 (ly_symbol2scm ("stop-page"),
- ly_bool2scm (is_last && !unsmob_stencil (footer_))));
- progress_indication ("]");
+ 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 (Stencil *s = unsmob_stencil (p->copyright_))
+ stack_stencils (stencil, s, &o);
+ if (Stencil *s = unsmob_stencil (p->tagline_))
+ stack_stencils (stencil, s, &o);
+ if (Stencil *s = unsmob_stencil (p->footer_))
+ stack_stencils (stencil, s, &o);
+
+ return stencil.smobbed_copy ();
}
Real
-Page::text_height ()
+Page::text_height () const
{
Real h = vsize_ - top_margin_ - bottom_margin_;
if (unsmob_stencil (header_))
h -= unsmob_stencil (footer_)->extent (Y_AXIS).length ();
return h;
}
+
#include "stencil.hh"
#include "warn.hh"
-// JUNKME.
-extern SCM stencil2line (Stencil* stil, bool is_title = false);
+// JUNKME
+SCM
+stencil2line (Stencil* stil, bool is_title = false)
+{
+ static SCM z;
+ if (!z)
+ z = scm_permanent_object (ly_offset2scm (Offset (0, 0)));
+ Offset dim = Offset (stil->extent (X_AXIS).length (),
+ stil->extent (Y_AXIS).length ());
+ Paper_line *pl = new Paper_line (dim, scm_cons (stil->smobbed_copy (),
+ SCM_EOL),
+ -10001 * is_title, is_title);
+
+ return scm_gc_unprotect_object (pl->self_scm ());
+}
+
Paper_book::Paper_book ()
{
Paper_book::output (String outname)
{
if (!papers_.size ())
+ // FIXME: no end-output?
return;
/* Generate all stencils to trigger font loads. */
int page_count = scm_ilength (pages);
out->output_header (paper, scopes (0), page_count, false);
- for (SCM s = pages; ly_c_pair_p (s); s = ly_cdr (s))
- unsmob_page (ly_car (s))->output (out, ly_c_pair_p (ly_cdr (s)));
+ for (SCM s = pages; s != SCM_EOL; s = ly_cdr (s))
+ {
+ Page *p = unsmob_page (ly_car (s));
+ progress_indication ("[" + to_string (p->number_));
+ out->output_page (p, ly_cdr (s) == SCM_EOL);
+ progress_indication ("]");
+ }
out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
-
progress_indication ("\n");
}
SCM
Paper_line::to_stencil () const
{
- Stencil stencil = Stencil ();
+ Stencil stencil;
for (SCM s = stencils_; ly_c_pair_p (s); s = ly_cdr (s))
stencil.add_stencil (*unsmob_stencil (ly_car (s)));
return stencil.smobbed_copy ();
#include "lily-version.hh"
#include "ly-module.hh"
#include "main.hh"
+#include "page.hh"
#include "paper-book.hh"
#include "paper-def.hh"
#include "paper-line.hh"
#include "string-convert.hh"
#include "warn.hh"
+// JUNKME
+extern SCM stencil2line (Stencil* stil, bool is_title = false);
Paper_outputter::Paper_outputter (String filename)
{
Offset dim = p->dim ();
if (dim[Y_AXIS] > 50 CM)
{
- programming_error ("Improbable system height.");
+ programming_error (to_string ("Improbable line height: %f",
+ dim[Y_AXIS]));
dim[Y_AXIS] = 50 CM;
}
ly_quote_scm (ly_offset2scm (*origin)),
ly_quote_scm (ly_offset2scm (dim))));
-#if 0 /* FIXME: how stupid is this wrt memory management? */
- for (SCM s = p->stencils (); ly_c_pair_p (s); s = ly_cdr (s))
- output_expr (unsmob_stencil (ly_car (s))->get_expr (), Offset (0, 0));
-#else
+#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"),
ly_bool2scm (is_last)));
}
+void
+Paper_outputter::output_page (Page *p, bool is_last)
+{
+ 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_))));
+}
+
void
Paper_outputter::output_music_output_def (Music_output_def *odef)
{
void
Paper_outputter::output_stencil (Stencil *stil)
{
- output_expr (stil->get_expr (), stil->origin ());
+ output_expr (stil->expr (), stil->origin ());
}
/* TODO: replaceme/rewriteme, see output-ps.scm: output-stencil */
| STRING_IDENTIFIER {
$$ = $1;
}
+ | score_block {
+ Score *score = $1;
+ //Book *book = unsmob_book (ly_score_bookify (score->self_scm ()));
+ Book *book = new Book;
+ book->scores_.push (score);
+ extern Music_output_def* get_paper (My_lily_parser *parser);
+ Music_output_def *paper = get_paper (THIS);
+ SCM s = book->to_stencil (paper, THIS->header_);
+// $$ = s;
+ $$ = Text_item::interpret_markup (paper->self_scm (), SCM_EOL, s);
+ }
;
markup_list:
return new_s;
}
-LY_DEFINE (ly_stencil_get_expr, "ly:stencil-get-expr",
+LY_DEFINE (ly_stencil_expr, "ly:stencil-get-expr",
1, 0, 0, (SCM stil),
"Return the expression of @var{stil}.")
{
Stencil *s = unsmob_stencil (stil);
SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil");
- return s->get_expr ();
+ return s->expr ();
}
LY_DEFINE (ly_stencil_get_extent, "ly:stencil-extent",
return dim_[a];
}
+/* Hmm... maybe this is not such a good idea ; stuff can be empty,
+ while expr_ == '() */
+bool
+Stencil::is_empty () const
+{
+ return expr_ == SCM_EOL;
+}
+
+SCM
+Stencil::expr () const
+{
+ return expr_;
+}
+
+Box
+Stencil::extent_box () const
+{
+ return dim_;
+}
Offset
Stencil::origin () const
{
}
/* FIXME: unintuitive naming, you would expect *this to be moved.
- Kept (keeping?) API for compat with add_at_edge (). */
+ 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
+Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s,
+ Real padding, Real minimum) const
{
- Interval my_extent= dim_[a];
-
-
+ Interval my_extent = dim_[a];
Interval i (s.extent (a));
Real his_extent;
if (i.is_empty ())
else
his_extent = i[-d];
- Real offset = (my_extent. is_empty () ? 0.0 : my_extent[d] - his_extent)
+ Real offset = (my_extent.is_empty () ? 0.0 : my_extent[d] - his_extent)
+ d * padding;
Stencil toadd (s);
toadd.translate_axis (offset,a);
- if (minimum > 0
- && d *(- origin ()[a] + toadd.origin ()[a]) < minimum)
+ if (minimum > 0 && d * (-origin ()[a] + toadd.origin ()[a]) < minimum)
toadd.translate_axis ( -toadd.origin ()[a]
- + origin ()[a] + d* minimum, a);
-
+ + origin ()[a] + d * minimum, a);
+
return toadd;
}
{
add_stencil (moved_to_edge (a, d, s, padding, minimum));
}
-
-/* Hmm... maybe this is not such a good idea ; stuff can be empty,
- while expr_ == '() */
-bool
-Stencil::is_empty () const
-{
- return expr_ == SCM_EOL;
-}
-
-SCM
-Stencil::get_expr () const
-{
- return expr_;
-}
-
-Box
-Stencil::extent_box () const
-{
- return dim_;
-}
lo = cmp;
}
while (hi - lo > 1);
-
- Stencil m (fm->get_indexed_char_stencil (lo)); // ugh. ascii?
- b=m.extent_box ();
- b[X_AXIS] = Interval (0,0);
- return Stencil (b, m.get_expr ());
+ /* FIXME: ascii? */
+ Stencil stil (fm->get_indexed_char_stencil (lo));
+ b = stil.extent_box ();
+ b[X_AXIS] = Interval (0, 0);
+
+ return Stencil (b, stil.expr ());
}
Real line_thickness)
{
Real staff_space = Staff_symbol_referencer::staff_space (me);
- Stencil stencil = Stencil ();
+ Stencil stencil;
Real right_height = 0.6 * staff_space;
Real interval;
(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))