]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/slur.cc (get_boundary_notecolumn_y): change name from
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 19 Jun 2003 23:09:43 +0000 (23:09 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 19 Jun 2003 23:09:43 +0000 (23:09 +0000)
get_first_notecolumn_y

* lily/spanner.cc (broken_spanner_index): new function.

ChangeLog
lily/include/slur.hh
lily/include/spanner.hh
lily/line-spanner.cc
lily/slur.cc
lily/spanner.cc

index fb663df35d422f96404ffe14d5430917d636f416..f1be3b321813c6dada2cd586450fa185ac2b3324 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-06-20  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * lily/slur.cc (get_boundary_notecolumn_y): change name from
+       get_first_notecolumn_y
+
+       * lily/spanner.cc (broken_spanner_index): new function.
+
 2003-06-19  Graham Percival  <gperlist@shaw.ca>
 
        * input/test/ beam-damp.ly grace-end.ly lyric-extender.ly
index 67d1334f74b5b8462c0e8f707d0f60ca7464f57f..4c3eb95354680614cc6083094842849998647252 100644 (file)
@@ -25,7 +25,7 @@ public:
 
   DECLARE_SCHEME_CALLBACK (height, (SCM,SCM));
 private:  
-  static Real get_first_notecolumn_y (Grob *me, Direction dir);
+  static Real get_boundary_notecolumn_y (Grob *me, Direction dir);
   static Offset broken_trend_offset (Grob *me, Direction dir);
   static Offset get_attachment (Grob *me,Direction dir, Grob **common);
   static void de_uglyfy (Grob *me,Slur_bezier_bow* bb, Real default_height);
index b4aa9f99984e3e9986ffcc45c495aa2a6ebb0ad2..4afd77cfadea6773d7cd7a12ae8a760edc9b7de4 100644 (file)
@@ -68,4 +68,5 @@ protected:
 void add_bound_item (Spanner*, Grob*);
 ///DECLARE_UNSMOB (Spanner, spanner);
 
+int broken_spanner_index (Spanner * sp);
 #endif
index fabfbf1a76e6bd28a24900935396999b5d3bcd4b..7ed5314f288357c2e65ce13e966fa789f3c40dbb 100644 (file)
@@ -160,32 +160,26 @@ Line_spanner::get_broken_offset (Grob *me, Direction dir)
   return Offset ();
 }
 
+/* A broken line-spaner should maintain the same vertical trend
+   the unbroken line-spanner would have had.
+   From slur */
 Offset
 Line_spanner::broken_trend_offset (Grob *me, Direction dir)
 {
-  /* A broken line-spaner should maintain the same vertical trend
-     the unbroken line-spanner would have had.
-     From slur */
   Offset o;
+  
   if (Spanner *mother =  dynamic_cast<Spanner*> (me->original_))
     {
-      for (int i = dir == LEFT ? 0 : mother->broken_intos_.size () - 1;
-          dir == LEFT ? i < mother->broken_intos_.size () : i > 0;
-          dir == LEFT ? i++ : i--)
-       {
-         if (mother->broken_intos_[i - dir] == me)
-           {
-             Grob *neighbour = mother->broken_intos_[i];
-             Offset neighbour_o = get_broken_offset (neighbour, dir);
-             Offset me_o = get_broken_offset (me, -dir);
-             // Hmm, why not return me_o[X], but recalc in brew_mol?
-             o = Offset (0,
- (neighbour_o[Y_AXIS]*me_o[X_AXIS]
-                          - me_o[Y_AXIS]*neighbour_o[X_AXIS]) * dir /
- (me_o[X_AXIS] + neighbour_o[X_AXIS]));
-             break;
-           }
-       }
+      int k = broken_spanner_index (dynamic_cast<Spanner*> (me));
+      Grob *neighbour = mother->broken_intos_[k + dir];      
+      Offset neighbour_o = get_broken_offset (neighbour, dir);
+      Offset me_o = get_broken_offset (me, -dir);
+
+      // Hmm, why not return me_o[X], but recalc in brew_mol?
+      o = Offset (0,
+                 (neighbour_o[Y_AXIS]*me_o[X_AXIS]
+                  - me_o[Y_AXIS]*neighbour_o[X_AXIS]) * dir /
+                 (me_o[X_AXIS] + neighbour_o[X_AXIS]));
     }
   return o;
 }
@@ -207,14 +201,9 @@ Line_spanner::brew_molecule (SCM smob)
   Grob *me= unsmob_grob (smob);
 
   Spanner *spanner = dynamic_cast<Spanner*> (me);
-  Item* bound_drul[] = {
-    spanner->get_bound (LEFT),
-    0,
-    spanner->get_bound (RIGHT)
-  };
+  Drul_array<Item*>  bound (spanner->get_bound (LEFT),
+                           spanner->get_bound (RIGHT));
   
-  Item** bound = bound_drul + 1;
-
   Grob *common[] = { me, me };
   for (int a = X_AXIS;  a < NO_AXES; a++)
     {
@@ -229,13 +218,13 @@ Line_spanner::brew_molecule (SCM smob)
     }
   
   Real gap = gh_scm2double (me->get_grob_property ("gap"));
-  Real dist; /*distance between points */
 
   Offset ofxy (gap, 0); /*offset from start point to start of line*/
   Offset dxy ;
   Offset my_off;
   Offset his_off;
 
+
   
   if (bound[LEFT]->break_status_dir () || bound[RIGHT]->break_status_dir ())
     /* across line break */
index eba766cc31666bb142456bc9709657186979c22a..7473197e22e5dabfe3d0843270211a9d346f3c3e 100644 (file)
@@ -218,7 +218,7 @@ Slur::set_extremities (Grob *me)
 
 
 Real
-Slur::get_first_notecolumn_y (Grob *me, Direction dir)
+Slur::get_boundary_notecolumn_y (Grob *me, Direction dir)
 {
   SCM cols = me->get_grob_property ("note-columns");
 
@@ -261,25 +261,17 @@ Slur::broken_trend_offset (Grob *me, Direction dir)
   Offset o;
   if (Spanner *mother =  dynamic_cast<Spanner*> (me->original_))
     {
-      for (int i = dir == LEFT ? 0 : mother->broken_intos_.size () - 1;
-          dir == LEFT ? i < mother->broken_intos_.size () : i > 0;
-          dir == LEFT ? i++ : i--)
-       {
-         if (mother->broken_intos_[i - dir] == me)
-           {
-             Grob *neighbour = mother->broken_intos_[i];
-             if (dir == RIGHT)
-               neighbour->set_grob_property ("direction",
-                                            me->get_grob_property ("direction"));
-             Real neighbour_y = get_first_notecolumn_y (neighbour, dir);
-             Real y = get_first_notecolumn_y (me, -dir);
-             int neighbour_cols = scm_ilength (neighbour->get_grob_property ("note-columns"));
-             int cols = scm_ilength (me->get_grob_property ("note-columns"));
-             o = Offset (0, (y*neighbour_cols + neighbour_y*cols) /
- (cols + neighbour_cols));
-             break;
-           }
-       }
+      int k = broken_spanner_index (dynamic_cast<Spanner*> (me));
+      Grob *neighbour = mother->broken_intos_[k + dir];      
+      if (dir == RIGHT)
+       neighbour->set_grob_property ("direction",
+                                     me->get_grob_property ("direction"));
+      Real neighbour_y = get_boundary_notecolumn_y (neighbour, dir);
+      Real y = get_boundary_notecolumn_y (me, -dir);
+      int neighbour_cols = scm_ilength (neighbour->get_grob_property ("note-columns"));
+      int cols = scm_ilength (me->get_grob_property ("note-columns"));
+      o = Offset (0, (y*neighbour_cols + neighbour_y*cols) /
+                 (cols + neighbour_cols));
     }
   return o;
 }
@@ -288,6 +280,8 @@ Slur::broken_trend_offset (Grob *me, Direction dir)
   COMMON is size-2 array with common refpoints.
 
 UGH: this routine delivers offsets which are *not* relative to COMMON.
+
+UGH,  we should take COMMON-Y as argument.
 */ 
 Offset
 Slur::get_attachment (Grob *me, Direction dir,
index 5882795d0a25e29b51efc9545c04975aed34ee56..0b444d45fecdda45bb34a2c021d95d29a414910a 100644 (file)
@@ -343,6 +343,17 @@ Spanner::set_spacing_rods (SCM smob)
 }
 
 
+/*
+  Return I such that SP == SP->ORIGINAL_->BROKEN_INTOS_[I]. 
+ */
+int
+broken_spanner_index (Spanner * sp)
+{
+  Spanner * parent = dynamic_cast<Spanner*> (sp->original_);
+  return parent->broken_intos_.find_index (sp);
+}
+                     
+
 Spanner*
 unsmob_spanner (SCM s )
 {