]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/spacing-determine-loose-columns.cc (is_loose_column):
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 20 Jul 2006 11:09:47 +0000 (11:09 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 20 Jul 2006 11:09:47 +0000 (11:09 +0000)
support float_grace_columns_.

* lily/spacing-options.cc (init_from_grob): new file.

* Documentation/topdocs/NEWS.tely (Top): doc tupletFullLengthNote.

* Documentation/topdocs/NEWS.tely (Top): document new feature.

ChangeLog
lily/include/spacing-spanner.hh
lily/spacing-options.cc [new file with mode: 0644]
lily/spacing-spanner.cc

index 852e9973c8cdfaa877c3bf6da047118898ec023b..0d6ae510196fba5e7f81ddb8056a9b6b4e192366 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2006-07-20  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
+       * scm/define-grob-properties.scm (all-user-grob-properties): add
+       strict-grace-spacing.
+
        * lily/spacing-determine-loose-columns.cc (is_loose_column):
        support float_grace_columns_.
 
index a8d9888397116c1eef3b23a055beef1acc0fa8db..d2259533c824a12452720dfab851ec920d158747 100644 (file)
@@ -45,7 +45,6 @@ public:
   static Real default_bar_spacing (Grob *, Grob *, Grob *, Moment);
   static Real note_spacing (Grob *, Grob *, Grob *, Spacing_options const *, bool *);
   static Real get_duration_space (Moment dur, Spacing_options const *, bool *);
-  static Rational find_shortest (Grob *, vector<Grob*> const &);
   static Rational effective_shortest_duration (Grob *me, vector<Grob*> const &all);
   static void breakable_column_spacing (Grob *, Item *l, Item *r, Spacing_options const *);
   static void prune_loose_columns (Grob *, vector<Grob*> *cols, Spacing_options const *);
@@ -53,7 +52,10 @@ public:
   static void set_implicit_neighbor_columns (vector<Grob*> const &cols);
   static void generate_springs (Grob *me, vector<Grob*> const &cols, Spacing_options const *);
   static void musical_column_spacing (Grob *, Item *, Item *, Spacing_options const *);
+  static vector<Grob*> get_columns (Spanner *me);
+
   DECLARE_SCHEME_CALLBACK (set_springs, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_common_shortest_duration, (SCM));
   static bool has_interface (Grob *);
 };
 
diff --git a/lily/spacing-options.cc b/lily/spacing-options.cc
new file mode 100644 (file)
index 0000000..7a038eb
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+  spacing-options.cc -- implement Spacing_options 
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2006 Han-Wen Nienhuys <hanwen@lilypond.org>
+
+*/
+
+#include "spacing-spanner.hh"
+#include "grob.hh"
+
+void
+Spacing_options::init_from_grob (Grob *me)
+{
+  increment_ = robust_scm2double (me->get_property ("spacing-increment"), 1);
+
+  packed_ = to_boolean (me->get_property ("packed-spacing"));
+  stretch_uniformly_ = to_boolean (me->get_property ("uniform-stretching"));
+  float_nonmusical_columns_
+    = to_boolean (me->get_property ("strict-note-spacing"));
+  float_grace_columns_
+    = to_boolean (me->get_property ("strict-grace-spacing"));
+  shortest_duration_space_ = robust_scm2double (me->get_property ("shortest-duration-space"), 1);
+}
+
+Spacing_options::Spacing_options ()
+{
+  increment_ = 1.2;
+  packed_ = false;
+  stretch_uniformly_ = false;
+  float_nonmusical_columns_ = false;
+  float_grace_columns_ = false;
+  shortest_duration_space_ = 2.0;
+
+  global_shortest_ = Rational (1, 8);
+}
index 9c48aaec0a0a384413db2d6e35ada1cd3af3e549..55e2a6ca3aab37b1017b5046988dcb71c9e8eaa3 100644 (file)
@@ -26,32 +26,20 @@ using namespace std;
 #include "system.hh"
 #include "warn.hh"
 
-
-/*
-  TODO:
-
-  use callback instead?
-
-*/
-Rational
-Spacing_spanner::effective_shortest_duration (Grob *me,
-                                             vector<Grob*> const &all)
+vector<Grob*>
+Spacing_spanner::get_columns (Spanner *me)
 {
-  SCM preset_shortest = me->get_property ("common-shortest-duration");
-  Rational global_shortest;
-  if (unsmob_moment (preset_shortest))
-    global_shortest = unsmob_moment (preset_shortest)->main_part_;
-  else
-    {
-      global_shortest = Spacing_spanner::find_shortest (me, all);
-      if (be_verbose_global)
-       message (_f ("Global shortest duration is %s", global_shortest.to_string ()) + "\n");
-    }
+  vector<Grob*> all (get_root_system (me)->columns ());
+  vsize start = binary_search (all, (Grob*)me->get_bound (LEFT),
+                              &Paper_column::compare);
+  vsize end = binary_search (all, (Grob*) me->get_bound (RIGHT),
+                            &Paper_column::compare);
 
-  return global_shortest;
+  all = vector<Grob*>::vector<Grob*> (all.begin () + start,
+                                     all.begin () + end + 1);
+  return all;
 }
 
-
 MAKE_SCHEME_CALLBACK (Spacing_spanner, set_springs, 1);
 SCM
 Spacing_spanner::set_springs (SCM smob)
@@ -61,20 +49,13 @@ Spacing_spanner::set_springs (SCM smob)
   /*
     can't use get_system() ? --hwn.
   */
-  vector<Grob*> all (get_root_system (me)->columns ());
-  vsize start = binary_search (all, (Grob*)me->get_bound (LEFT),
-                              &Paper_column::compare);
-  vsize end = binary_search (all, (Grob*) me->get_bound (RIGHT),
-                            &Paper_column::compare);
-
-  all = vector<Grob*>::vector<Grob*> (all.begin () + start,
-                                     all.begin () + end + 1);
-  
+  vector<Grob*> all (get_columns (me));
   set_explicit_neighbor_columns (all);
 
   Spacing_options options;
   options.init_from_grob (me);
-  options.global_shortest_ = effective_shortest_duration (me, all);
+  options.global_shortest_ = robust_scm2moment (me->get_property ("common-shortest-duration"),
+                                               Moment (1,8)).main_part_;
 
   prune_loose_columns (me, &all, &options);
   set_implicit_neighbor_columns (all);
@@ -92,9 +73,15 @@ Spacing_spanner::set_springs (SCM smob)
   note has a different duration, but hey, don't write that kind of
   stuff, then.
 */
-Rational
-Spacing_spanner::find_shortest (Grob *me, vector<Grob*> const &cols)
+
+MAKE_SCHEME_CALLBACK (Spacing_spanner, calc_common_shortest_duration, 1);
+SCM 
+Spacing_spanner::calc_common_shortest_duration (SCM grob)
 {
+  Spanner *me = unsmob_spanner (grob);
+
+  vector<Grob*> cols (get_columns (me));
+  
   /*
     ascending in duration
   */
@@ -172,7 +159,7 @@ Spacing_spanner::find_shortest (Grob *me, vector<Grob*> const &cols)
   if (max_idx >= 0)
     d = min (d, durations[max_idx]);
 
-  return d;
+  return Moment (d).smobbed_copy ();
 }
 
 void