lilypond-devel
[Top][All Lists]

## Re: [patch] \label, page references

 From: Nicolas Sceaux Subject: Re: [patch] \label, page references Date: Sun, 27 May 2007 11:03:45 +0200 User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

Han-Wen Nienhuys <address@hidden> writes:

>> +  book_->paper_->set_variable (ly_symbol2scm ("label-page-table"),
>> +                           scm_reverse_x (label_page_table, SCM_EOL));
>
> This is acceptable if there is no other way, but I would like the rendering
> process to be a function, ie. in the ideal case, the rendering should not
> write
> into the Output_def. Can you think of a way to store this information
> elsewhere,
> or pass it as a parameter to the delayed evaluation? You may need to extend
> the
> stencil evaluation process to have another parameter.

OK. I used a paper variable because they are accessible by the markup
command. Would it be OK to add a SCM labels_' slot to
Paper_book? Then, in Paper_book::get_system_specs (), the
page_properties used in markup interpretation, which now is:
(layout-extract-page-properties (paper_->self_scm))
could become:
(cons (cons 'paper-book (self_scm))
(layout-extract-page-properties (paper_->self_scm)))
Thus, the paper_book instance is accessible by the markup command when
it is interpreted. With a new ly:paper-book-labels accessor, the markup
command can get the paper-book labels during the delayed evaluation.

>> +void
>> +set_label (SCM sys, SCM label)
>> +{
>> +  if (Paper_score *ps = dynamic_cast<Paper_score*> (unsmob_music_output
>> (sys)))
>> +    {
>> +      SCM labels = ps->layout ()->c_variable ("labels");
>> +      ps->layout ()->set_variable (ly_symbol2scm ("labels"),
>> +                               scm_cons (label, labels));
>> +    }
>> +  else if (Prob *pb = unsmob_prob (sys))
>
> idem.
>
>>
>> +      /* set the first system labels with the score ones */
>> +      if (i == 0)
>> +    {
>> +      SCM labels = pscore_->layout ()->c_variable ("labels");
>> +      system->set_property ("labels", labels);
>> +    }
>
> Wouldn't it be more appropriate to set labels for each broken
> System, so you could eg. refer to the page number of a rehearsal
> mark?  It would be difficult to transport the label symbol out of
> the initial markup -> stencil conversion, though. You might have to
> run a separate pass over all nested markups to discover the labels.

My first idea was to make labels use the same kind of logics as
breaks, ie have \label work inside music and at toplevel:

\markup { Act I } \label #'actI

\score {
{ ... \mark A \label #'markA ... }
} \label #'pieceXXX

So, in Paper_book::get_system_specs (), when a label marker is found,
the labels property of the first column of the previous score is set
(instead of the score itself, through its layout slot, as in the patch I
sent).  But then, propagating the labels from individual columns to the
systems would require to loop across every single column of each system
to collect the labels. Wouldn't that be too expensive? If this is
affordable, then that might be the best solution.

nicolas

`