]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spacing-spanner.cc
* lily/midi-item.cc (name): new method.
[lilypond.git] / lily / spacing-spanner.cc
index 703337bd0bd46dbd6030783e0758089490e6db04..783889d3c8989eafe95cea78ac7069d3b463ed23 100644 (file)
 #include "staff-spacing.hh"
 #include "spacing-interface.hh"
 
-
-
-void
-Spacing_options::init (Grob *me)
-{
-  increment_ = robust_scm2double (me->get_property ("spacing-increment"), 1);
-  packed_ = to_boolean (me->get_layout ()->c_variable ("packed"));
-  stretch_uniformly_ = to_boolean (me->get_property ("uniform-stretching"));
-  float_nonmusical_columns_
-    = to_boolean (me->get_property ("strict-note-spacing"));
-}
-
-
 Rational
-Spacing_spanner::effective_shortest_duration (Grob *me, Link_array<Grob> const &all)
+Spacing_spanner::effective_shortest_duration (Grob *me,
+                                             Link_array<Grob> const &all)
 {
   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_;
-    }
+    global_shortest = unsmob_moment (preset_shortest)->main_part_;
   else
     {
       global_shortest = Spacing_spanner::find_shortest (me, all);
@@ -55,7 +41,6 @@ Spacing_spanner::effective_shortest_duration (Grob *me, Link_array<Grob> const &
   return global_shortest;
 }
 
-
 MAKE_SCHEME_CALLBACK (Spacing_spanner, set_springs, 1);
 SCM
 Spacing_spanner::set_springs (SCM smob)
@@ -70,9 +55,9 @@ Spacing_spanner::set_springs (SCM smob)
   set_explicit_neighbor_columns (all);
 
   Spacing_options options;
-  options.init (me);
+  options.init_from_grob (me);
   options.global_shortest_ = effective_shortest_duration (me, all);
-  
+
   prune_loose_columns (me, &all, &options);
   set_implicit_neighbor_columns (all);
   generate_springs (me, all, &options);
@@ -181,14 +166,12 @@ Spacing_spanner::generate_pair_spacing (Grob *me,
   if (Paper_column::is_musical (left_col))
     {
       bool skip_unbroken_right = false;
-      
+
       if (!Paper_column::is_musical (right_col)
          && options->float_nonmusical_columns_
          && after_right_col
          && Paper_column::is_musical (after_right_col))
-       {
-         skip_unbroken_right = true;
-       }
+       skip_unbroken_right = true;
 
       if (skip_unbroken_right)
        {
@@ -201,7 +184,6 @@ Spacing_spanner::generate_pair_spacing (Grob *me,
        }
       else
        musical_column_spacing (me, left_col, right_col, options);
-      
 
       if (Item *rb = right_col->find_prebroken_piece (LEFT))
        musical_column_spacing (me, left_col, rb, options);
@@ -218,7 +200,7 @@ Spacing_spanner::generate_pair_spacing (Grob *me,
 
       if (left_col && right_col)
        breakable_column_spacing (me, left_col, right_col, options);
-         
+
       if (lb && right_col)
        breakable_column_spacing (me, lb, right_col, options);
 
@@ -260,14 +242,12 @@ Spacing_spanner::musical_column_spacing (Grob *me,
 {
   bool expand_only = false;
   Real base_note_space = note_spacing (me, left_col, right_col, options, &expand_only);
-  
+
   Real compound_note_space = 0.0;
   Real compound_fixed_note_space = 0.0;
 
   if (options->stretch_uniformly_)
-    {
-      compound_note_space = base_note_space;
-    }
+    compound_note_space = base_note_space;
   else
     {
       int wish_count = 0;
@@ -334,7 +314,7 @@ Spacing_spanner::musical_column_spacing (Grob *me,
       compound_fixed_note_space = min (compound_fixed_note_space,
                                       compound_note_space);
     }
-  
+
   Real inverse_strength = 1.0;
   Real distance = 1.0;
 
@@ -430,10 +410,8 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r,
     }
 
   if (options->stretch_uniformly_ && l->break_status_dir () != RIGHT)
-    {
-      compound_fixed = 0.0;
-    }
-  
+    compound_fixed = 0.0;
+
   assert (!isinf (compound_space));
   compound_space = max (compound_space, compound_fixed);
 
@@ -460,11 +438,10 @@ ADD_INTERFACE (Spacing_spanner, "spacing-spanner-interface",
               "gets 2 note heads width (i.e. the space following a note is 1 note\n"
               "head width) A 16th note is followed by 0.5 note head width. The\n"
               "quarter note is followed by  3 NHW, the half by 4 NHW, etc.\n",
-              
-              "grace-space-factor spacing-increment base-shortest-duration strict-note-spacing "
-              "shortest-duration-space common-shortest-duration uniform-stretching"
 
-              );
+              "grace-space-factor spacing-increment base-shortest-duration strict-note-spacing "
+              "shortest-duration-space common-shortest-duration uniform-stretching "
+              "packed-spacing ");
 
 ADD_INTERFACE (Spacing_interface, "spacing-interface",
               "Something to do with line breaking and spacing. "