+2002-03-31 Juergen Reuter <reuter@ipd.uka.de>
+
+ * 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 <hanwen@cs.uu.nl>
* input/regression/spacing-note-flags.ly: new file
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);
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)
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 ();
/*
* round filled box:
*
- * __________________________
- * / \ ^ / \
- * | |blot |
- * | + | |dia | +---|------
- * | |meter | ^
+ * __________________________________
+ * / \ ^ / \ ^
+ * | |blot | |
+ * | | |dia | | |
+ * | |meter | |
* |\ _ _ / v \ _ _ /| |
* | | |
* | | | Box
* | | |
* | _ _ _ _ | |
* |/ \ / \| |
- * | (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]),
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);
#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))
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_;
#include <stdio.h>
#include "line-of-score.hh"
+#include "paper-def.hh"
#include "paper-score.hh"
#include "paper-column.hh"
#include "item.hh"
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
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);
}
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);
} 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
{
(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