]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beaming-pattern.cc
Fix 1112.
[lilypond.git] / lily / beaming-pattern.cc
index ab89bc386e90b05fceb8c184b0f7257fb4b7c6df..3659525f115eb91c6e2b86973876cb1889c53469 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1999--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1999--2010 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
@@ -245,6 +245,51 @@ Beaming_pattern::beamlet_count (int i, Direction d) const
   return infos_.at (i).beam_count_drul_[d];
 }
 
+Moment
+Beaming_pattern::start_moment (int i) const
+{
+  return infos_.at (i).start_moment_;
+}
+
+Moment
+Beaming_pattern::end_moment (int i) const
+{
+  Duration *dur = new Duration (2 + max (beamlet_count (i, LEFT),
+                                        beamlet_count (i, RIGHT)),
+                               0);
+
+  return infos_.at (i).start_moment_ + dur->get_length();
+}
+
+bool
+Beaming_pattern::invisibility (int i) const
+{
+  return infos_.at (i).invisible_;
+}
+
+/*
+    Split a beamin pattern at index i and return a new
+    Beaming_pattern containing the removed elements
+*/
+Beaming_pattern *
+Beaming_pattern::split_pattern (int i)
+{
+  Beaming_pattern* new_pattern=0;
+  int count;
+
+  new_pattern = new Beaming_pattern ();
+  for (vsize j=i+1; j<infos_.size (); j++)
+    {
+      count = max(beamlet_count (j, LEFT), beamlet_count(j, RIGHT));
+      new_pattern->add_stem (start_moment (j),
+                             count,
+                             invisibility (j));
+    }
+  for (vsize j=i+1; j<infos_.size (); )
+    infos_.pop_back ();
+  return (new_pattern);
+}
+
 void
 Beaming_options::from_context (Context *context)
 {