]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-column.cc
unsmob_pitch -> Pitch::unsmob and related
[lilypond.git] / lily / note-column.cc
index b98b4c68f8079ce1178da7c2cc2883afc978eacf..28a0b13d77e0a0c808054245a0cc7e2e715dbd44 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1997--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -40,35 +40,10 @@ using namespace std;
   annoying layer between (rest)collision & (note-head + stem)
 */
 
-Interval
-Note_column::accidental_width (Grob *me)
-{
-  extract_grob_set (me, "note-heads", nhs);
-  vector<Grob *> accs;
-  for (vsize i = 0; i < nhs.size (); i++)
-    if (Grob *acc = unsmob_grob (nhs[i]->get_object ("accidental-grob")))
-      accs.push_back (acc);
-
-  Grob *common = common_refpoint_of_array (accs, me, X_AXIS);
-  common = common_refpoint_of_array (nhs, common, X_AXIS);
-
-  Interval nhs_ex = Axis_group_interface::relative_group_extent (nhs, common, X_AXIS);
-  Interval accs_ex = Axis_group_interface::relative_group_extent (accs, common, X_AXIS);
-
-  if (nhs_ex.is_empty ())
-    return accs_ex;
-
-  // want an empty interval here
-  if (accs_ex.is_empty ())
-    return Interval ();
-
-  return Interval (accs_ex[LEFT], nhs_ex[LEFT]);
-}
-
 bool
 Note_column::has_rests (Grob *me)
 {
-  return unsmob_grob (me->get_object ("rest"));
+  return Grob::unsmob (me->get_object ("rest"));
 }
 
 bool
@@ -122,7 +97,7 @@ Note_column::head_positions_interval (Grob *me)
 Direction
 Note_column::dir (Grob *me)
 {
-  Grob *stem = unsmob_grob (me->get_object ("stem"));
+  Grob *stem = Grob::unsmob (me->get_object ("stem"));
   if (stem && Stem::has_interface (stem))
     return get_grob_direction (stem);
   else
@@ -146,7 +121,7 @@ Note_column::set_stem (Grob *me, Grob *stem)
 Grob *
 Note_column::get_rest (Grob *me)
 {
-  return unsmob_grob (me->get_object ("rest"));
+  return Grob::unsmob (me->get_object ("rest"));
 }
 
 void
@@ -163,7 +138,7 @@ Note_column::add_head (Grob *me, Grob *h)
     }
   else if (Note_head::has_interface (h))
     {
-      if (unsmob_grob (me->get_object ("rest")))
+      if (Grob::unsmob (me->get_object ("rest")))
         both = true;
       Pointer_group_interface::add_grob (me, ly_symbol2scm ("note-heads"), h);
     }
@@ -181,6 +156,26 @@ Note_column::first_head (Grob *me)
   return st ? Stem::first_head (st) : 0;
 }
 
+/*
+  Return extent of the noteheads in the "main column",
+  i.e. excluding any suspended noteheads.
+*/
+Interval
+Note_column::calc_main_heads_extent (Grob *me)
+{
+  if (get_stem (me))
+    return first_head (me)->extent (me, X_AXIS);
+  else
+    {
+      // no stems => no suspended noteheads.
+      extract_grob_set (me, "note-heads", heads);
+      if (heads.size())
+        return heads[0]->extent (me, X_AXIS);
+      else
+        return Interval (0, 0);
+    }
+}
+
 /*
   Return the first AccidentalPlacement grob that we find in a note-head.
 */
@@ -192,7 +187,7 @@ Note_column::accidentals (Grob *me)
   for (vsize i = 0; i < heads.size (); i++)
     {
       Grob *h = heads[i];
-      acc = h ? unsmob_grob (h->get_object ("accidental-grob")) : 0;
+      acc = h ? Grob::unsmob (h->get_object ("accidental-grob")) : 0;
       if (acc)
         break;
     }
@@ -213,7 +208,7 @@ Note_column::dot_column (Grob *me)
   extract_grob_set (me, "note-heads", heads);
   for (vsize i = 0; i < heads.size (); i++)
     {
-      Grob *dots = unsmob_grob (heads[i]->get_object ("dot"));
+      Grob *dots = Grob::unsmob (heads[i]->get_object ("dot"));
       if (dots)
         return dots->get_parent (X_AXIS);
     }