From b0722af04579cd67f38c3f3ac51762d186614664 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 31 Mar 2002 22:25:59 +0000 Subject: [PATCH] '' --- ChangeLog | 10 ++++++++++ lily/gourlay-breaking.cc | 4 +++- lily/include/simple-spacer.hh | 2 +- lily/lookup.cc | 37 +++++++++++++++++++++++------------ lily/note-head.cc | 11 ++++------- lily/simple-spacer.cc | 12 ++++++++++-- lily/spacing-spanner.cc | 11 +++++++++-- lily/staff-symbol.cc | 23 +++++++++++++++++----- ps/music-drawing-routines.ps | 27 +++++++++++++++++++++++++ scm/ps.scm | 14 +++++-------- 10 files changed, 111 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8d2c85064..2cf3f21717 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2002-03-31 Juergen Reuter + + * 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 * input/regression/spacing-note-flags.ly: new file diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc index b61a750562..492e2c1a4f 100644 --- a/lily/gourlay-breaking.cc +++ b/lily/gourlay-breaking.cc @@ -76,6 +76,8 @@ Gourlay_breaking::do_solve () const 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 line = all.slice (breaks[start_idx], breaks[break_idx]+1); @@ -89,7 +91,7 @@ Gourlay_breaking::do_solve () const 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 --git a/lily/include/simple-spacer.hh b/lily/include/simple-spacer.hh index 58bd34cf7c..b658f5354b 100644 --- a/lily/include/simple-spacer.hh +++ b/lily/include/simple-spacer.hh @@ -42,7 +42,7 @@ struct Simple_spacer Simple_spacer (); - void solve (Column_x_positions *) const; + void solve (Column_x_positions *, bool) const; void add_columns (Link_array); void my_solve_linelen (); void my_solve_natural_len (); diff --git a/lily/lookup.cc b/lily/lookup.cc index f25983e47c..e8f5bb03fc 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -87,11 +87,11 @@ Lookup::filledbox (Box b) /* * round filled box: * - * __________________________ - * / \ ^ / \ - * | |blot | - * | + | |dia | +---|------ - * | |meter | ^ + * __________________________________ + * / \ ^ / \ ^ + * | |blot | | + * | | |dia | | | + * | |meter | | * |\ _ _ / v \ _ _ /| | * | | | * | | | Box @@ -101,19 +101,30 @@ Lookup::filledbox (Box b) * | | | * | _ _ _ _ | | * |/ \ / \| | - * | (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 --git a/lily/note-head.cc b/lily/note-head.cc index 08b7c057c6..23f407622f 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -77,16 +77,13 @@ Note_head::brew_ledger_lines (Grob *me, 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 --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index 3590d12f40..be05115a6d 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -314,7 +314,7 @@ Simple_spacer::add_columns (Link_array cols) #include 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 @@ Simple_spacer::solve (Column_x_positions *positions) const positions->config_.push (indent_f_); for (int i=0; i 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 --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index fd9585f135..fbad90b0ed 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -11,6 +11,7 @@ #include #include "line-of-score.hh" +#include "paper-def.hh" #include "paper-score.hh" #include "paper-column.hh" #include "item.hh" @@ -554,7 +555,10 @@ Spacing_spanner::musical_column_spacing (Grob *me, Item * lc, Item *rc, Real inc 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 @@ Spacing_spanner::breakable_column_spacing (Grob*me, Item* l, Item *r,Moment shor 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 --git a/lily/staff-symbol.cc b/lily/staff-symbol.cc index de2ecf4e42..4eeb24b864 100644 --- a/lily/staff-symbol.cc +++ b/lily/staff-symbol.cc @@ -27,11 +27,24 @@ Staff_symbol::brew_molecule (SCM smob) 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 --git a/ps/music-drawing-routines.ps b/ps/music-drawing-routines.ps index 93e82f9aaf..a3ad13a895 100644 --- a/ps/music-drawing-routines.ps +++ b/ps/music-drawing-routines.ps @@ -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 --git a/scm/ps.scm b/scm/ps.scm index 75cf347d89..de78697958 100644 --- a/scm/ps.scm +++ b/scm/ps.scm @@ -160,20 +160,16 @@ (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) (string-append -- 2.39.2