* lily/paper-book.cc: junk stencil2line.
* lily/paper-line.cc (Paper_line): construct from Stencil
directly. No futzing with the dimensions.
* lily/include/paper-line.hh (class Paper_line):
* lily/stencil.cc (interpret_stencil_expression): combine-stencil
takes arbitrary number of arguments.
if (!stacking_dir)
stacking_dir = DOWN;
- Interval threshold = robust_scm2interval ( me->get_property ("threshold"), Interval (0, Interval::infinity ()));
+ Interval threshold = robust_scm2interval (me->get_property ("threshold"), Interval (0, Interval::infinity ()));
Array<Interval> dims;
public:
int number_;
- Paper_line (Offset, SCM, int penalty = 0, bool = false);
+ Paper_line (Stencil, int penalty, bool);
Offset dim () const;
Stencil to_stencil () const;
It is implemented as a "tree" of scheme expressions, as in
- Expr = combine Expr Expr
+ Expr = combine Expr-list
| translate Offset Expr
| origin (ORIGIN) Expr
| no-origin Expr
\> {
return '>';
}
+ \\score {
+ return SCORE;
+ }
{MARKUPCOMMAND} {
String str (YYText () + 1);
SCM s = lookup_markup_command (str);
*/
-// 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 ()
{
Stencil title = book_title ();
if (!title.is_empty ())
- lines_ = scm_cons (stencil2line (title, true), lines_);
+ {
+ Paper_line *pl = new Paper_line (title, -10001, true);
+
+ lines_ = scm_cons (pl->self_scm (), lines_);
+ scm_gc_unprotect_object (pl->self_scm ());
+ }
int score_count = score_lines_.size ();
for (int i = 0; i < score_count; i++)
{
Stencil title = score_title (i);
if (!title.is_empty ())
- lines_ = scm_cons (stencil2line (title, true), lines_);
-
+ {
+ Paper_line *pl = new Paper_line (title, -10001, true);
+ lines_ = scm_cons (pl->self_scm (), lines_);
+ scm_gc_unprotect_object (pl->self_scm ());
+ }
+
if (scm_vector_p (score_lines_[i].lines_) == SCM_BOOL_T)
{
SCM line_list = scm_vector_to_list (score_lines_[i].lines_); // guh.
#define TITLE_PENALTY -1
-Paper_line::Paper_line (Offset o, SCM stencils, int penalty, bool is_title)
+Paper_line::Paper_line (Stencil s, int penalty, bool is_title)
{
is_title_ = is_title;
number_ = 0;
penalty_ = penalty;
smobify_self ();
-
-
- /*
- TODO: we should extend the definition of stencil to allow
-
- stencil-expr: LISTOF stencil-expr*
-
- so that we don't use as much memory for combining the stencils, and
- can do this conversion in constant time.
- */
- for (SCM s = stencils; ly_c_pair_p (s); s = ly_cdr (s))
- stencil_.add_stencil (*unsmob_stencil (ly_car (s)));
-
- Box x (Interval (0, o[X_AXIS]), Interval (0, o[Y_AXIS]));
- stencil_ = Stencil (x, stencil_.expr ());
+ stencil_ = s;
}
Paper_line::~Paper_line ()
IMPLEMENT_SMOBS(Paper_outputter);
IMPLEMENT_DEFAULT_EQUAL_P(Paper_outputter);
-LY_DEFINE(ly_outputter_dump_string, "ly:outputter-dump-stencil",
+LY_DEFINE(ly_outputter_dump_stencil, "ly:outputter-dump-stencil",
2, 0,0, (SCM outputter, SCM stencil),
"Dump stencil @var{expr} onto @var{outputter}."
)
}
-LY_DEFINE(ly_outputter_dump_stencil, "ly:outputter-dump-string",
+LY_DEFINE(ly_outputter_dump_string, "ly:outputter-dump-string",
2, 0, 0, (SCM outputter, SCM str),
"Dump @var{str} onto @var{outputter}.")
{
| STRING_IDENTIFIER {
$$ = $1;
}
- | {
+ | SCORE {
SCM nn = THIS->lexer_->lookup_identifier ("pitchnames");
THIS->lexer_->push_note_state (alist_to_hashq (nn));
- }
- /* cont */ score_block {
- /* WIP this is a bit arbitrary,
- we should also allow \book or Composite_music.
- However, you'd typically want to change paper
- settings, and need a \score block anyway. */
-
+ } '{' score_body '}' {
+ Score * sc = $4;
+ $$ = scm_list_2 (ly_scheme_function ("score-markup"), sc->self_scm ());
+ scm_gc_unprotect_object (sc->self_scm ());
THIS->lexer_->pop_state ();
- Score *score = $2;
- Book *book = new Book;
- book->header_ = THIS->lexer_->lookup_identifier ("$globalheader");
- book->scores_.push (score);
-
- Output_def *paper = get_paper (THIS);
- book->bookpaper_ = get_bookpaper (THIS);
-
- SCM s = book->to_stencil (paper);
- scm_gc_unprotect_object (score->self_scm ());
- scm_gc_unprotect_object (book->self_scm ());
- $$ = scm_list_2 (ly_scheme_function ("stencil-markup"), s);
}
;
IMPLEMENT_SMOBS (Score);
IMPLEMENT_DEFAULT_EQUAL_P (Score);
+IMPLEMENT_TYPE_P (Score, "ly:score?");
SCM
Score::mark_smob (SCM s)
store point & click locations.
Global to save some time. (Sue us!)
*/
-
Score::Score (Score const &s)
: Input (s)
{
scm_gc_unprotect_object (book->self_scm ());
return book->self_scm ();
}
+
+
+LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
+ 2, 0, 0, (SCM score, SCM paper),
+ "Run @var{score} through @var{paper}, a output definition, "
+ " scaled to correct outputscale already, return a list of paper-lines. ")
+{
+ Score * sc = unsmob_score (score);
+ Output_def *od = unsmob_output_def (paper);
+
+ SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score");
+ SCM_ASSERT_TYPE (od, paper, SCM_ARG2, __FUNCTION__, "Output_def");
+
+ SCM lines = SCM_EOL;
+ Output_def * score_def = 0;
+
+ /*
+ UGR, FIXME, these are default \paper blocks once again. They suck.
+ */
+ for (int i = 0; !score_def && i < sc->defs_.size (); i++)
+ {
+ if (sc->defs_[i]->c_variable ("is-paper") == SCM_BOOL_T)
+ {
+ score_def = sc->defs_[i];
+ }
+ }
+
+ if (!score_def)
+ return lines;
+
+
+ score_def = score_def->clone ();
+ SCM prot = score_def->self_scm ();
+ scm_gc_unprotect_object (prot);
+
+ score_def->parent_ = od;
+
+ SCM context = ly_run_translator (sc->music_, score_def->self_scm ());
+ lines = ly_format_output (context, scm_makfrom0str ("<embedded>"));
+
+ scm_remember_upto_here_1 (prot);
+ return lines;
+}
dim_.unite (s.dim_);
}
+
+
void
Stencil::set_empty (bool e)
{
}
else if (head == ly_symbol2scm ("combine-stencil"))
{
- interpret_stencil_expression (ly_cadr (expr), func, func_arg, o);
- expr = ly_caddr (expr);
+ for (SCM x = ly_cdr (expr); ly_c_pair_p (x); x = ly_cdr (x))
+ {
+ interpret_stencil_expression (ly_car (x), func, func_arg, o);
+ }
+ return ;
}
else
{
progress_indication (_f ("Element count %d.", count + element_count ()));
int line_count = broken_intos_.size ();
- SCM lines = scm_c_make_vector (line_count, SCM_UNDEFINED);
+ SCM lines = scm_c_make_vector (line_count, SCM_EOL);
- for (int i = 0; i < line_count; i++)
+ for (int i = 0; i < line_count; i++)
{
if (verbose_global_b)
progress_indication ("[");
if (verbose_global_b)
progress_indication (to_string (i) + "]");
}
- return lines;
+ return lines;
}
/* Find the loose columns in POSNS, and drape them around the columns
Start with layer 3, since scm_cons prepends to list. */
SCM all = get_property ("all-elements");
+ SCM exprs = SCM_EOL;
+ SCM *tail = &exprs;
+
Real penalty = 0;
for (int i = LAYER_COUNT; i--;)
for (SCM s = all; ly_c_pair_p (s); s = ly_cdr (s))
/* Must copy the stencil, for we cannot change the stencil
cached in G. */
- SCM my_stencil = stil->smobbed_copy ();
- unsmob_stencil (my_stencil)->translate (o + extra);
- stencils = scm_cons (my_stencil, stencils);
+ Stencil st = *stil;
+ st.translate (o + extra);
+ *tail = scm_cons (st.expr (), SCM_EOL);
+ tail = SCM_CDRLOC(*tail);
+
+ /*
+ UGH. back-end should extract this info from the System?
+ */
if (g->original_)
{
+ /*
+ Huh ? penalties from all columns are added ??!! --hwn
+ */
if (Item *it = dynamic_cast <Item*> (g))
{
Grob *col = it->get_column ();
SCM s = col->get_property ("page-penalty");
+
// FIXME; page breaking is not discrete at +-10000
if (ly_c_number_p (s)) // && fabs (ly_scm2double (s)) < 10000)
penalty += ly_scm2double (s);
Interval x (extent (this, X_AXIS));
Interval y (extent (this, Y_AXIS));
- Paper_line *pl = new Paper_line (Offset (x.length (), y.length ()),
- stencils, (bool) penalty); // FIXME.
+ Stencil sys_stencil (Box (x,y),
+ scm_cons (ly_symbol2scm ("combine-stencil"),
+ exprs));
+
+ Paper_line *pl = new Paper_line (sys_stencil, (int) penalty, false);
return scm_gc_unprotect_object (pl->self_scm ());
}
{
if (!valign_)
{
- valign_ =make_spanner ("VerticalAlignment", SCM_EOL);
+ valign_ = make_spanner ("VerticalAlignment", SCM_EOL);
valign_->set_bound (LEFT,unsmob_grob (get_property ("currentCommandColumn")));
-
}
}
if (valign_)
{
valign_->set_bound (RIGHT,unsmob_grob (get_property ("currentCommandColumn")));
- valign_ =0;
+ valign_ = 0;
}
}