var penalty_.
* lily/system.cc (get_line): Initialise Paper_line with
page-penalty's from original grobs.
* scm/define-music-properties.scm (all-music-properties): Add
page-penalty.
* scm/define-grob-properties.scm (all-grob-descriptions): Idem.
* lily/score-engraver.cc (try_music): Handle page-penalty.
* ly/declarations-init.ly (pagebreak, noPagebreak): New command.
+2004-04-11 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * lily/include/paper-line.hh (class Paper_line): New member
+ var penalty_.
+
+ * lily/system.cc (get_line): Initialise Paper_line with
+ page-penalty's from original grobs.
+
+ * scm/define-music-properties.scm (all-music-properties): Add
+ page-penalty.
+
+ * scm/define-grob-properties.scm (all-grob-descriptions): Idem.
+
+ * lily/score-engraver.cc (try_music): Handle page-penalty.
+
+ * ly/declarations-init.ly (pagebreak, noPagebreak): New command.
+
2004-04-11 Han-Wen Nienhuys <hanwen@xs4all.nl>
* ly/declarations-init.ly (melismaEnd): typo
(c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-
#ifndef PAPER_BOOK_HH
#define PAPER_BOOK_HH
source file of the GNU LilyPond music typesetter
- (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
*/
#ifndef PAPER_LINE_HH
#define PAPER_LINE_HH
class Paper_line
{
- DECLARE_SMOBS (Paper_line,)
+ DECLARE_SMOBS (Paper_line,);
SCM stencils_;
Offset dim_;
bool is_title_;
+ int penalty_;
public:
- Paper_line (Offset, SCM, bool = false);
+ Paper_line (Offset, SCM, int penalty = 0, bool = false);
int number_;
Offset dim () const;
SCM stencils () const;
bool is_title () const;
+ int penalty () const;
};
DECLARE_UNSMOB (Paper_line, paper_line);
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), is_title);
+ SCM_EOL),
+ -10001 * is_title, is_title);
return scm_gc_unprotect_object (pl->self_scm ());
}
#define TITLE_PENALTY -1
-Paper_line::Paper_line (Offset o, SCM stencils, bool is_title)
+Paper_line::Paper_line (Offset o, SCM stencils, int penalty, bool is_title)
{
dim_ = o;
stencils_ = stencils;
is_title_ = is_title;
+ penalty_ = penalty;
smobify_self ();
}
return is_title_;
}
+int
+Paper_line::penalty () const
+{
+ return penalty_;
+}
+
SCM
Paper_line::stencils () const
{
LY_DEFINE (ly_paper_line_break_score, "ly:paper-line-break-score",
1, 0, 0, (SCM line),
- "Return the score for breaking after @var{line}.")
+ "Return the score for page break after @var{line}.")
{
Paper_line *pl = unsmob_paper_line (line);
SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
- return scm_int2num (int (pl->is_title ()) * TITLE_PENALTY);
+ return scm_int2num (int (pl->penalty ()));
}
}
bool
-Score_engraver::try_music (Music*r)
+Score_engraver::try_music (Music *m)
{
- bool gotcha = Engraver_group_engraver::try_music (r);
+ if (Engraver_group_engraver::try_music (m))
+ return true;
- if (!gotcha && r->is_mus_type ("break-event"))
+ if (m->is_mus_type ("break-event"))
{
- gotcha = true;
-
SCM pen = command_column_->get_property ("penalty");
- Real total_penalty = is_number (pen)
- ? ly_scm2double (pen)
- : 0.0;
-
- SCM rpen = r->get_property ("penalty");
- if (is_number (rpen))
- total_penalty += ly_scm2double (rpen);
-
- if (total_penalty > 10000.0) // ugh. arbitrary.
+ Real total_penalty = is_number (pen) ? ly_scm2double (pen) : 0.0;
+
+ SCM mpen = m->get_property ("penalty");
+ if (is_number (mpen))
+ total_penalty += ly_scm2double (mpen);
+
+ command_column_->set_property ("penalty", scm_make_real (total_penalty));
+
+ /* ugh. arbitrary, hardcoded */
+ if (total_penalty > 10000.0)
forbid_breaks ();
- command_column_->set_property ("penalty",
- scm_make_real (total_penalty));
+ SCM page_pen = command_column_->get_property ("page-penalty");
+ if (is_number (page_pen))
+ {
+ Real total_pp = ly_scm2double (page_pen);
+ SCM mpage_pen = m->get_property ("page-penalty");
+ if (is_number (mpen))
+ total_pp += ly_scm2double (mpage_pen);
+
+ // FIXME: this never reaches a grob that System::get_line sees.
+ command_column_->set_property ("page-penalty",
+ scm_make_real (total_pp));
+ }
+ return true;
}
- return gotcha;
+ return false;
}
void
(c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include <math.h>
+
#include "axis-group-interface.hh"
#include "warn.hh"
#include "system.hh"
static void
set_loose_columns (System* which, Column_x_positions const *posns)
{
- for (int i = 0; i < posns->loose_cols_.size (); i++)
+ int loose_col_count = posns->loose_cols_.size ();
+ for (int i = 0; i < loose_col_count; i++)
{
int divide_over = 1;
Item *loose = dynamic_cast<Item*> (posns->loose_cols_[i]);
if (col->system_)
continue;
- Item * left = 0;
- Item * right = 0;
- do
+ Item *left = 0;
+ Item *right = 0;
+ while (1)
{
SCM between = loose->get_property ("between-cols");
if (!is_pair (between))
break;
-
Item *le = dynamic_cast<Item*> (unsmob_grob (ly_car (between)));
Item *re = dynamic_cast<Item*> (unsmob_grob (ly_cdr (between)));
if (!(le && re))
- break ;
+ break;
if (!left && le)
{
left = left->find_prebroken_piece (RIGHT);
}
- divide_over ++;
+ divide_over++;
loose = right = re->get_column ();
}
- while (1);
if (!right->get_system ())
right = right->find_prebroken_piece (LEFT);
if (Stencil *me = get_stencil ())
stencils = scm_cons (me->smobbed_copy (), stencils);
- /* Output stencils in three layers: 0, 1, 2. The default layer is
- 1.
+ /* Output stencils in three layers: 0, 1, 2. Default layer: 1.
- Start with layer 3, since scm_cons prepends to list.
-
- */
+ Start with layer 3, since scm_cons prepends to list. */
SCM all = get_property ("all-elements");
-
+
+ Real penalty = 0;
for (int i = LAYER_COUNT; i--;)
for (SCM s = all; is_pair (s); s = ly_cdr (s))
{
Offset (0, 0))
* Staff_symbol_referencer::staff_space (g);
- /*
- must copy the stencil, for we cannot change the stencil
- cached in G.
- */
+ /* 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);
+
+ // FIXME: never original
+ if (1 || g->original_)
+ {
+ SCM s = g->get_property ("page-penalty");
+ // FIXME: 'page-penalty is never set
+ // FIXME; page breaking is not discrete at +-10000
+ if (is_number (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);
+ stencils, penalty);
scm_gc_unprotect_object (pl->self_scm ());
return pl->self_scm ();
working with lyric sections)
%}
-break =#(make-event-chord (list (make-penalty-music -10001)))
-noBreak = #(make-event-chord (list (make-penalty-music 10001)))
+
+%% rather name \newline, \newpage ?
+break = #(make-event-chord (list (make-penalty-music -10001 0)))
+noBreak = #(make-event-chord (list (make-penalty-music 10001 0)))
+pagebreak = #(make-event-chord (list (make-penalty-music -10001 -10001)))
+noPagebreak = #(make-event-chord (list (make-penalty-music 0 10001)))
noBeam = #(make-music 'BeamForbidEvent)
pipeSymbol = #(make-music 'BarCheck)
\set Timing.measurePosition = #(ly:make-moment 0 1)
}
-newpage = \notes
-{
- \break
- %% FIXME: page break penalty should tickle into Paper_line
- %% \context Score \applyoutput
- %%#(outputproperty-compatibility (make-type-checker 'paper-column-interface)
- %% 'between-system-string "\\newpage")
-}
-
% dynamic ly:dir? text script, articulation script ly:dir?
oneVoice = #(context-spec-music (make-voice-props-revert) 'Voice)
voiceOne = #(context-spec-music (make-voice-props-set 0) 'Voice)
(padding ,ly:dimension? "Add this much extra space between
objects that are next to each other.")
- (penalty ,number? "Penalty for breaking at
-this column. 10000 or more means forbid linebreak, -10000 or less
-means force linebreak. Other values influence linebreaking decisions
+ (page-penalty ,number? "Penalty for page break at
+this column. 10000 or more means forbid linebreak, -10000 or less
+means force page break. Other values influence page breaking decisions
as a real penalty.")
-
+ (penalty ,number? "Penalty for line break at
+this column. 10000 or more means forbid line break, -10000 or less
+means force line break. Other values influence line breaking decisions
+as a real penalty.")
+
(pitch-max ,ly:pitch? "Top pitch for ambitus.")
(pitch-min ,ly:pitch? "Bottom pitch for ambitus.")
"This pitch was octavated by how many octaves?
For chord inversions, this is negative.")
(origin ,ly:input-location? "where was this piece of music defined?")
- (penalty ,number? "Penalty for break hint.")
+ (page-penalty ,number? "Penalty for page break hint.")
+ (penalty ,number? "Penalty for line break hint.")
(pitch ,ly:pitch? "the pitch of this note")
(pitch-alist ,list? "list of pitches jointly forming the scale of a key signature")
(pop-first ,boolean? "Do a revert before we try to do a override on some grob property.")
))
(BreakEvent
. (
- (description . "Creates a line break.
-
-Syntax: \\break.")
+ (description . "Create a line break, Syntax: \\break or page break, Syntax: \\pagebreak.")
(internal-class-name . "Event")
(types . (general-music break-event event))
(define-public (set-time-signature num den . rest)
(ly:export (apply make-time-signature-set `(,num ,den . ,rest))))
-(define-public (make-penalty-music pen)
+(define-public (make-penalty-music pen page-pen)
(make-music 'BreakEvent
- 'penalty pen))
+ 'penalty pen
+ 'page-penalty page-pen))
(define-public (make-articulation name)
(make-music 'ArticulationEvent