]> git.donarmstrong.com Git - lilypond.git/commitdiff
move extremal_break_aligned_grob to Spacing_interface
authorJoe Neeman <joeneeman@gmail.com>
Thu, 5 Jul 2007 03:24:39 +0000 (13:24 +1000)
committerJoe Neeman <joeneeman@gmail.com>
Thu, 5 Jul 2007 03:24:39 +0000 (13:24 +1000)
lily/include/spacing-interface.hh
lily/note-spacing.cc
lily/separating-line-group-engraver.cc
lily/separation-item.cc
lily/spacing-interface.cc
lily/staff-spacing.cc

index 14b8c2bf03c468fa9bdab9365a33d371b683e080..135b31ae6e8f35219eb2ff1f15283e0732f433ee 100644 (file)
@@ -19,6 +19,7 @@ struct Spacing_interface
   static Item* right_column (Grob *me);
   static Item* left_column (Grob *me);
   static Drul_array<Skyline> skylines (Grob *me, Grob *right_col);
+  static Grob* extremal_break_aligned_grob (Grob *me, Direction, Direction, Interval*);
 
   DECLARE_GROB_INTERFACE();
 };
index 61af354f4cb1ebc161c289437a86e0333156db2a..c434e633c3a0fb56e722cb32e6bcbb88d1b64315 100644 (file)
@@ -116,6 +116,12 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
   Direction d = LEFT;
   bool acc_right = false;
 
+  Grob *bar = Spacing_interface::extremal_break_aligned_grob (me, RIGHT,
+                                                             rcolumn->break_status_dir (),
+                                                             &bar_xextent);
+  if (bar)
+    bar_yextent = Staff_spacing::bar_y_positions (bar);
+
   do
     {
       vector<Grob*> const &items (ly_scm2link_array (props [d]));
@@ -129,22 +135,7 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
          Grob *stem = Note_column::get_stem (it);
 
          if (!stem || !stem->is_live ())
-           {
-             if (d == RIGHT && Separation_item::has_interface (it))
-               {
-                 if (it->get_column () != rcolumn)
-                   it = it->find_prebroken_piece (rcolumn->break_status_dir ());
-
-                 Grob *last = Separation_item::extremal_break_aligned_grob (it, LEFT, &bar_xextent);
-
-                 if (last)
-                   bar_yextent = Staff_spacing::bar_y_positions (last);
-
-                 break;
-               }
-
-             return;
-           }
+           return;
 
          if (Stem::is_invisible (stem))
            {
index 31bd53a2d53f39cb53a1ee78183b70fe5bc12db1..aafb49399e57c68e9ee2ad843536293296aedcba 100644 (file)
@@ -49,8 +49,11 @@ protected:
   Spacings last_spacings_;
 
   DECLARE_ACKNOWLEDGER (item);
+  DECLARE_ACKNOWLEDGER (break_aligned);
   void stop_translation_timestep ();
   void start_translation_timestep ();
+
+  vector<Grob*> break_aligned_;
 public:
   TRANSLATOR_DECLARATIONS (Separating_line_group_engraver);
 };
@@ -101,6 +104,12 @@ Separating_line_group_engraver::acknowledge_item (Grob_info i)
     }
 }
 
+void
+Separating_line_group_engraver::acknowledge_break_aligned (Grob_info gi)
+{
+  break_aligned_.push_back (gi.grob ());
+}
+
 void
 Separating_line_group_engraver::start_translation_timestep ()
 {
@@ -110,6 +119,18 @@ Separating_line_group_engraver::start_translation_timestep ()
 void
 Separating_line_group_engraver::stop_translation_timestep ()
 {
+  for (vsize i = 0; i < break_aligned_.size (); i++)
+    {
+      SCM smob = break_aligned_[i]->self_scm ();
+
+      if (Item *sp = current_spacings_.staff_spacing_)
+       Pointer_group_interface::add_grob (sp, ly_symbol2scm ("left-break-aligned"), smob);
+
+      for (vsize j = 0; j < last_spacings_.note_spacings_.size (); j++)
+       Pointer_group_interface::add_grob (last_spacings_.note_spacings_[j],
+                                          ly_symbol2scm ("right-break-aligned"), smob);
+    }
+
   if (!current_spacings_.is_empty ())
     last_spacings_ = current_spacings_;
 
@@ -118,9 +139,12 @@ Separating_line_group_engraver::stop_translation_timestep ()
       Pointer_group_interface::add_grob (sp, ly_symbol2scm ("right-items"), col);
 
   current_spacings_.clear ();
+  break_aligned_.clear ();
 }
 
 ADD_ACKNOWLEDGER (Separating_line_group_engraver, item);
+ADD_ACKNOWLEDGER (Separating_line_group_engraver, break_aligned);
+
 ADD_TRANSLATOR (Separating_line_group_engraver,
                /* doc */ "Generates objects for computing spacing parameters.",
 
index a692fc0b9b558b7e0b30d4419b96232d6aaefc2a..00103c31d4ee5839682d375084b6c568ad39815f 100644 (file)
@@ -128,45 +128,6 @@ Separation_item::boxes (Grob *me, Grob *left)
   return out;      
 }
 
-/*
-  Try to find the break-aligned symbol in SEPARATION_ITEM that is
-  sticking out at direction D. The x size is put in LAST_EXT
-*/
-Grob *
-Separation_item::extremal_break_aligned_grob (Grob *me,
-                                             Direction d,
-                                             Interval *last_ext)
-{
-  Grob *col = dynamic_cast<Item *> (me)->get_column ();
-  last_ext->set_empty ();
-  Grob *last_grob = 0;
-
-  extract_grob_set (me, "elements", elts);
-  for (vsize i = elts.size (); i--;)
-    {
-      Grob *break_item = elts[i];
-      if (!scm_is_symbol (break_item->get_property ("break-align-symbol")))
-       continue;
-
-      if (!scm_is_pair (break_item->get_property ("space-alist")))
-       continue;
-
-      Interval ext = break_item->extent (col, X_AXIS);
-
-      if (ext.is_empty ())
-       continue;
-
-      if (!last_grob
-         || (last_grob && d * (ext[d]- (*last_ext)[d]) > 0))
-       {
-         *last_ext = ext;
-         last_grob = break_item;
-       }
-    }
-
-  return last_grob;
-}
-
 extern bool debug_skylines;
 MAKE_SCHEME_CALLBACK (Separation_item, print, 1)
 SCM
index dbfe4e43c6dd1e4dc9cea9cf7632de16aacc7cc5..93bd1c2cfaf0549de703ef1892748916729b818e 100644 (file)
@@ -168,6 +168,52 @@ Spacing_interface::left_note_columns (Grob *me)
   return get_note_columns (elts);
 }
 
+/*
+  Try to find the break-aligned symbol that belongs on the D-side
+  of ME, sticking out in direction -D. The x size is put in LAST_EXT
+*/
+Grob *
+Spacing_interface::extremal_break_aligned_grob (Grob *me,
+                                               Direction d,
+                                               Direction break_dir,
+                                               Interval *last_ext)
+{
+  Grob *col = 0;
+  last_ext->set_empty ();
+  Grob *last_grob = 0;
+
+  extract_grob_set (me, d == LEFT ? "left-break-aligned" : "right-break-aligned", elts);
+
+  for (vsize i = elts.size (); i--;)
+    {
+      Item *break_item = dynamic_cast<Item*> (elts[i]);
+
+      if (break_item->break_status_dir () != break_dir)
+       break_item = break_item->find_prebroken_piece (break_dir);
+
+      if (!break_item || !scm_is_pair (break_item->get_property ("space-alist")))
+       continue;
+
+      if (!col)
+       col = dynamic_cast<Item*> (elts[0])->get_column ()->find_prebroken_piece (break_dir);
+
+      Interval ext = break_item->extent (col, X_AXIS);
+
+      if (ext.is_empty ())
+       continue;
+
+      if (!last_grob
+         || (last_grob && d * (ext[-d]- (*last_ext)[-d]) < 0))
+       {
+         *last_ext = ext;
+         last_grob = break_item;
+       }
+    }
+
+  return last_grob;
+}
+
+
 ADD_INTERFACE (Spacing_interface,
               "This object calculates the desired and minimum distances between two columns.",
 
index 8a8822a803ad16cd51237eab3f6b754ef553e2f8..72b997514c9738e23613aaf7f88a1380bd1ecc70 100644 (file)
@@ -119,8 +119,10 @@ Staff_spacing::get_spacing (Grob *me, Grob *right_col)
   Grob *left_col = me_item->get_column ();
 
   Interval last_ext;
-  Grob *last_grob = Separation_item::extremal_break_aligned_grob (left_col, RIGHT,
-                                                                 &last_ext);
+  Direction break_dir = me_item->break_status_dir ();
+  Grob *last_grob = Spacing_interface::extremal_break_aligned_grob (me, LEFT,
+                                                                   break_dir,
+                                                                   &last_ext);
   if (!last_grob)
     {
       /*