Happy Easter!
And here is another small but important step towards mensural notation.
(If you want to see an example, put "raggedright = ##t" into the paper
block, e.g. of wtk1-fugue.ly, and see, what happens!)
Greetings,
Juergen
diff -Naur lilypond-1.5.49/ChangeLog lilypond-1.5.49.NEW/ChangeLog
--- lilypond-1.5.49/ChangeLog Fri Mar 29 13:04:20 2002
+++ lilypond-1.5.49.NEW/ChangeLog Sun Mar 31 15:41:33 2002
@@ -1,3 +1,13 @@
+2002-03-31 Juergen Reuter <[EMAIL PROTECTED]>
+
+ * scm/ps.scm, ps/music-drawing-routines.ps, lily/lookup.cc,
+ lily/note-head-engraver: improved implementation of roundfilledbox
+ (according to Han-Wen's request)
+
+ * lily/include/spacing-spanner.hh, lily/spacing-spanner.cc,
+ lily/gourlay-breaking.cc, lily/staff-symbol.cc,
+ lily/simple-spacer.cc: ragged-right alignment
+
2002-03-29 Han-Wen <[EMAIL PROTECTED]>
* input/regression/spacing-note-flags.ly: new file
diff -Naur lilypond-1.5.49/lily/gourlay-breaking.cc
lilypond-1.5.49.NEW/lily/gourlay-breaking.cc
--- lilypond-1.5.49/lily/gourlay-breaking.cc Sun Mar 17 19:09:27 2002
+++ lilypond-1.5.49.NEW/lily/gourlay-breaking.cc Sun Mar 31 14:34:26 2002
@@ -76,6 +76,8 @@
Real minimal_demerits = infinity_f;
+ bool ragged = to_boolean (pscore_l_->paper_l_->get_scmvar ("raggedright"));
+
for (int start_idx = break_idx; start_idx--;)
{
Link_array<Grob> line = all.slice (breaks[start_idx], breaks[break_idx]+1);
@@ -89,7 +91,7 @@
Interval line_dims
= pscore_l_->paper_l_->line_dimensions_int
(optimal_paths[start_idx].line_i_);
Simple_spacer * sp = generate_spacing_problem (line, line_dims);
- sp->solve (&cp);
+ sp->solve (&cp, ragged);
delete sp;
if (fabs (cp.force_f_) > worst_force)
diff -Naur lilypond-1.5.49/lily/include/simple-spacer.hh
lilypond-1.5.49.NEW/lily/include/simple-spacer.hh
--- lilypond-1.5.49/lily/include/simple-spacer.hh Mon Mar 11 01:49:51 2002
+++ lilypond-1.5.49.NEW/lily/include/simple-spacer.hh Sun Mar 31 14:40:22 2002
@@ -42,7 +42,7 @@
Simple_spacer ();
- void solve (Column_x_positions *) const;
+ void solve (Column_x_positions *, bool) const;
void add_columns (Link_array<Grob>);
void my_solve_linelen ();
void my_solve_natural_len ();
diff -Naur lilypond-1.5.49/lily/lookup.cc lilypond-1.5.49.NEW/lily/lookup.cc
--- lilypond-1.5.49/lily/lookup.cc Mon Mar 25 23:47:03 2002
+++ lilypond-1.5.49.NEW/lily/lookup.cc Sun Mar 31 14:35:30 2002
@@ -87,11 +87,11 @@
/*
* round filled box:
*
- * __________________________
- * / \ ^ / \
- * | |blot |
- * | + | |dia | +---|------
- * | |meter | ^
+ * __________________________________
+ * / \ ^ / \ ^
+ * | |blot | |
+ * | | |dia | | |
+ * | |meter | |
* |\ _ _ / v \ _ _ /| |
* | | |
* | | | Box
@@ -101,19 +101,30 @@
* | | |
* | _ _ _ _ | |
* |/ \ / \| |
- * | (0,0) | v
- * | x | | +---|------
- * | | | |
- * \__|__/______________\__|__/
- * | |
- * | |
- * | |
- * |<------------------>|
+ * | | |
+ * | | | | |
+ * | | |
+ * x\_____/______________\_____/|_____v
+ * |(0,0) |
+ * | |
+ * | |
+ * |<-------------------------->|
* Box extent(X_AXIS)
*/
Molecule
Lookup::roundfilledbox (Box b, Real blotdiameter)
{
+ if (b.x ().length () < blotdiameter)
+ {
+ programming_error (_f ("round filled box horizontal extent smaller than blot;
+decreasing blot"));
+ blotdiameter = b.x ().length ();
+ }
+ if (b.y ().length () < blotdiameter)
+ {
+ programming_error (_f ("round filled box vertical extent smaller than blot;
+decreasing blot"));
+ blotdiameter = b.y ().length ();
+ }
+
SCM at = (scm_list_n (ly_symbol2scm ("roundfilledbox"),
gh_double2scm (-b[X_AXIS][LEFT]),
gh_double2scm (b[X_AXIS][RIGHT]),
diff -Naur lilypond-1.5.49/lily/note-head.cc lilypond-1.5.49.NEW/lily/note-head.cc
--- lilypond-1.5.49/lily/note-head.cc Wed Mar 27 00:16:22 2002
+++ lilypond-1.5.49.NEW/lily/note-head.cc Sun Mar 31 14:35:51 2002
@@ -77,16 +77,13 @@
Real blotdiameter = ledgerlinethickness;
// (me->paper_l ()->get_var ("blotdiameter"));
Interval y_extent =
- Interval (-0.5*(ledgerlinethickness - blotdiameter),
- +0.5*(ledgerlinethickness - blotdiameter));
+ Interval (-0.5*(ledgerlinethickness),
+ +0.5*(ledgerlinethickness));
Box ledger_line (x_extent, y_extent);
- // FIXME: Currently need blotdiameter factor 2.0 to compensate
- // for error somewhere else. (Maybe draw_box confuses radius
- // and diameter?)
#if 1
- Molecule proto_ledger_line =
- Lookup::roundfilledbox (ledger_line, ledgerlinethickness );
+ Molecule proto_ledger_line =
+ Lookup::roundfilledbox (ledger_line, blotdiameter);
#else
Molecule proto_ledger_line = // if you like it the old way
Lookup::filledbox (ledger_line);
diff -Naur lilypond-1.5.49/lily/simple-spacer.cc
lilypond-1.5.49.NEW/lily/simple-spacer.cc
--- lilypond-1.5.49/lily/simple-spacer.cc Sat Mar 23 02:43:29 2002
+++ lilypond-1.5.49.NEW/lily/simple-spacer.cc Sun Mar 31 14:36:48 2002
@@ -314,7 +314,7 @@
#include <stdio.h>
void
-Simple_spacer::solve (Column_x_positions *positions) const
+Simple_spacer::solve (Column_x_positions *positions, bool ragged) const
{
positions->force_f_ = force_f_;
if ((force_f_ < 0))
@@ -333,7 +333,15 @@
positions->config_.push (indent_f_);
for (int i=0; i <springs_.size (); i++)
{
- positions->config_.push (positions->config_.top () + springs_[i].length
(force_f_));
+ if (ragged)
+ {
+ // ragged right operation: do not apply any force
+ positions->config_.push (positions->config_.top () + springs_[i].length
+(0.0));
+ }
+ else
+ {
+ positions->config_.push (positions->config_.top () + springs_[i].length
+(force_f_));
+ }
}
positions->cols_ = spaced_cols_;
positions->loose_cols_ = loose_cols_;
diff -Naur lilypond-1.5.49/lily/spacing-spanner.cc
lilypond-1.5.49.NEW/lily/spacing-spanner.cc
--- lilypond-1.5.49/lily/spacing-spanner.cc Fri Mar 29 13:04:25 2002
+++ lilypond-1.5.49.NEW/lily/spacing-spanner.cc Sun Mar 31 15:37:10 2002
@@ -11,6 +11,7 @@
#include <stdio.h>
#include "line-of-score.hh"
+#include "paper-def.hh"
#include "paper-score.hh"
#include "paper-column.hh"
#include "item.hh"
@@ -554,7 +555,10 @@
max_fixed_note_space = increment;
}
- Spaceable_grob::add_spring (lc, rc, max_note_space, 1 / (max_note_space
-max_fixed_note_space), expand_only);
+ bool ragged = to_boolean (me->paper_l ()->get_scmvar ("raggedright"));
+ Real strength = (ragged) ? 1.0 : 1 / (max_note_space - max_fixed_note_space);
+ Real distance = (ragged) ? max_fixed_note_space : max_note_space;
+ Spaceable_grob::add_spring (lc, rc, distance, strength, expand_only);
}
void
@@ -649,7 +653,10 @@
works on all architectures.
*/
- Spaceable_grob::add_spring (l, r, max_space, 1/(max_space - max_fixed), false);
+ bool ragged = to_boolean (me->paper_l ()->get_scmvar ("raggedright"));
+ Real strength = (ragged) ? 1.0 : 1 / (max_space - max_fixed);
+ Real distance = (ragged) ? max_fixed : max_space;
+ Spaceable_grob::add_spring (l, r, distance, strength, false);
}
diff -Naur lilypond-1.5.49/lily/staff-symbol.cc
lilypond-1.5.49.NEW/lily/staff-symbol.cc
--- lilypond-1.5.49/lily/staff-symbol.cc Sun Mar 24 21:46:54 2002
+++ lilypond-1.5.49.NEW/lily/staff-symbol.cc Sun Mar 31 14:35:06 2002
@@ -27,11 +27,24 @@
Grob * common
= sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
- Real width =
- // right_shift - left_shift
- + sp->get_bound (RIGHT)->relative_coordinate (common , X_AXIS)
- - sp->get_bound (LEFT)->relative_coordinate (common, X_AXIS)
- ;
+ bool ragged = to_boolean (me->paper_l ()->get_scmvar ("raggedright"));
+ Real width;
+ if (ragged)
+ {
+ // *prevent* staff symbol from being ragged right
+ width =
+ me->paper_l ()->get_var ("linewidth")
+ - sp->get_bound (LEFT)->relative_coordinate (common, X_AXIS)
+ ;
+ }
+ else
+ {
+ width =
+ // right_shift - left_shift
+ + sp->get_bound (RIGHT)->relative_coordinate (common , X_AXIS)
+ - sp->get_bound (LEFT)->relative_coordinate (common, X_AXIS)
+ ;
+ }
Real t = me->paper_l ()->get_var ("stafflinethickness");
int l = Staff_symbol::line_count (me);
diff -Naur lilypond-1.5.49/ps/music-drawing-routines.ps
lilypond-1.5.49.NEW/ps/music-drawing-routines.ps
--- lilypond-1.5.49/ps/music-drawing-routines.ps Sun Mar 17 19:38:01 2002
+++ lilypond-1.5.49.NEW/ps/music-drawing-routines.ps Sun Mar 31 14:38:05 2002
@@ -52,6 +52,33 @@
} ifelse
} bind def
+/draw_round_box % breapth width depth height blot
+{
+ /blot exch def
+
+ 0 setlinecap
+ blot setlinewidth
+ 1 setlinejoin
+
+ blot 2 div sub /h exch def
+ blot 2 div sub /d exch def
+ blot 2 div sub /w exch def
+ blot 2 div sub /b exch def
+
+ b neg d neg moveto
+ b w add 0 rlineto
+ 0 d h add rlineto
+ b w add neg 0 rlineto
+ 0 d h add neg rlineto
+
+ currentdict /testing known {
+ %% outline only, for testing:
+ stroke
+ }{
+ closepath gsave stroke grestore fill
+ } ifelse
+} bind def
+
% Nice beam with rounded corners
/draw_beam % slope width thick
{
diff -Naur lilypond-1.5.49/scm/ps.scm lilypond-1.5.49.NEW/scm/ps.scm
--- lilypond-1.5.49/scm/ps.scm Mon Mar 25 23:47:03 2002
+++ lilypond-1.5.49.NEW/scm/ps.scm Sun Mar 31 14:37:43 2002
@@ -160,19 +160,15 @@
(string-append (numbers->string (list breapth width depth height))
" draw_box" ))
+(define (roundfilledbox x width y height blotdiam)
+ (string-append " "
+ (numbers->string
+ (list x width y height blotdiam)) " draw_round_box"))
+
(define (dot x y radius)
(string-append " "
(numbers->string
(list x y radius)) " draw_dot"))
-
-(define (roundfilledbox x width y height blotdiam)
- (string-append " "
- (dot (- 0 x) (- 0 y) (/ blotdiam 2))
- (dot width (- 0 y) (/ blotdiam 2))
- (dot width height (/ blotdiam 2))
- (dot (- 0 x) height (/ blotdiam 2))
- (filledbox (+ x (/ blotdiam 2)) (+ width (/ blotdiam 2)) y height)
- (filledbox x width (+ y (/ blotdiam 2)) (+ height (/ blotdiam 2)))))
;; obsolete?
(define (font-def i s)