]> git.donarmstrong.com Git - lilypond.git/commitdiff
''
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 31 Mar 2002 22:25:59 +0000 (22:25 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 31 Mar 2002 22:25:59 +0000 (22:25 +0000)
ChangeLog
lily/gourlay-breaking.cc
lily/include/simple-spacer.hh
lily/lookup.cc
lily/note-head.cc
lily/simple-spacer.cc
lily/spacing-spanner.cc
lily/staff-symbol.cc
ps/music-drawing-routines.ps
scm/ps.scm

index c8d2c8506497fcb51d0818766cbae0b6d2295984..2cf3f2171704266c679d70b0b2e2379bc2d621f2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+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
index b61a750562d3c6718cd8d3ff702a54be32ab9d78..492e2c1a4ff32bc31fb4bc7a422e8ed5753d7ce1 100644 (file)
@@ -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<Grob> 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)
index 58bd34cf7cfd1478a9ba9dcb90bb1339fb0da5a5..b658f5354b7d207be29e471c6984a3a252dc61b1 100644 (file)
@@ -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<Grob>);
   void my_solve_linelen ();
   void my_solve_natural_len ();
index f25983e47ca7c4a4ea4dd56bcc5ab2f345c860af..e8f5bb03fc9d09b50a2ce6d1e657e41b29ca58db 100644 (file)
@@ -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]),
index 08b7c057c6176fe8f58e39a1b104d83e0129846a..23f407622f1e4044055c34bb0f6a7a346660f1b4 100644 (file)
@@ -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);
index 3590d12f4027051879917abd8c4b3ff2c4eed791..be05115a6dda560bf32aae8b4e085e5fa1ce4f4b 100644 (file)
@@ -314,7 +314,7 @@ Simple_spacer::add_columns (Link_array<Grob> cols)
 #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 @@ Simple_spacer::solve (Column_x_positions *positions) const
   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_;
index fd9585f1352e2b8dfe2af52a136b3cacbe2c7b0e..fbad90b0ed666b7351eec1e7f6258b3def709bab 100644 (file)
@@ -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 @@ 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);
 }
 
 
index de2ecf4e423e0ac8e2c3f4c32846b3d283d8b8ac..4eeb24b8645d4ac9783fb6ba556a32cf8913a69f 100644 (file)
@@ -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);
index 93e82f9aaff2d689546feffac159a5cd4a2cdd6d..a3ad13a895a561c659a2499f09c5dcc1b35ed683 100644 (file)
        } 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 
 {
index 75cf347d89fa1cd3e89c7098e761c72f619b1b39..de78697958001c5b410c397009738f92fdb3869d 100644 (file)
   (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