]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam.cc
Update texinfo.tex from Texinfo CVS
[lilypond.git] / lily / beam.cc
index ecc9d0b5a6ea979dcec6546bb7078fe44cf8ebac..183a936440ff12fe7038025671431264a7ae7ae3 100644 (file)
@@ -233,7 +233,7 @@ position_with_maximal_common_beams (SCM left_beaming, SCM right_beaming,
   return best_start;
 }
 
-MAKE_SCHEME_CALLBACK(Beam, calc_beaming, 1)
+MAKE_SCHEME_CALLBACK (Beam, calc_beaming, 1)
 SCM
 Beam::calc_beaming (SCM smob)
 {
@@ -405,7 +405,7 @@ Beam::get_beam_segments (Grob *me_grob, Grob **common)
          do
            {
              bool on_bound = (event_dir == LEFT) ? j == 0 :
-               j == segs.size() - 1;
+               j == segs.size () - 1;
 
              bool inside_stem = (event_dir == LEFT)
                        ? segs[j].stem_index_ > 0
@@ -427,7 +427,8 @@ Beam::get_beam_segments (Grob *me_grob, Grob **common)
                      && me->get_bound (event_dir)->break_status_dir ())
                    {
                      current.horizontal_[event_dir]
-                       = (me->get_bound (event_dir)->extent (commonx, X_AXIS)[RIGHT]
+                       = (robust_relative_extent (me->get_bound (event_dir),
+                                                  commonx, X_AXIS)[RIGHT]
                           + event_dir * break_overshoot[event_dir]);
                    }
                  else
@@ -441,7 +442,8 @@ Beam::get_beam_segments (Grob *me_grob, Grob **common)
                      if (inside_stem)
                        {
                          Grob *neighbor_stem = stems[segs[j].stem_index_ + event_dir];
-                         Real neighbor_stem_x = neighbor_stem->relative_coordinate (commonx, X_AXIS);
+                         Real neighbor_stem_x
+                           = neighbor_stem->relative_coordinate (commonx, X_AXIS);
 
                          notehead_width = min (notehead_width,
                                                fabs (neighbor_stem_x - segs[j].stem_x_)/2);
@@ -453,13 +455,32 @@ Beam::get_beam_segments (Grob *me_grob, Grob **common)
                {
                  current.horizontal_[event_dir] += event_dir * segs[j].width_/2;
                  if (segs[j].gapped_)
-                   current.horizontal_[event_dir] -= event_dir * gap_length;  
+                   {
+                     current.horizontal_[event_dir] -= event_dir * gap_length;
+
+                     if (Stem::is_invisible (segs[j].stem_))
+                       {
+                         /*
+                           Need to do this in case of whole notes. We don't want the
+                           heads to collide with the beams.
+                          */
+                         extract_grob_set (segs[j].stem_, "note-heads", heads);
+
+                         for (vsize k = 0; k < heads.size (); k ++)
+                           current.horizontal_[event_dir]
+                             = event_dir * min  (event_dir * current.horizontal_[event_dir],
+                                                 - gap_length/2
+                                                 + event_dir
+                                                   * heads[k]->extent (commonx,
+                                                                       X_AXIS)[-event_dir]);
+                       }
+                   }
                }
 
              if (event_dir == RIGHT)
                {
                  segments.push_back (current);
-                 current = Beam_segment();
+                 current = Beam_segment ();
                }
            }
          while (flip (&event_dir) != LEFT);
@@ -470,7 +491,7 @@ Beam::get_beam_segments (Grob *me_grob, Grob **common)
   return segments;
 }
 
-MAKE_SCHEME_CALLBACK(Beam, print, 1);
+MAKE_SCHEME_CALLBACK (Beam, print, 1);
 SCM
 Beam::print (SCM grob)
 {
@@ -695,7 +716,7 @@ Beam::consider_auto_knees (Grob *me)
            sets stem directions, a constant shift does not have an
            influence.
          */
-         head_extents += stem->relative_coordinate (common, Y_AXIS);
+         head_extents += stem->pure_relative_y_coordinate (common, 0, INT_MAX);
 
          if (to_dir (stem->get_property_data ("direction")))
            {
@@ -790,7 +811,7 @@ set_minimum_dy (Grob *me, Real *dy)
 
   
 
-MAKE_SCHEME_CALLBACK(Beam, calc_stem_shorten, 1)
+MAKE_SCHEME_CALLBACK (Beam, calc_stem_shorten, 1)
 SCM
 Beam::calc_stem_shorten (SCM smob)
 {
@@ -974,7 +995,6 @@ Beam::shift_region_to_valid (SCM grob, SCM posns)
   Real dx = lvs->relative_coordinate (commonx, X_AXIS) - x0;
 
   Drul_array<Real> pos = ly_scm2interval (posns);
-  
 
   scale_drul (&pos, Staff_symbol_referencer::staff_space (me));
 
@@ -1152,7 +1172,7 @@ Beam::calc_stem_y (Grob *me, Grob *stem, Grob **common,
   Hmm.  At this time, beam position and slope are determined.  Maybe,
   stem directions and length should set to relative to the chord's
   position of the beam.  */
-MAKE_SCHEME_CALLBACK(Beam, set_stem_lengths, 1); 
+MAKE_SCHEME_CALLBACK (Beam, set_stem_lengths, 1); 
 SCM
 Beam::set_stem_lengths (SCM smob)
 {
@@ -1307,7 +1327,7 @@ Beam::last_normal_stem (Grob *me)
 
   rest -> stem -> beam -> interpolate_y_position ()
 */
-MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Beam, rest_collision_callback, 2, 1);
+MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Beam, rest_collision_callback, 2, 1, "");
 SCM
 Beam::rest_collision_callback (SCM smob, SCM prev_offset)
 {
@@ -1421,6 +1441,24 @@ Beam::is_knee (Grob *me)
   return knee;
 }
 
+bool
+Beam::is_cross_staff (Grob *me)
+{
+  extract_grob_set (me, "stems", stems);
+  Grob *staff_symbol = Staff_symbol_referencer::get_staff_symbol (me);
+  for (vsize i = 0; i < stems.size (); i++)
+    if (Staff_symbol_referencer::get_staff_symbol (stems[i]) != staff_symbol)
+      return true;
+  return false;
+}
+
+MAKE_SCHEME_CALLBACK (Beam, calc_cross_staff, 1)
+SCM
+Beam::calc_cross_staff (SCM smob)
+{
+  return scm_from_bool (is_cross_staff (unsmob_grob (smob)));
+}
+
 int
 Beam::get_direction_beam_count (Grob *me, Direction d)
 {