]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/new-slur.cc: Resolve conflicts.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 18 Jul 2004 18:53:55 +0000 (18:53 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 18 Jul 2004 18:53:55 +0000 (18:53 +0000)
* lily/stem-engraver.cc (add_script):
(make_stem): New method.

* lily/include/script-interface.hh:
* lily/script-interface.cc: New file.

* lily/include/script.hh:
* lily/script.cc: Remove.

* lily/music.cc (duration_log): New method.

* lily/script.cc (struct Skript): Remove.

* lily/new-slur.cc (get_base_attachments): Try at articulations.
Lots of coding cleanups (Stom).

15 files changed:
ChangeLog
SConstruct
lily/drum-note-engraver.cc
lily/dynamic-engraver.cc
lily/include/music.hh
lily/include/script-interface.hh [new file with mode: 0644]
lily/include/script.hh [deleted file]
lily/music.cc
lily/new-fingering-engraver.cc
lily/new-slur.cc
lily/script-engraver.cc
lily/script-interface.cc [new file with mode: 0644]
lily/script.cc [deleted file]
lily/stem-engraver.cc
lily/stem.cc

index 2de7714c4705d092dc300583fc5533e24c9848e9..e565c3c5ed7454f71714236e3e810bc809e22acd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2004-07-18  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * lily/new-slur.cc: Resolve conflicts.
+
+       * lily/stem-engraver.cc (add_script):
+       (make_stem): New method.
+
+       * lily/include/script-interface.hh:
+       * lily/script-interface.cc: New file.
+
+       * lily/include/script.hh:
+       * lily/script.cc: Remove.
+
+       * lily/music.cc (duration_log): New method.
+
+       * lily/script.cc (struct Skript): Remove.
+
+       * lily/new-slur.cc (get_base_attachments): Try at articulations.
+       Lots of coding cleanups (Stom).
+
 2004-07-18  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
        * lily/new-slur.cc (avoid_staff_line): new function: avoid
index 63d9a4e2c00be7e675497c80b5dac9aea62f2b24..1b34dd33f34a5beafbeb7d2aecf3d6d0bbedc093 100644 (file)
@@ -761,7 +761,7 @@ env.Command (www_ball, web_ball,
             ['rm -rf $out/tmp',
              'mkdir -p $absbuild/$out/tmp',
              'tar -C $absbuild/$out/tmp -xzf $SOURCE',
-             'cd $absbuild/$out/tmp && for i in $$(find . -name "$out"; do mv $i out-www; done',
+             'cd $absbuild/$out/tmp && for i in $$(find . -name "$out"); do mv $$i $$(dirname $$i)/out-www; done',
              'tar -C $absbuild/$out/tmp -czf $TARGET .'])
 env.Alias ('web', www_ball)
 
index a668d3408b884f8fe4078f364e4c8f512e5c117c..3143bcf78c9ced40c3e8957fc16e447516ddfc73 100644 (file)
@@ -11,7 +11,7 @@
 #include "engraver.hh"
 #include "warn.hh"
 #include "side-position-interface.hh"
-#include "script.hh"
+#include "script-interface.hh"
 #include "stem.hh"
 #include "note-column.hh"
 
index 8b476249312a452717e9a73b17f8a25d7a2f386f..705cdfa3284a433db347bcb5fedb52af1419a20e 100644 (file)
@@ -18,7 +18,7 @@
 #include "directional-element-interface.hh"
 #include "context.hh"
 #include "axis-group-interface.hh"
-#include "script.hh"
+#include "script-interface.hh"
 
 /*
   TODO:
index 5d95c29103e15386a3dcd8211c4fea971c411051..0b27e8c2c45bfad2a1d0a693c8bf148046a3cf0e 100644 (file)
@@ -16,8 +16,7 @@
 #include "smobs.hh"
 #include "music-constructor.hh"
 
-
-#define is_mus_type(x) internal_is_music_type(ly_symbol2scm (x))
+#define is_mus_type(x) internal_is_music_type (ly_symbol2scm (x))
 
 /** Music is anything that has duration and supports both time compression and
   transposition.
@@ -46,6 +45,7 @@ public:
   void internal_set_property (SCM , SCM val);
   SCM get_property_alist (bool mut) const;
   bool internal_is_music_type (SCM) const;
+  int duration_log () const;
   
   virtual Pitch to_relative_octave (Pitch);
   String name () const;
diff --git a/lily/include/script-interface.hh b/lily/include/script-interface.hh
new file mode 100644 (file)
index 0000000..fbef775
--- /dev/null
@@ -0,0 +1,33 @@
+/*   
+  script-interface.hh -- 
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#ifndef SCRIPT_INTERFACE_HH
+#define SCRIPT_INTERFACE_HH
+
+#include "lily-guile.hh"
+#include "lily-proto.hh"
+
+/**
+   Articulation marks (and the like) that are attached to notes/stems.
+   Needs support from Staff_side for proper operation.  Staff_side
+   handles the positioning.
+*/
+class Script_interface
+{
+public:
+  static Stencil get_stencil (Grob *, Direction d);
+  static bool has_interface (Grob *);
+  DECLARE_SCHEME_CALLBACK (print, (SCM ));
+  DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
+};
+
+void make_script_from_event (Grob *p, SCM *descr, Context *tg,
+                            SCM type, int index);
+
+#endif /* SCRIPT_INTERFACE_HH */
+
diff --git a/lily/include/script.hh b/lily/include/script.hh
deleted file mode 100644 (file)
index 6a74154..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*   
-  script.hh -- declare Script
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
- */
-
-#ifndef SCRIPT_HH
-#define SCRIPT_HH
-
-#include "lily-guile.hh"
-#include "lily-proto.hh"
-
-/**
-   Articulation marks (and the like) that are attached to notes/stems.
-   Needs support from Staff_side for proper operation.  Staff_side
-   handles the positioning.
-*/
-class Script_interface
-{
-public:
-  static Stencil get_stencil (Grob*,Direction d);
-  
-  static bool  has_interface (Grob*);
-  DECLARE_SCHEME_CALLBACK (print, (SCM ));
-  DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM ));
-};
-
-void make_script_from_event (Grob *p,
-                            SCM * descr, Context *tg,
-                            SCM type, 
-                            int index);
-#endif /* Stem_SCRIPT_HH */
-
index 4d882ba98339d42d9b2237309a6bbbb94bd11f4c..161bf21ab79caf7144ddd4771727fc13e5d2da2f 100644 (file)
@@ -6,6 +6,7 @@
   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
+#include "duration.hh"
 #include "input-smob.hh"
 #include "ly-smobs.icc"
 #include "main.hh"
@@ -15,7 +16,6 @@
 #include "score.hh"
 #include "warn.hh"
 
-
 bool
 Music::internal_is_music_type (SCM k) const
 {
@@ -215,6 +215,13 @@ Music::origin () const
   return ip ? ip : & dummy_input_global;
 }
 
+int
+Music::duration_log () const
+{
+  if (is_mus_type ("rhythmic-event"))
+    return unsmob_duration (get_property ("duration"))->duration_log ();
+  return 0;
+}
 
 Music*
 make_music_by_name (SCM sym)
index c9a359e9a4427d64c51b6ae98de10b6bc63032ee..2f7800d8c9a190591b8f2394680e8c198266879c 100644 (file)
@@ -15,7 +15,7 @@
 #include "stem.hh"
 #include "rhythmic-head.hh"
 #include "self-alignment-interface.hh"
-#include "script.hh"
+#include "script-interface.hh"
 #include "stem.hh"
 
 struct Finger_tuple
index d055e11ec200de36cc62efd1ab157c3c5d537ef9..335e145939579281182ef7e3021fc0f9cee08b5a 100644 (file)
@@ -39,9 +39,9 @@
   - collisions with accidentals
   - collisions with scripts (staccato!)
   - 
-  
 */
-struct Encompass_info {
+struct Encompass_info
+{
   Real x_;
   Real stem_;
   Real head_;
@@ -53,8 +53,8 @@ struct Encompass_info {
   }
 };
 
-struct Bound_info {
-
+struct Bound_info
+{
   Box stem_extent_;
   Direction stem_dir_;
   Grob *bound_;
@@ -64,9 +64,10 @@ struct Bound_info {
   Grob *stem_;
   Interval slur_head_extent_;
   Real neighbor_y_;
-  Real staff_space_ ;
+  Real staff_space_;
   
-  Bound_info () {
+  Bound_info ()
+  {
     stem_ = 0;
     neighbor_y_ = 0;
     staff_ = 0;
@@ -81,18 +82,18 @@ struct Bound_info {
 */
 struct Slur_score_parameters
 {
-  int SLUR_REGION_SIZE ;
-  Real HEAD_ENCOMPASS_PENALTY ;
-  Real STEM_ENCOMPASS_PENALTY ;
-  Real CLOSENESS_FACTOR ;
-  Real EDGE_ATTRACTION_FACTOR ; 
-  Real SAME_SLOPE_PENALTY ;
-  Real STEEPER_SLOPE_FACTOR ;
-  Real NON_HORIZONTAL_PENALTY ;
-  Real HEAD_STRICT_FREE_SPACE ;
-  Real MAX_SLOPE ;
-  Real MAX_SLOPE_FACTOR ;
-  Real FREE_HEAD_DISTANCE ;
+  int SLUR_REGION_SIZE;
+  Real HEAD_ENCOMPASS_PENALTY;
+  Real STEM_ENCOMPASS_PENALTY;
+  Real CLOSENESS_FACTOR;
+  Real EDGE_ATTRACTION_FACTOR;
+  Real SAME_SLOPE_PENALTY;
+  Real STEEPER_SLOPE_FACTOR;
+  Real NON_HORIZONTAL_PENALTY;
+  Real HEAD_STRICT_FREE_SPACE;
+  Real MAX_SLOPE;
+  Real MAX_SLOPE_FACTOR;
+  Real FREE_HEAD_DISTANCE;
   Slur_score_parameters ();
 };
 
@@ -103,14 +104,14 @@ init_score_param (Slur_score_parameters *score_param)
   score_param->HEAD_ENCOMPASS_PENALTY = 1000.0;
   score_param->STEM_ENCOMPASS_PENALTY = 30.0;
   score_param->CLOSENESS_FACTOR = 10;
-  score_param->EDGE_ATTRACTION_FACTOR = 4; 
+  score_param->EDGE_ATTRACTION_FACTOR = 4;
   score_param->SAME_SLOPE_PENALTY = 20;
   score_param->STEEPER_SLOPE_FACTOR = 50;
   score_param->NON_HORIZONTAL_PENALTY = 15;
   score_param->HEAD_STRICT_FREE_SPACE = 0.2;
   score_param->MAX_SLOPE = 1.1;
   score_param->MAX_SLOPE_FACTOR = 10;
-  score_param->FREE_HEAD_DISTANCE = 0.3 ;
+  score_param->FREE_HEAD_DISTANCE = 0.3;
 }
 
 Slur_score_parameters::Slur_score_parameters()
@@ -120,7 +121,8 @@ Slur_score_parameters::Slur_score_parameters()
 
 #define DEBUG_SLUR_QUANTING 1
 
-struct Slur_score {
+struct Slur_score
+{
   Drul_array<Offset> attachment_;
   Real score_;
   Bezier curve_;
@@ -129,7 +131,8 @@ struct Slur_score {
   String score_card_;
 #endif
 
-  Slur_score() {
+  Slur_score()
+  {
     score_ = 0.0;
   }
 };
@@ -139,115 +142,109 @@ class New_slur
 public:
   static void add_column (Grob *me, Grob *col);
   DECLARE_SCHEME_CALLBACK (print, (SCM));
-  static void score_slopes (Grob * me,  Grob *common[],
-                           Slur_score_parameters * score_param,
-                           
+  static void score_slopes (Grob *me, Grob *common[],
+                           Slur_score_parameters *score_param,
                            Drul_array<Bound_info>,
                            Drul_array<Offset> base_attach,
-                           Array<Slur_score> * scores);
-  
-  static void score_edges (Grob * me,  Grob *common[],
-                          Slur_score_parameters * score_param,
-                          
+                           Array<Slur_score> *scores);
+
+  static void score_edges (Grob *me, Grob *common[],
+                          Slur_score_parameters *score_param,
                           Drul_array<Bound_info> extremes,
                           Drul_array<Offset> base_attach,
-                          Array<Slur_score> * scores);
-  static void score_encompass (Grob * me,  Grob *common[],
+                          Array<Slur_score> *scores);
+  static void score_encompass (Grob *me, Grob *common[],
                               Slur_score_parameters*,
                               Drul_array<Bound_info>,
-                              Drul_array<Offset>, Array<Slur_score> * scores);
-  static Bezier avoid_staff_line (Grob * me,  Grob **common,
-                          Drul_array<Bound_info> extremes,
-                          Bezier bez);
+                              Drul_array<Offset>, Array<Slur_score> *scores);
+  static Bezier avoid_staff_line (Grob *me, Grob **common,
+                                 Drul_array<Bound_info> extremes,
+                                 Bezier bez);
 
   static Encompass_info get_encompass_info (Grob *me,
                                            Grob *col,
-                                           Grob **common) ;
-  static void set_interface (Grob*);
-  static bool  has_interface (Grob*);
+                                           Grob **common);
+  static void set_interface (Grob *);
+  static bool  has_interface (Grob *);
   static Bezier get_curve (Grob *me);
-  static Bezier get_bezier (Grob *me, Drul_array<Offset>,Real,Real);
+  static Bezier get_bezier (Grob *me, Drul_array<Offset>, Real, Real);
   static Direction get_default_dir (Grob *me);
   DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
   DECLARE_SCHEME_CALLBACK (height, (SCM,SCM));
 
-  static void set_end_points (Grob*);
+  static void set_end_points (Grob *);
   static Real get_boundary_notecolumn_y (Grob *me, Direction dir);
-  static Real broken_trend_y (Grob *me, Grob**, Direction dir);
+  static Real broken_trend_y (Grob *me, Grob **, Direction dir);
   static void set_control_points (Grob *me);
-  static Drul_array<Bound_info> get_bound_info (Spanner* me,
-                                               Grob **common);
+  static Drul_array<Bound_info> get_bound_info (Spanner *me, Grob **common);
 
-  static void generate_curves (Grob*me,
+  static void generate_curves (Grob *me,
                               Grob *common[],
                               Drul_array<Bound_info> extremes,
                               Drul_array<Offset> base_attach,
-                              Array<Slur_score> * scores);
-  static Array<Slur_score> enumerate_attachments (Grob * me,  Grob *common[],
-                                                 Slur_score_parameters * score_param,
-                                                 Drul_array<Bound_info> extremes,
-                                                 Drul_array<Offset> base_attachment, Drul_array<Real> end_ys);
-  ;
-  static  Drul_array<Offset> get_base_attachments (Spanner*sp,
-                                                  Grob **common,
-                                                  Drul_array<Bound_info> extremes);
-  static  Drul_array<Real> get_y_attachment_range (Spanner*sp,
-                                                  Grob **common,
-                                                  Drul_array<Bound_info> extremes,
-                                                  Drul_array<Offset> base_attachment);
+                              Array<Slur_score> *scores);
+  static Array<Slur_score> enumerate_attachments
+  (Grob *me, Grob *common[], Slur_score_parameters *score_param,
+   Drul_array<Bound_info> extremes,
+   Drul_array<Offset> base_attachment, Drul_array<Real> end_ys);
+  static Drul_array<Offset> get_base_attachments
+  (Spanner *sp, Grob **common, Drul_array<Bound_info> extremes);
+  static Drul_array<Real> get_y_attachment_range
+  (Spanner *sp, Grob **common, Drul_array<Bound_info> extremes,
+   Drul_array<Offset> base_attachment);
 };
 
-/*
-  HDIR indicates the direction for the slur.
- */
+/* HDIR indicates the direction for the slur.  */
 Real
-New_slur::broken_trend_y (Grob *me, Grob**common, Direction hdir)
+New_slur::broken_trend_y (Grob *me, Grob **common, Direction hdir)
 {
-  /*
-    A broken slur should maintain the same vertical trend
-    the unbroken slur would have had.
-  */
+  /* A broken slur should maintain the same vertical trend
+    the unbroken slur would have had.  */
   Real by = 0.0;
-  if (Spanner *mother =  dynamic_cast<Spanner*> (me->original_))
+  if (Spanner *mother = dynamic_cast<Spanner*> (me->original_))
     {
       int k = broken_spanner_index (dynamic_cast<Spanner*> (me));
       int j = k + hdir;
       if (j < 0 || j >= mother->broken_intos_.size ())
        return by;
-      
-      Grob *neighbor = mother->broken_intos_[j];      
+
+      Grob *neighbor = mother->broken_intos_[j];
       if (hdir == RIGHT)
        neighbor->set_property ("direction",
                                me->get_property ("direction"));
 
-      Spanner * common_mother = dynamic_cast<Spanner*> (common[Y_AXIS]->original_);
-      int common_k = broken_spanner_index (dynamic_cast<Spanner*> (common[Y_AXIS]));
+      Spanner *common_mother
+       = dynamic_cast<Spanner*> (common[Y_AXIS]->original_);
+      int common_k
+       = broken_spanner_index (dynamic_cast<Spanner*> (common[Y_AXIS]));
       int common_j = common_k + hdir;
 
       if (common_j < 0 || common_j >= common_mother->broken_intos_.size())
        return by;
-      
 
       Grob *common_next_system = common_mother->broken_intos_[common_j];
-      Link_array<Grob> neighbor_cols = 
-       Pointer_group_interface__extract_grobs (neighbor, (Grob*)0, "note-columns");
+      Link_array<Grob> neighbor_cols
+       = Pointer_group_interface__extract_grobs (neighbor, (Grob *)0,
+                                                 "note-columns");
 
-      Grob * neighbor_col = (hdir == RIGHT) ? neighbor_cols[0] : neighbor_cols.top ();
-      Grob * neighbor_common = common_next_system->common_refpoint (neighbor_col, Y_AXIS);
+      Grob *neighbor_col
+       = (hdir == RIGHT) ? neighbor_cols[0] : neighbor_cols.top ();
+      Grob *neighbor_common
+       = common_next_system->common_refpoint (neighbor_col, Y_AXIS);
 
       Direction vdir = get_grob_direction (me);
-      Real neighbor_y =
-       neighbor_col->extent (neighbor_common, Y_AXIS)
+      Real neighbor_y
+       neighbor_col->extent (neighbor_common, Y_AXIS)
        .linear_combination (int(neighbor_cols.size()==1 ? CENTER : vdir))
        - common_next_system->relative_coordinate (neighbor_common, Y_AXIS);
 
-      Link_array<Grob> my_cols = 
-       Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
-      
+      Link_array<Grob> my_cols
+       = Pointer_group_interface__extract_grobs (me, (Grob *)0,
+                                                 "note-columns");
+
       Grob *extreme_col = (hdir == RIGHT) ? my_cols.top() : my_cols[0];
       Real y = extreme_col->extent (common[Y_AXIS], Y_AXIS)
-       .linear_combination (int ((my_cols.size()==1) ? CENTER : vdir));
-      
+       .linear_combination (int ((my_cols.size() == 1) ? CENTER : vdir));
       by = (y*neighbor_cols.size() + neighbor_y*my_cols.size()) /
        (my_cols.size() + neighbor_cols.size());
     }
@@ -274,20 +271,21 @@ New_slur::add_column (Grob*me, Grob*n)
 Encompass_info
 New_slur::get_encompass_info (Grob *me,
                              Grob *col,
-                             Grob **common) 
+                             Grob **common)
 {
   Grob* stem = unsmob_grob (col->get_property ("stem"));
 
   Encompass_info ei;
-  
+
   Direction dir = get_grob_direction (me);
-  
+
   if (!stem)
     {
       programming_error ("No stem for note column?");
       ei.x_ = col->relative_coordinate (common[X_AXIS], X_AXIS);
-      ei.head_ = ei.stem_ = col->extent (common[Y_AXIS], Y_AXIS)[get_grob_direction (me)];
-      return ei;  
+      ei.head_ = ei.stem_ = col->extent (common[Y_AXIS],
+                                        Y_AXIS)[get_grob_direction (me)];
+      return ei;
     }
   Direction stem_dir = get_grob_direction (stem);
 
@@ -300,20 +298,17 @@ New_slur::get_encompass_info (Grob *me,
   if (!h)
     {
       ei.head_ = ei.stem_ = col->extent (common[Y_AXIS], Y_AXIS)[dir];
-      return ei;  
+      return ei;
     }
-  
+
   ei.head_ = h->extent (common[Y_AXIS], Y_AXIS)[dir];
-  
+
   if ((stem_dir == dir)
       && !stem->extent (stem, Y_AXIS).is_empty ())
     {
       ei.stem_ = stem->extent (common[Y_AXIS], Y_AXIS)[dir];
       if (Grob * b = Stem::get_beam (stem))
-       {
-         ei.stem_ += stem_dir * 0.5  *Beam::get_thickness (b);
-       }
-      
+       ei.stem_ += stem_dir * 0.5 * Beam::get_thickness (b);
       ei.x_  = stem->extent (common[X_AXIS], X_AXIS).center ();
     }
   else
@@ -324,15 +319,15 @@ New_slur::get_encompass_info (Grob *me,
 
 
 Direction
-New_slur::get_default_dir (Grob*me) 
+New_slur::get_default_dir (Grob*me)
 {
-  Link_array<Grob> encompasses =
-    Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
-  
+  Link_array<Grob> encompasses
+    = Pointer_group_interface__extract_grobs (me, (Grob*) 0, "note-columns");
+
   Direction d = DOWN;
-  for (int i=0; i < encompasses.size (); i ++) 
+  for (int i= 0; i < encompasses.size (); i ++)
     {
-      if (Note_column::dir (encompasses[i]) < 0) 
+      if (Note_column::dir (encompasses[i]) < 0)
        {
          d = UP;
          break;
@@ -351,11 +346,10 @@ New_slur::after_line_breaking (SCM smob)
       me->suicide ();
       return SCM_UNSPECIFIED;
     }
-  
+
   if (!get_grob_direction (me))
     set_grob_direction (me, get_default_dir (me));
 
-  
   set_end_points (me);
 
   return SCM_UNSPECIFIED;
@@ -369,7 +363,7 @@ New_slur::get_bezier (Grob *me, Drul_array<Offset> extremes,
   Array<Offset> encompasses;
   encompasses.push (extremes[LEFT]);
   encompasses.push (extremes[RIGHT]);
-  
+
   Slur_bezier_bow bb (encompasses,
                      get_grob_direction (me), h_inf, r_0);
 
@@ -387,7 +381,7 @@ New_slur::get_bound_info (Spanner* me,
 
   do {
     extremes[d].bound_ = me->get_bound (d);
-      
+
     if (Note_column::has_interface (extremes[d].bound_))
       {
        extremes[d].note_column_ = extremes[d].bound_;
@@ -412,15 +406,13 @@ New_slur::get_bound_info (Spanner* me,
 void
 New_slur::set_end_points (Grob *me)
 {
-  Link_array<Grob> columns =
-    Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
-
+  Link_array<Grob> columns
+    = Pointer_group_interface__extract_grobs (me, (Grob *)0, "note-columns");
   Slur_score_parameters params;
-  
   if (columns.is_empty ())
     {
       me->suicide ();
-      return ; 
+      return;
     }
 
   SCM eltlist = me->get_property ("note-columns");
@@ -428,17 +420,20 @@ New_slur::set_end_points (Grob *me)
                    common_refpoint_of_list (eltlist, me, Y_AXIS)};
 
 
-  Spannersp = dynamic_cast<Spanner*> (me);
-  common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
-  common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (LEFT), X_AXIS);
-
-
+  Spanner *sp = dynamic_cast<Spanner*> (me);
+  common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (RIGHT),
+                                                   X_AXIS);
+  common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (LEFT),
+                                                   X_AXIS);
   Drul_array<Bound_info> extremes = get_bound_info (sp, common);
-  Drul_array<Offset> base_attachment = get_base_attachments (sp, common, extremes);
-  Drul_array<Real> end_ys = get_y_attachment_range (sp, common, extremes, base_attachment);
-  Array<Slur_score> scores = enumerate_attachments (me, common,
-                                                   &params, extremes, base_attachment, end_ys);
-  
+  Drul_array<Offset> base_attachment
+    = get_base_attachments (sp, common, extremes);
+  Drul_array<Real> end_ys
+    = get_y_attachment_range (sp, common, extremes, base_attachment);
+  Array<Slur_score> scores = enumerate_attachments (me, common, &params,
+                                                   extremes, base_attachment,
+                                                   end_ys);
+
   generate_curves (me, common, extremes, base_attachment, &scores);
   score_edges (me, common, &params,extremes, base_attachment, &scores);
   score_slopes (me, common, &params,extremes, base_attachment, &scores);
@@ -446,6 +441,7 @@ New_slur::set_end_points (Grob *me)
   
   Real opt = 1e6;
   int opt_idx = 0;
+  // why backwards?
   for (int i = scores.size (); i--;)
     {
       if (scores[i].score_  < opt)
@@ -457,7 +453,8 @@ New_slur::set_end_points (Grob *me)
 
 #if DEBUG_SLUR_QUANTING
   SCM inspect_quants = me->get_property ("inspect-quants");
-  if (to_boolean (me->get_paper ()->lookup_variable (ly_symbol2scm ("debug-slur-quanting")))
+  if (to_boolean (me->get_paper ()
+                 ->lookup_variable (ly_symbol2scm ("debug-slur-quanting")))
       && ly_c_pair_p (inspect_quants))
     {
       Drul_array<Real> ins = ly_scm2interval (inspect_quants);
@@ -477,7 +474,6 @@ New_slur::set_end_points (Grob *me)
       if (mindist > 1e5)
        programming_error ("Could not find quant.");
     }
-  
   scores[opt_idx].score_card_ += to_string ("i%d", opt_idx);
 
   // debug quanting
@@ -485,8 +481,8 @@ New_slur::set_end_points (Grob *me)
                    scm_makfrom0str (scores[opt_idx].score_card_.to_str0 ()));
 #endif
   
-  Bezier b =
-    avoid_staff_line  (me,common, extremes, scores[opt_idx].curve_);
+  Bezier b
+    avoid_staff_line  (me,common, extremes, scores[opt_idx].curve_);
   
   SCM controls = SCM_EOL;
   for (int i = 4; i--;)
@@ -494,7 +490,7 @@ New_slur::set_end_points (Grob *me)
       Offset o = b.control_[i] -
        Offset (me->relative_coordinate (common[X_AXIS], X_AXIS),
                me->relative_coordinate (common[Y_AXIS], Y_AXIS));
-      
+
       controls = scm_cons (ly_offset2scm (o), controls);
     }
 
@@ -511,45 +507,41 @@ New_slur::get_y_attachment_range (Spanner*me,
   Drul_array<Real> end_ys;
   Direction dir = get_grob_direction (me);
   Direction d = LEFT;
-  do {
-    if (extremes[d].note_column_)
-      {
-       end_ys[d] =  dir * ((dir * (base_attachment[d][Y_AXIS] + 4.0 *dir))
-                           >? (dir * (dir + extremes[d].note_column_->extent(common[Y_AXIS],Y_AXIS)[dir]))
-                           >? (dir * base_attachment[-d][Y_AXIS])
-                           );
-      }
-    else
-      {
-       end_ys[d] = extremes[d].neighbor_y_ + 4.0 * dir ;
-      }
-  } while (flip (&d) != LEFT);
+  do
+    {
+      if (extremes[d].note_column_)
+       {
+         end_ys[d] = dir
+           * ((dir * (base_attachment[d][Y_AXIS] + 4.0 * dir))
+              >? (dir * (dir + extremes[d].note_column_->extent(common[Y_AXIS],
+                                                                Y_AXIS)[dir]))
+              >? (dir * base_attachment[-d][Y_AXIS]));
+       }
+      else
+      end_ys[d] = extremes[d].neighbor_y_ + 4.0 * dir;
+    }
+  while (flip (&d) != LEFT);
 
   return end_ys;
 }
 
 Drul_array<Offset>
-New_slur::get_base_attachments (Spanner*me,
-                               Grob **common,
-                               Drul_array<Bound_info> extremes)
+New_slur::get_base_attachments (Spanner *me,
+                               Grob **common, Drul_array<Bound_info> extremes)
 {
-  Link_array<Grob> columns =
-    Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
+  Link_array<Grob> columns
+    = Pointer_group_interface__extract_grobs (me, (Grob *)0, "note-columns");
   Drul_array<Offset> base_attachment;
-    
-
   Slur_score_parameters params;
-
   Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me);
-
   Direction dir = get_grob_direction (me);
-  Direction d = LEFT;  
+  Direction d = LEFT;
   do
     {
       Grob *stem = extremes[d].stem_;
       Grob *head = extremes[d].slur_head_;
-      
-      Real x,y;
+
+      Real x, y;
       if (!extremes[d].note_column_)
        {
          y = extremes[d].neighbor_y_;
@@ -565,29 +557,40 @@ New_slur::get_base_attachments (Spanner*me,
              && Stem::get_beaming (stem, -d)
              && columns.size () > 2
              )
+           y = extremes[d].stem_extent_[Y_AXIS][dir];
+         else if (head)
+           y = head->extent (common[Y_AXIS], Y_AXIS)[dir];
+         y += dir * 0.5 * staff_space;
+
+         if (stem)
            {
-             y = extremes[d].stem_extent_[Y_AXIS][dir];
-           }
-         else if (head) 
-           {
-             y = head->extent (common[Y_AXIS], Y_AXIS)[dir];
+             SCM scripts = stem->get_property ((dir == UP
+                                                ? "script-up"
+                                                : "script-down"));
+
+             /* FIXME: number of scripts, height, priority?
+                articulation scripts should be inside slur, other,
+                such as dynamics, pedals, fingering, should be
+                outside.  */
+             if (!SCM_NULLP (scripts))
+               y += dir * staff_space;
            }
-         y += dir * 0.5 * staff_space;
 
-         Real pos = 2.0 * (y - extremes[d].staff_->relative_coordinate (common[Y_AXIS], Y_AXIS))
-           / Staff_symbol::staff_space (extremes[d].staff_);
+         Real pos
+           = (y - extremes[d].staff_->relative_coordinate (common[Y_AXIS],
+                                                           Y_AXIS))
+           * 2.0 / Staff_symbol::staff_space (extremes[d].staff_);
 
-         /*
-           start off staffline.
-         */
+         /* start off staffline. */
          if (fabs (pos - round (pos)) < 0.2
              && Staff_symbol_referencer::on_staffline (head, (int) rint (pos))
-             && Staff_symbol_referencer::line_count (head) -1 >= rint (pos)
+             && Staff_symbol_referencer::line_count (head) - 1 >= rint (pos)
              )
-           y += 1.5 * staff_space * dir / 10 ; // TODO: calc from slur thick & line thick, parameter.
-      
+           // TODO: calc from slur thick & line thick, parameter.          
+           y += 1.5 * staff_space * dir / 10;
+
          Grob * fh = Note_column::first_head (extremes[d].note_column_);
-         x = fh->extent (common[X_AXIS],  X_AXIS).linear_combination (CENTER);
+         x = fh->extent (common[X_AXIS], X_AXIS).linear_combination (CENTER);
        }
       base_attachment[d] = Offset (x, y);
 
@@ -596,30 +599,24 @@ New_slur::get_base_attachments (Spanner*me,
   return base_attachment;
 }
 
-
 void
-New_slur::generate_curves (Grob * me,  Grob **common,
+New_slur::generate_curves (Grob *me,  Grob **common,
                           Drul_array<Bound_info> extremes,
-                          Drul_array<Offset> ,
+                          Drul_array<Offset>,
                           Array<Slur_score> *scores)
 {
-  Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me);
+  Real staff_space = Staff_symbol_referencer::staff_space ((Grob *) me);
   Real r_0 = robust_scm2double (me->get_property ("ratio"), 0.33);
   Real h_inf = staff_space * ly_scm2double (me->get_property ("height-limit"));
-  
   for (int i = 0; i < scores->size(); i++)
     {
-      Bezier bez= get_bezier (me, (*scores)[i].attachment_,
-                             r_0, h_inf);
-      
+      Bezier bez= get_bezier (me, (*scores)[i].attachment_, r_0, h_inf);
       (*scores)[i].curve_ = bez;
     }
 }
 
-
-
 Bezier
-New_slur::avoid_staff_line (Grob * me,  Grob **common,
+New_slur::avoid_staff_line (Grob *me, Grob **common,
                            Drul_array<Bound_info> extremes,
                            Bezier bez)
 {
@@ -628,10 +625,7 @@ New_slur::avoid_staff_line (Grob * me,  Grob **common,
   Real lt =  me->get_paper ()->get_dimension (ly_symbol2scm ("linethickness"));
   Real thick = robust_scm2double (me->get_property ("thickness"), 1.0) *  lt;
 
-
-  /*
-    TODO: handle case of broken slur.
-  */
+  /* TODO: handle case of broken slur.  */
   if (!ts.is_empty ()
       && (extremes[LEFT].staff_ == extremes[RIGHT].staff_)
       && extremes[LEFT].staff_ && extremes[RIGHT].staff_)
@@ -641,26 +635,28 @@ New_slur::avoid_staff_line (Grob * me,  Grob **common,
       Grob *staff = extremes[LEFT].staff_;
 
       Real staff_space = extremes[LEFT].staff_space_;
-      Real p = 2 * (y - staff->relative_coordinate (common[Y_AXIS], Y_AXIS)) / staff_space;
+      Real p = 2 * (y - staff->relative_coordinate (common[Y_AXIS], Y_AXIS))
+       / staff_space;
 
       Real distance = fabs (round (p) - p);    //  in halfspaces
       if (distance < 4 * thick
-         && (int) fabs (round (p)) <= 2* Staff_symbol_referencer::staff_radius (staff) + 0.1
+         && (int) fabs (round (p))
+         <= 2 * Staff_symbol_referencer::staff_radius (staff) + 0.1
          && (int (fabs (round (p))) % 2
              != Staff_symbol_referencer::line_count (staff) % 2))
        {
          // TODO: parameter
          Real newp = round (p) + get_grob_direction (me) * 5 * thick;
          Real dy = (newp - p) * staff_space / 2.0;
-         bez.translate (Offset (0,dy));
+         bez.translate (Offset (0, dy));
        }
     }
   return bez;
 }
 
 Array<Slur_score>
-New_slur::enumerate_attachments (Grob * me,  Grob **,
-                                Slur_score_parameters * score_param,
+New_slur::enumerate_attachments (Grob *me, Grob **,
+                                Slur_score_parameters *score_param,
                                 Drul_array<Bound_info> extremes,
                                 Drul_array<Offset> base_attachment,
                                 Drul_array<Real> end_ys)
@@ -669,23 +665,21 @@ New_slur::enumerate_attachments (Grob * me,  Grob **,
   Array<Slur_score> scores;
 
   Direction dir = get_grob_direction (me);
-  Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me);
-  
+  Real staff_space = Staff_symbol_referencer::staff_space ((Grob *)me);
+
   Drul_array<Offset> os;
   os[LEFT] = base_attachment[LEFT];
-  Real minimum_length = staff_space * robust_scm2double (me->get_property ("minimum-length"),
-                                                        2.0);
-  
+  Real minimum_length = staff_space
+    * robust_scm2double (me->get_property ("minimum-length"), 2.0);
+
   for (int i = 0; dir * os[LEFT][Y_AXIS] <= dir * end_ys[LEFT]; i++)
     {
       os[RIGHT] = base_attachment[RIGHT];
-      for (int j = 0; dir *os[RIGHT][Y_AXIS] <= dir * end_ys[RIGHT]; j++)
+      for (int j = 0; dir * os[RIGHT][Y_AXIS] <= dir * end_ys[RIGHT]; j++)
        {
          Slur_score s;
          Direction d = LEFT;
-         
          Drul_array<bool> attach_to_stem (false, false);
-         
          do {  
            os[d][X_AXIS] = base_attachment[d][X_AXIS];
            if (extremes[d].stem_
@@ -709,16 +703,18 @@ New_slur::enumerate_attachments (Grob * me,  Grob **,
          Offset dz;      
          dz = os[RIGHT] - os[LEFT];
          if (dz[X_AXIS] < minimum_length
-             || fabs (dz[Y_AXIS] / dz[X_AXIS])  > score_param->MAX_SLOPE
+             || fabs (dz[Y_AXIS] / dz[X_AXIS]) > score_param->MAX_SLOPE
              )
            {
-             do {
-               if (extremes[d].slur_head_)
-                 {
-                   os[d][X_AXIS] = extremes[d].slur_head_extent_.center ();
-                   attach_to_stem[d] = false;
-                 }
-             } while (flip (&d) != LEFT);
+             do
+               {
+                if (extremes[d].slur_head_)
+                  {
+                    os[d][X_AXIS] = extremes[d].slur_head_extent_.center ();
+                    attach_to_stem[d] = false;
+                  }
+             }
+             while (flip (&d) != LEFT);
            }
 
          dz = os[RIGHT] - os[LEFT];
@@ -739,38 +735,36 @@ New_slur::enumerate_attachments (Grob * me,  Grob **,
          
          s.attachment_ = os;
          scores.push (s);
-         
+
          os[RIGHT][Y_AXIS] += dir * staff_space / 2;
        }
 
-      os[LEFT][Y_AXIS] += dir * staff_space /;
+      os[LEFT][Y_AXIS] += dir * staff_space / 2;
     }
 
   return scores;
 }
 
-
 void
-New_slur::score_encompass (Grob * me,  Grob *common[],
-                          Slur_score_parameters * score_param,
-
+New_slur::score_encompass (Grob *me, Grob *common[],
+                          Slur_score_parameters *score_param,
                           Drul_array<Bound_info> ,
                           Drul_array<Offset> ,
                           Array<Slur_score> * scores)
 {
-  Link_array<Grob> encompasses =
-    Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
+  Link_array<Grob> encompasses
+    = Pointer_group_interface__extract_grobs (me, (Grob *)0, "note-columns");
   Direction dir = get_grob_direction (me);
+
   Array<Encompass_info> infos;
 
   for (int i = 0; i < encompasses.size(); i++)
     infos.push (get_encompass_info (me, encompasses[i], common));
 
-  for (int i =; i < scores->size (); i++)
+  for (int i = 0; i < scores->size (); i++)
     {
       Bezier const &bez (scores->elem (i).curve_);
-      Real demerit =0.;
+      Real demerit = 0.0;
       for (int j = 0; j < infos.size(); j++)
        {
          Real x = infos[j].x_;
@@ -782,23 +776,21 @@ New_slur::score_encompass (Grob * me,  Grob *common[],
          if (!(x < scores->elem (i).attachment_[RIGHT][X_AXIS]
                && x > scores->elem (i).attachment_[LEFT][X_AXIS]))
            continue;
-         
+       
          Real y = bez.get_other_coordinate (X_AXIS, x);
          if (!edge)
            {
              Real head_dy = (y - infos[j].head_);
              if (dir * head_dy < 0)
+               demerit += score_param->HEAD_ENCOMPASS_PENALTY;
+             else
                {
-                 demerit += score_param->HEAD_ENCOMPASS_PENALTY;
-               }
-             else 
-               {
-                 Real hd =  
-                   (head_dy) ? (1/fabs (head_dy)  - 1/score_param->FREE_HEAD_DISTANCE)
+                 Real hd = (head_dy)
+                   ? (1 / fabs (head_dy) - 1 / score_param->FREE_HEAD_DISTANCE)
                    : score_param->HEAD_ENCOMPASS_PENALTY;
-                 hd = (hd >? 0)<? score_param->HEAD_ENCOMPASS_PENALTY; 
+                 hd = (hd >? 0)<? score_param->HEAD_ENCOMPASS_PENALTY;
 
-                 demerit += hd;          
+                 demerit += hd;        
                }
            }     
 
@@ -821,33 +813,30 @@ New_slur::score_encompass (Grob * me,  Grob *common[],
 #if DEBUG_SLUR_QUANTING
       (*scores)[i].score_card_ += to_string ("C%.2f", demerit);
 #endif
-      
+
       (*scores)[i].score_ += demerit;
     }
 }
 
-
 void
-New_slur::score_edges (Grob * me,  Grob **,
+New_slur::score_edges (Grob *me, Grob **,
                       Slur_score_parameters * score_param,
                       Drul_array<Bound_info> extremes,
                       Drul_array<Offset> base_attach,
-                      Array<Slur_score> * scores)
+                      Array<Slur_score> *scores)
 {
   Direction dir = get_grob_direction (me);
-  for (int i =; i < scores->size (); i++)
+
+  for (int i = 0; i < scores->size (); i++)
     {
-  
+
       Direction d = LEFT;
       do {
        Real y = scores->elem (i).attachment_[d][Y_AXIS];
        Real dy = fabs (y - base_attach[d][Y_AXIS]);
        
        Real factor = score_param->EDGE_ATTRACTION_FACTOR;
-
        Real demerit = factor * dy;
        if (extremes[d].stem_
            && extremes[d].stem_dir_ == dir
            && !Stem::get_beaming (extremes[d].stem_, -d)
@@ -863,7 +852,7 @@ New_slur::score_edges (Grob * me,  Grob **,
 }
 
 void
-New_slur::score_slopes (Grob * me,  Grob *common[],
+New_slur::score_slopes (Grob *me, Grob *common[],
                        Slur_score_parameters*score_param,
                        Drul_array<Bound_info> extremes,
                        Drul_array<Offset> base_attach,
@@ -873,27 +862,32 @@ New_slur::score_slopes (Grob * me,  Grob *common[],
 
   Direction d = LEFT;
   do {
-
     if (extremes[d].slur_head_)
-      ys[d] = extremes[d].slur_head_ ->relative_coordinate (common[Y_AXIS], Y_AXIS);
+      ys[d] = extremes[d].slur_head_ ->relative_coordinate (common[Y_AXIS],
+                                                           Y_AXIS);
     else
       ys[d] = extremes[d].neighbor_y_;
   } while (flip (&d) != LEFT);
 
-  bool has_beams =
-    (extremes[LEFT].stem_ && Stem::get_beam (extremes[LEFT].stem_))
+  bool has_beams
+    (extremes[LEFT].stem_ && Stem::get_beam (extremes[LEFT].stem_))
     || (extremes[RIGHT].stem_ && Stem::get_beam (extremes[RIGHT].stem_));
 
   Real dy = ys[RIGHT] - ys[LEFT];
-  for (int i =; i < scores->size (); i++)
+  for (int i = 0; i < scores->size (); i++)
     {
       Offset slur_dz = (*scores)[i].attachment_[RIGHT]
-       -  (*scores)[i].attachment_[LEFT];
-
-      Real slur_dy = slur_dz[Y_AXIS]; 
-
-
+       - (*scores)[i].attachment_[LEFT];
+      Real slur_dy = slur_dz[Y_AXIS];
       Real demerit = 0.0;
+      if (!has_beams)
+       /* 0.2: account for staffline offset.  */
+       demerit += score_param->STEEPER_SLOPE_FACTOR
+         * (dir * (fabs (slur_dy) - fabs (dy + 0.2)) >? 0);
+
+      demerit += ((fabs (slur_dy/slur_dz[X_AXIS])
+                  - score_param->MAX_SLOPE) >? 0)
+       * score_param->MAX_SLOPE_FACTOR;
 
       if (!has_beams)
        /*
@@ -910,9 +904,10 @@ New_slur::score_slopes (Grob * me,  Grob *common[],
       if (sign (dy)
          && sign (slur_dy)
          && sign (slur_dy) != sign (dy))
-       demerit +=
-         has_beams ? score_param->SAME_SLOPE_PENALTY/10 : score_param->SAME_SLOPE_PENALTY;
-      
+       demerit += has_beams
+         ? score_param->SAME_SLOPE_PENALTY / 10
+         : score_param->SAME_SLOPE_PENALTY;
+
 #if DEBUG_SLUR_QUANTING
       (*scores)[i].score_card_ += to_string ("S%.2f",d);
 #endif
@@ -922,14 +917,13 @@ New_slur::score_slopes (Grob * me,  Grob *common[],
 
 
 Bezier
-New_slur::get_curve (Grob*me) 
+New_slur::get_curve (Grob*me)
 {
   Bezier b;
   int i = 0;
-  for (SCM s= me->get_property ("control-points"); s != SCM_EOL; s = ly_cdr (s))
-    {
-      b.control_[i++] = ly_scm2offset (ly_car (s));
-    }
+  for (SCM s = me->get_property ("control-points"); s != SCM_EOL;
+       s = ly_cdr (s))
+    b.control_[i++] = ly_scm2offset (ly_car (s));
 
   return b;
 }
@@ -940,12 +934,12 @@ SCM
 New_slur::height (SCM smob, SCM ax)
 {
   Axis a = (Axis)ly_scm2int (ax);
-  Grob * me = unsmob_grob (smob);
+  Grob *me = unsmob_grob (smob);
   assert (a == Y_AXIS);
 
   SCM mol = me->get_uncached_stencil ();
   Interval ext;
-  if (Stencil * m = unsmob_stencil (mol))
+  if (Stencil *m = unsmob_stencil (mol))
     ext = m->extent (a);
   return ly_interval2scm (ext);
 }
@@ -957,7 +951,7 @@ MAKE_SCHEME_CALLBACK (New_slur, print,1);
 SCM
 New_slur::print (SCM smob)
 {
-  Grob * me = unsmob_grob (smob);
+  Grob *me = unsmob_grob (smob);
   if (!scm_ilength (me->get_property ("note-columns")))
     {
       me->suicide ();
@@ -984,26 +978,25 @@ New_slur::print (SCM smob)
 
 #if DEBUG_SLUR_QUANTING
   SCM quant_score = me->get_property ("quant-score");
-  
-  if (to_boolean (me->get_paper ()->lookup_variable (ly_symbol2scm ("debug-slur-quanting"))) &&
-      ly_c_string_p (quant_score))
+
+  if (to_boolean (me->get_paper ()
+                 ->lookup_variable (ly_symbol2scm ("debug-slur-quanting")))
+      && ly_c_string_p (quant_score))
     {
       String str;
       SCM properties = Font_interface::text_font_alist_chain (me);
 
       Stencil tm = *unsmob_stencil (Text_item::interpret_markup
-                                   (me->get_paper ()->self_scm (), properties, quant_score));
+                                   (me->get_paper ()->self_scm (), properties,
+                                    quant_score));
       a.add_at_edge (Y_AXIS, get_grob_direction (me), tm, 1.0, 0);
     }
 #endif
-  
+
   return a.smobbed_copy ();
 }
 
 
-
-
-
 ADD_INTERFACE (New_slur, "new-slur-interface",
               "A slur",
               "control-points dashed details direction height-limit note-columns ratio slope-limit thickness");
index 4d5a1644bbfeec172fb633e24a533753010d87cc..9d75ba8ab2c3ce2b32f2a9f5d6b4fbe26bb165c6 100644 (file)
@@ -1,24 +1,25 @@
 /*
-  script-engraver.cc -- implement Script_engraver
+  script-engraver.cc -- engrave Scripts: Articulations.
+
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "script.hh"
-#include "side-position-interface.hh"
-#include "event.hh"
-#include "stem.hh"
-#include "rhythmic-head.hh"
+#include "context.hh"
 #include "engraver.hh"
+#include "event.hh"
 #include "note-column.hh"
-#include "context.hh"
-
+#include "rhythmic-head.hh"
+#include "script-interface.hh"
+#include "side-position-interface.hh"
+#include "stem.hh"
 #include "warn.hh"
 
 struct Script_tuple
 {
   Music *event_;
-  Grob * script_;
+  Grob *script_;
   SCM description_;
   Script_tuple ()
   {
@@ -31,94 +32,86 @@ struct Script_tuple
 class Script_engraver : public Engraver
 {
   Array<Script_tuple> scripts_;
-public:
-  TRANSLATOR_DECLARATIONS (Script_engraver);
+
 protected:
   virtual bool try_music (Music*);
   virtual void stop_translation_timestep ();
   virtual void process_music ();
   virtual void acknowledge_grob (Grob_info);
+
+public:
+  TRANSLATOR_DECLARATIONS (Script_engraver);
 };
 
+Script_engraver::Script_engraver ()
+{
+}
+
 bool
 Script_engraver::try_music (Music *r)
 {
   if (r->is_mus_type ("articulation-event"))
     {
-      /*
-       Discard double articulations.
-       This is necessary for part-combining.
-       */
-      for (int j = 0; j < scripts_.size (); j++)
-       if (ly_c_equal_p (scripts_[j]. event_->get_property ("articulation-type"),
-                       r->get_property ("articulation-type")
-                       ))
+      /* Discard double articulations for part-combining.  */
+      int script_count = scripts_.size ();
+      for (int i = 0; i < script_count; i++)
+       if (ly_c_equal_p (scripts_[i].event_
+                         ->get_property ("articulation-type"),
+                         r->get_property ("articulation-type")))
          return true;
-         
+
       Script_tuple t;
-      t.event_ =r;
+      t.event_ = r;
       scripts_.push (t);
-      
       return true;
     }
   return false;
 }
 
 void
-copy_property (Grob * g , SCM sym, SCM alist)
+copy_property (Grob *g, SCM sym, SCM alist)
 {
   if (g->internal_get_property (sym) == SCM_EOL)
     {
-      SCM entry = scm_assoc (sym,alist);
+      SCM entry = scm_assoc (sym, alist);
       if (ly_c_pair_p (entry))
-       {
-         g->internal_set_property (sym, ly_cdr (entry));
-       }
+       g->internal_set_property (sym, ly_cdr (entry));
     }
 }
 
-
-/*
-  We add the properties, one by one for each Script. We could save a
-  little space by tacking the props onto the Script grob (i.e. make
-  ScriptStaccato , ScriptMarcato, etc. )
- */
-void make_script_from_event (Grob *p,
-                            SCM * descr, Context *tg,
-                            SCM art_type, 
-                            int index)
+/* Add the properties, one by one for each Script.  A little space
+   (memory? --jcn) could be saved by tacking the props onto the Script
+   grob (i.e. make ScriptStaccato , ScriptMarcato, etc. ).  */
+void make_script_from_event (Grob *p, SCM *descr, Context *tg,
+                            SCM art_type, int index)
 {
   SCM alist = tg->get_property ("scriptDefinitions");
   SCM art = scm_assoc (art_type, alist);
 
   if (art == SCM_BOOL_F)
     {
-      warning (_("Don't know how to interpret articulation:"));
-      warning (_("Scheme encoding: "));
+      /* FIXME: */
+      warning (_ ("Do not know how to interpret articulation: "));
+      warning (_ ("Scheme encoding: "));
       scm_write (art_type, scm_current_error_port ());
-      return  ;
+      return;
     }
 
   art = ly_cdr (art);
-  
-  *descr = art;  
-
+  *descr = art;
 
   copy_property (p, ly_symbol2scm ("script-stencil"), art);
   copy_property (p, ly_symbol2scm ("direction"), art);
   copy_property (p, ly_symbol2scm ("side-relative-direction"), art);
 
-  int prio =0;
+  int prio = 0;
   SCM sprio = scm_assoc (ly_symbol2scm ("script-priority"), art);
   if (ly_c_pair_p (sprio))
     prio = ly_scm2int (ly_cdr (sprio));
 
-
-  /*
-    Make sure they're in order of user input by adding index i.
-    Don't use the direction in this priority. Smaller means closer
-    to the head.
-  */
+  /* Make sure they're in order of user input by adding index i.
+     Don't use the direction in this priority. Smaller means closer
+     to the head.  */
   prio += index;
 
   Side_position_interface::set_axis (p, Y_AXIS);
@@ -128,20 +121,20 @@ void make_script_from_event (Grob *p,
 void
 Script_engraver::process_music ()
 {
-  for (int i=0; i < scripts_.size (); i++)
+  int script_count = scripts_.size ();
+  for (int i = 0; i < script_count; i++)
     {
-      Music* l=scripts_[i].event_;
+      Music *m = scripts_[i].event_;
 
-      Grob * p = make_item ("Script", l->self_scm ());
+      Grob *p = make_item ("Script", m->self_scm ());
 
       make_script_from_event (p, &scripts_[i].description_, context (),
-                             l->get_property ("articulation-type"),
+                             m->get_property ("articulation-type"),
                              i);
 
       scripts_[i].script_ = p;
 
-      
-      SCM force_dir = l->get_property ("direction");
+      SCM force_dir = m->get_property ("direction");
       if (is_direction (force_dir) && to_dir (force_dir))
        p->set_property ("direction", force_dir);
     }
@@ -150,28 +143,27 @@ Script_engraver::process_music ()
 void
 Script_engraver::acknowledge_grob (Grob_info inf)
 {
+  int script_count = scripts_.size ();
   if (Stem::has_interface (inf.grob_))
     {
-      for (int i=0; i < scripts_.size (); i++)
+      for (int i = 0; i < script_count; i++)
        {
-         Grob*e = scripts_[i].script_;
+         Grob *e = scripts_[i].script_;
 
          if (to_dir (e->get_property ("side-relative-direction")))
            e->set_property ("direction-source", inf.grob_->self_scm ());
 
-         /*
-           add dep ? 
-          */
+         /* FIXME: add dependency */
          e->add_dependency (inf.grob_);
          Side_position_interface::add_support (e, inf.grob_);
        }
     }
   else if (Rhythmic_head::has_interface (inf.grob_))
     {
-      for (int i=0; i < scripts_.size (); i++)
+      for (int i = 0; i < script_count; i++)
        {
          Grob *e = scripts_[i].script_;
-         
+       
          if (Side_position_interface::get_axis (e) == X_AXIS
              && !e->get_parent (Y_AXIS))
            {
@@ -183,24 +175,19 @@ Script_engraver::acknowledge_grob (Grob_info inf)
     }
   else if (Note_column::has_interface (inf.grob_))
     {
-
-      /*
-       We make note column the parent of the script. That's not
+      /* Make note column the parent of the script.  That is not
        correct, but due to seconds in a chord, noteheads may be
-       swapped around horizontally. We don't know which note head to
-       put it on, so we postpone this decision to
-       Script_interface::before_line_breaking ().
-       */
-      for (int i=0; i < scripts_.size (); i++)
+       swapped around horizontally.
+
+       As the note head to put it on is not known now, postpone this
+       decision to Script_interface::before_line_breaking ().  */
+      for (int i = 0; i < script_count; i++)
        {
          Grob *e = scripts_[i].script_;
-         
-         if (!e->get_parent (X_AXIS) &&
-             Side_position_interface::get_axis (e) == Y_AXIS)
-           {
-             e->set_parent (inf.grob_, X_AXIS);
-           }
+
+         if (!e->get_parent (X_AXIS)
+             && Side_position_interface::get_axis (e) == Y_AXIS)
+           e->set_parent (inf.grob_, X_AXIS);
        }
     }
 }
@@ -208,27 +195,22 @@ Script_engraver::acknowledge_grob (Grob_info inf)
 void
 Script_engraver::stop_translation_timestep ()
 {
-  for (int i=0; i < scripts_.size (); i++) 
-    {
-      if (!scripts_[i].script_)
-       continue;
-      
-      Grob * sc = scripts_[i].script_;
-
-      SCM follow = scm_assoc (ly_symbol2scm ("follow-into-staff"), scripts_[i].description_);
-      if (ly_c_pair_p (follow) && to_boolean (ly_cdr (follow)))
-       {
-         sc->add_offset_callback (Side_position_interface::quantised_position_proc, Y_AXIS);
-         sc->set_property ("staff-padding", SCM_EOL);
-       }
-    }
+  int script_count = scripts_.size ();
+  for (int i = 0; i < script_count; i++)
+    if (Grob *sc = scripts_[i].script_)
+      {
+       SCM follow = scm_assoc (ly_symbol2scm ("follow-into-staff"),
+                               scripts_[i].description_);
+       if (ly_c_pair_p (follow) && to_boolean (ly_cdr (follow)))
+         {
+           sc->add_offset_callback (Side_position_interface
+                                    ::quantised_position_proc, Y_AXIS);
+           sc->set_property ("staff-padding", SCM_EOL);
+         }
+      }
   scripts_.clear ();
 }
 
-
-
-Script_engraver::Script_engraver (){}
-
 ENTER_DESCRIPTION (Script_engraver,
 /* descr */       "Handles note scripted articulations.",
 /* creats*/       "Script",
diff --git a/lily/script-interface.cc b/lily/script-interface.cc
new file mode 100644 (file)
index 0000000..9a3d254
--- /dev/null
@@ -0,0 +1,100 @@
+/*   
+  script-interface.cc --  implement Script_interface
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
+
+#include "directional-element-interface.hh"
+#include "warn.hh"
+#include "script-interface.hh"
+#include "font-interface.hh"
+#include "side-position-interface.hh"
+#include "output-def.hh"
+#include "item.hh"
+#include "stencil.hh"
+#include "lookup.hh"
+#include "stem.hh"
+#include "note-column.hh"
+
+Stencil
+Script_interface::get_stencil (Grob *me, Direction d)
+{
+  SCM s = me->get_property ("script-stencil");
+  assert (ly_c_pair_p (s));
+
+  SCM key = ly_car (s);
+  if (key == ly_symbol2scm ("feta"))
+    {
+      SCM name_entry = ly_cdr (s);
+      SCM str = ((ly_c_pair_p (name_entry)) ? index_get_cell (name_entry, d)
+                : name_entry);
+      return Font_interface::get_default_font (me)
+       ->find_by_name ("scripts-" + ly_scm2string (str));
+    }
+  else if (key == ly_symbol2scm ("accordion"))
+    return Lookup::accordion (ly_cdr (s), 1.0,
+                             Font_interface::get_default_font (me));
+  else
+    assert (false);
+
+  return Stencil ();
+}
+
+MAKE_SCHEME_CALLBACK (Script_interface, before_line_breaking, 1);
+SCM
+Script_interface::before_line_breaking (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+
+  Direction d = Side_position_interface::get_direction (me);
+
+  if (!d)
+    {
+      /* FIXME: This should never happen: `arbitrary' directions.  */
+      programming_error ("Script direction not yet known!");
+      d = DOWN;
+    }
+
+  set_grob_direction (me, d);
+
+  if (Grob *par = me->get_parent (X_AXIS))
+    {
+      Grob *stem = Note_column::get_stem (par);
+      if (stem && Stem::first_head (stem))
+       me->set_parent (Stem::first_head (stem), X_AXIS);
+    }
+  return SCM_UNSPECIFIED;
+}
+
+MAKE_SCHEME_CALLBACK (Script_interface, print, 1);
+
+SCM
+Script_interface::print (SCM smob)
+{
+  Grob *me= unsmob_grob (smob);
+
+  Direction dir = Side_position_interface::get_direction (me);
+  if (!dir)
+    {
+      programming_error ("Script direction not known, but stencil wanted.");
+      dir = DOWN;
+    }
+  return get_stencil (me, dir).smobbed_copy ();
+}
+
+struct Text_script
+{
+  static bool has_interface (Grob*);
+};
+
+ADD_INTERFACE (Text_script,"text-script-interface",
+  "An object that is put above or below a note",
+  "script-priority");
+
+ADD_INTERFACE (Script_interface, "script-interface",
+  "An object that is put above or below a note",
+  "script-priority script-stencil");
+
diff --git a/lily/script.cc b/lily/script.cc
deleted file mode 100644 (file)
index 910c240..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*   
-  script.cc --  implement Script_interface
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
- */
-
-#include "directional-element-interface.hh"
-#include "warn.hh"
-#include "script.hh"
-#include "font-interface.hh"
-#include "side-position-interface.hh"
-#include "output-def.hh"
-#include "item.hh"
-#include "stencil.hh"
-#include "lookup.hh"
-#include "stem.hh"
-#include "note-column.hh"
-
-Stencil
-Script_interface::get_stencil (Grob * me, Direction d)
-{
-  SCM s = me->get_property ("script-stencil");
-  assert (ly_c_pair_p (s));
-
-  SCM key = ly_car (s);
-  if (key == ly_symbol2scm ("feta"))
-    {
-      SCM name_entry = ly_cdr (s);
-
-      SCM str = (ly_c_pair_p (name_entry)) ? index_get_cell (name_entry, d) :  name_entry;
-      return Font_interface::get_default_font (me)->find_by_name ("scripts-" +
-                                                                 ly_scm2string (str));
-    }
- else if (key == ly_symbol2scm ("accordion"))
-    {
-      return Lookup::accordion (ly_cdr (s), 1.0, Font_interface::get_default_font (me));
-    }
-  else
-    assert (false);
-
-  return Stencil ();
-}
-
-MAKE_SCHEME_CALLBACK (Script_interface,before_line_breaking,1);
-SCM
-Script_interface::before_line_breaking (SCM smob)
-{
-  Grob * me = unsmob_grob (smob);
-
-  Direction d = Side_position_interface::get_direction (me);
-
-  if (!d)
-    {
-      /*
-       we should not have `arbitrary' directions. 
-      */
-      programming_error ("Script direction not yet known!");
-      d = DOWN;
-    }
-  
-  set_grob_direction (me, d);
-
-  if (Grob * par = me->get_parent (X_AXIS))
-    {
-      Grob * stem = Note_column::get_stem (par);
-      if (stem && Stem::first_head (stem))
-       {
-         me->set_parent (Stem::first_head (stem), X_AXIS);
-       }
-    }
-  
-  return SCM_UNSPECIFIED;
-}
-
-
-MAKE_SCHEME_CALLBACK (Script_interface,print,1);
-
-SCM
-Script_interface::print (SCM smob)
-{
-  Grob *me= unsmob_grob (smob);
-
-  Direction dir = Side_position_interface::get_direction (me);
-  if (!dir)
-    {
-      programming_error ("Script direction not known, but stencil wanted.");
-      dir= DOWN;
-    }
-  
-  return get_stencil (me, dir).smobbed_copy ();
-}
-
-
-
-struct Text_script
-{
-    static bool has_interface (Grob*);
-};
-
-struct Skript
-{
-    static bool has_interface (Grob*);
-};
-
-ADD_INTERFACE (Text_script,"text-script-interface",
-  "An object that is put above or below a note",
-  "script-priority");
-
-ADD_INTERFACE (Script_interface, "script-interface",
-  "An object that is put above or below a note",
-  "script-priority script-stencil");
-
index 15bba47969191e7de7e48afdfad4c0d2a22295c9..386447ab03ad65401ea281d325ce3f90d710180c 100644 (file)
@@ -6,17 +6,17 @@
   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "staff-symbol-referencer.hh"
-#include "rhythmic-head.hh"
-#include "stem.hh"
+#include "context.hh"
+#include "directional-element-interface.hh"
+#include "engraver.hh"
 #include "event.hh"
+#include "item.hh"
 #include "misc.hh"
+#include "rhythmic-head.hh"
+#include "script-interface.hh"
+#include "staff-symbol-referencer.hh"
 #include "stem-tremolo.hh"
-#include "item.hh"
-#include "context.hh"
-
-#include "engraver.hh"
-
+#include "stem.hh"
 
 
 /**
  */
 class Stem_engraver : public Engraver
 {
-  TRANSLATOR_DECLARATIONS (Stem_engraver);
-protected:
-  virtual void acknowledge_grob (Grob_info);
-  virtual void stop_translation_timestep ();
-  virtual bool try_music (Music*);
-  
-private:
   Grob  *stem_;
   Grob *tremolo_;
   Music *rhythmic_ev_;
   Music* tremolo_ev_;
+  TRANSLATOR_DECLARATIONS (Stem_engraver);
+
+protected:
+  void add_script (Grob *);
+  void make_stem (Grob_info);
+  virtual void acknowledge_grob (Grob_info);
+  virtual void stop_translation_timestep ();
+  virtual bool try_music (Music *);
 };
 
 Stem_engraver::Stem_engraver ()
@@ -45,103 +46,106 @@ Stem_engraver::Stem_engraver ()
   rhythmic_ev_ =0;
 }
 
-
 void
-Stem_engraver::acknowledge_grob (Grob_info i)
+Stem_engraver::make_stem (Grob_info gi)
 {
-  Grob* h = i.grob_;
-  if (Rhythmic_head::has_interface (h))
+  /* Announce the cause of the head as cause of the stem.  The
+     stem needs a rhythmic structure to fit it into a beam.  */
+  stem_ = make_item ("Stem", gi.music_cause ()->self_scm ());
+
+  int duration_log = gi.music_cause ()->duration_log ();
+  stem_->set_property ("duration-log", scm_int2num (duration_log));
+
+  if (tremolo_ev_)
     {
-      if (Rhythmic_head::get_stem (h))
-       return;
+      /* Stem tremolo is never applied to a note by default,
+        is must me requested.  But there is a default for the
+        tremolo value:
 
-      /* Reverted to the old method so chord tremolos work again. /MB 
-      */
-      int duration_log = 0;
+        c4:8 c c:
 
-      Music * m = i.music_cause ();
-      if (m->is_mus_type ("rhythmic-event"))
-       duration_log = unsmob_duration (m->get_property ("duration"))-> duration_log (); 
-      
-      if (!stem_) 
+        the first and last (quarter) note bothe get one tremolo flag.  */
+      int requested_type
+       = ly_scm2int (tremolo_ev_->get_property ("tremolo-type"));
+      SCM f = get_property ("tremoloFlags");
+      if (!requested_type)
        {
-         /*
-           We announce the cause of the head as cause of the stem.
-           The stem needs a rhythmic structure to fit it into a beam.  */
-         stem_ = make_item ("Stem",i.music_cause ()->self_scm ());
-
-         stem_->set_property ("duration-log", scm_int2num (duration_log));
-
-         if (tremolo_ev_)
-           {
-             /*
-               Stem tremolo is never applied to a note by default,
-               is must me evuested.  But there is a default for the
-               tremolo value:
-
-                  c4:8 c c:
-
-               the first and last (quarter) note bothe get one tremolo flag.
-              */
-             int requested_type = ly_scm2int (tremolo_ev_->get_property ("tremolo-type"));
-             SCM f = get_property ("tremoloFlags");
-             if (!requested_type)
-               if (ly_c_number_p (f))
-                 requested_type = ly_scm2int (f);
-               else
-                 requested_type = 8; 
-             else
-               context ()->set_property ("tremoloFlags", scm_int2num (requested_type));
-
-             int tremolo_flags = intlog2 (requested_type) - 2
-               - (duration_log > 2 ? duration_log - 2 : 0);
-             if (tremolo_flags <= 0)
-               {
-                 tremolo_ev_->origin ()->warning (_("tremolo duration is too long"));
-                 tremolo_flags = 0;
-               }
-
-             if (tremolo_flags)
-               {
-                 tremolo_ = make_item ("StemTremolo", tremolo_ev_->self_scm ());
-
-                 /*
-                   The number of tremolo flags is the number of flags of
-                   the tremolo-type minus the number of flags of the note
-                   itself.
-                  */
-                 tremolo_->set_property ("flag-count",
-                                              scm_int2num (tremolo_flags));
-                 tremolo_->set_parent (stem_, X_AXIS);
-                 stem_->set_property ("tremolo-flag", tremolo_->self_scm ());
-                 tremolo_->set_property ("stem",
-                                         stem_->self_scm ());
-               }
-           }
+         if (ly_c_number_p (f))
+           requested_type = ly_scm2int (f);
+         else
+           requested_type = 8;
+       }
+      else
+       context ()->set_property ("tremoloFlags", scm_int2num (requested_type));
 
+      int tremolo_flags = intlog2 (requested_type) - 2
+       - (duration_log > 2 ? duration_log - 2 : 0);
+      if (tremolo_flags <= 0)
+       {
+         tremolo_ev_->origin ()->warning (_("tremolo duration is too long"));
+         tremolo_flags = 0;
+       }
+
+      if (tremolo_flags)
+       {
+         tremolo_ = make_item ("StemTremolo", tremolo_ev_->self_scm ());
+
+         /* The number of tremolo flags is the number of flags of the
+           tremolo-type minus the number of flags of the note itself.  */
+         tremolo_->set_property ("flag-count", scm_int2num (tremolo_flags));
+         tremolo_->set_parent (stem_, X_AXIS);
+         stem_->set_property ("tremolo-flag", tremolo_->self_scm ());
+         tremolo_->set_property ("stem", stem_->self_scm ());
        }
+    }
+}
+
+void
+Stem_engraver::add_script (Grob *script)
+{
+  Direction d = get_grob_direction (script);
+  if (d == UP || d == DOWN)
+    {
+      char const *property = d == UP ? "script-up" : "script-down";
+      stem_->set_property (property,
+                          scm_cons (script->self_scm (),
+                                    stem_->get_property (property)));
+    }
+}
 
+void
+Stem_engraver::acknowledge_grob (Grob_info gi)
+{
+  if (Rhythmic_head::has_interface (gi.grob_))
+    {
+      if (Rhythmic_head::get_stem (gi.grob_))
+       return;
+      
+      if (!stem_)
+       make_stem (gi);
+      
+      int duration_log = gi.music_cause ()->duration_log ();
       if (Stem::duration_log (stem_) != duration_log)
        {
-         i.music_cause ()->origin ()->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 <<  Stem::duration_log (stem_))
-                                               + _f ("Don't you want polyphonic voices instead?")
-                                               );
+         // FIXME: 
+         gi.music_cause ()->origin ()->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 << Stem::duration_log (stem_)));
+         
+         gi.music_cause ()->origin ()->warning (_f ("Don't you want polyphonic voices instead?"));
        }
 
-      Stem::add_head (stem_,h);
+      Stem::add_head (stem_, gi.grob_);
     }
+  else if (Script_interface::has_interface (gi.grob_))
+    add_script (gi.grob_);
 }
 
 void
 Stem_engraver::stop_translation_timestep ()
 {
   tremolo_ = 0;
-
   if (stem_)
     {
-      /*
-       toDO: junk these properties.
-       */
+      /* FIXME: junk these properties.  */
       SCM prop = get_property ("stemLeftBeamCount");
       if (ly_c_number_p (prop))
        {
@@ -154,21 +158,17 @@ Stem_engraver::stop_translation_timestep ()
          Stem::set_beaming (stem_,ly_scm2int (prop), RIGHT);
          context ()->unset_property (ly_symbol2scm ("stemRightBeamCount"));
        }
-
-      
       stem_ = 0;
     }
-
-
   tremolo_ev_ = 0;
 }
 
 bool
-Stem_engraver::try_music (Music* r)
+Stem_engraver::try_music (Music *m)
 {
-  if (r->is_mus_type ("tremolo-event"))
+  if (m->is_mus_type ("tremolo-event"))
     {
-      tremolo_ev_ = r;
+      tremolo_ev_ = m;
       return true;
     }
   return false;
index 64f8981b230e21fcf438f5713082c5f1e6840031..f964895964e3e5a8e2fa59c3b6fd253d224ca419 100644 (file)
@@ -393,7 +393,7 @@ Stem::position_noteheads (Grob *me)
     Pointer_group_interface__extract_grobs (me, (Grob*) 0, "note-heads");
 
   heads.sort (compare_position);
-  Direction dir =get_direction (me);
+  Direction dir = get_direction (me);
 
   if (dir < 0)
     heads.reverse ();