]> git.donarmstrong.com Git - lilypond.git/commitdiff
Merge branch 'master' of git://git.sv.gnu.org/lilypond
authorGraham Percival <graham@percival-music.ca>
Tue, 11 Dec 2007 07:16:52 +0000 (23:16 -0800)
committerGraham Percival <graham@percival-music.ca>
Tue, 11 Dec 2007 07:16:52 +0000 (23:16 -0800)
lily/ambitus-engraver.cc
lily/include/pitch-interval.hh
lily/pitch-interval.cc
scm/layout-page-layout.scm

index cd5402b2a0ac50768f80209484a92dc9d435c3c6..a9f1d92f57001726213ea408d25efc7063527f57 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "engraver.hh"
 
+#include "accidental-placement.hh"
 #include "axis-group-interface.hh"
 #include "item.hh"
 #include "note-head.hh"
@@ -17,6 +18,7 @@
 #include "pointer-group-interface.hh"
 #include "protected-scm.hh"
 #include "side-position-interface.hh"
+#include "separation-item.hh"
 #include "staff-symbol-referencer.hh" 
 #include "stream-event.hh"
 
@@ -38,6 +40,7 @@ private:
   Item *group_;
   Drul_array<Item *> heads_;
   Drul_array<Item *> accidentals_;
+  Drul_array<Stream_event *> causes_;
   Pitch_interval pitch_interval_;
   bool is_typeset_;
   int start_c0_;
@@ -65,7 +68,6 @@ Ambitus_engraver::create_ambitus ()
                             accidentals_[d]->self_scm ());
       Axis_group_interface::add_element (group_, heads_[d]);
       Axis_group_interface::add_element (group_, accidentals_[d]);
-      Side_position_interface::add_support (accidentals_[d], heads_[d]);
     }
   while (flip (&d) != DOWN);
 
@@ -120,7 +122,9 @@ Ambitus_engraver::acknowledge_note_head (Grob_info info)
   if (nr && nr->in_event_class ("note-event"))
     {
       Pitch pitch = *unsmob_pitch (nr->get_property ("pitch"));
-      pitch_interval_.add_point (pitch);
+      Direction expand_dir = pitch_interval_.add_point (pitch);
+      if (expand_dir)
+       causes_[expand_dir] = nr;
     }
 }
 
@@ -129,10 +133,15 @@ Ambitus_engraver::finalize ()
 {
   if (ambitus_ && !pitch_interval_.is_empty ())
     {
+      Grob * accidental_placement =
+       make_item ("AccidentalPlacement",
+                  accidentals_[DOWN]->self_scm ());
+
       Direction d = DOWN;
       do
        {
          Pitch p = pitch_interval_[d];
+         heads_[d]->set_property ("cause", causes_[d]->self_scm());
          heads_[d]->set_property ("staff-position",
                                   scm_from_int (start_c0_
                                                 + p.steps ()));
@@ -157,12 +166,15 @@ Ambitus_engraver::finalize ()
            {
              accidentals_[d]->set_property ("alteration", ly_rational2scm (p.get_alteration ()));
            }
+         Separation_item::add_conditional_item (heads_[d], accidental_placement);
+         Accidental_placement::add_accidental (accidental_placement, accidentals_[d]);
        }
       while (flip (&d) != DOWN);
 
 
       Pointer_group_interface::add_grob (ambitus_, ly_symbol2scm ("note-heads"), heads_[DOWN]);
       Pointer_group_interface::add_grob (ambitus_, ly_symbol2scm ("note-heads"), heads_[UP]);
+      Axis_group_interface::add_element (group_, accidental_placement);
     }
   else
     {
index 947e418ea0f10bfeccc7b83dcab614706f642284..478b58a7a8c5dff38cf559db52012cd881555f28 100644 (file)
@@ -16,7 +16,7 @@ class Pitch_interval : public Drul_array<Pitch>
 public:
   Pitch_interval ();
   Pitch_interval (Pitch, Pitch);
-  void add_point (Pitch);
+  Direction add_point (Pitch);
   bool is_empty () const;
 };
 
@@ -25,7 +25,7 @@ class Pitch_lexicographic_interval : public Drul_array<Pitch>
 public:
   Pitch_lexicographic_interval ();
   Pitch_lexicographic_interval (Pitch, Pitch);
-  void add_point (Pitch);
+  Direction add_point (Pitch);
   bool is_empty () const;
 };
 
index f871e7e185b000df6cb1dfd8f6010a3e2c1fbfaa..84d4911498525bcabf2decdb443af58a6e5c14a7 100644 (file)
@@ -28,13 +28,21 @@ Pitch_interval::is_empty () const
   return at (LEFT) > at (RIGHT);
 }
 
-void
+Direction
 Pitch_interval::add_point (Pitch p)
 {
   if (at (LEFT).tone_pitch () > p.tone_pitch ())
-    at (LEFT) = p;
-  if (at (RIGHT).tone_pitch () < p.tone_pitch ())
-    at (RIGHT) = p;
+    {
+      at (LEFT) = p;
+      return LEFT;
+    }
+  else if (at (RIGHT).tone_pitch () < p.tone_pitch ())
+    {
+      at (RIGHT) = p;
+      return RIGHT;
+    }
+  else
+    return CENTER;
 }
 
 
@@ -56,11 +64,19 @@ Pitch_lexicographic_interval::is_empty () const
   return at (LEFT) > at (RIGHT);
 }
 
-void
+Direction
 Pitch_lexicographic_interval::add_point (Pitch p)
 {
   if (at (LEFT) > p)
-    at (LEFT) = p;
-  if (at (RIGHT) < p)
-    at (RIGHT) = p;
+    {
+      at (LEFT) = p;
+      return LEFT;
+    }
+  else if (at (RIGHT) < p)
+    {
+      at (RIGHT) = p;
+      return RIGHT;
+    }
+  else
+    return CENTER;
 }
index 1686d9613a11d7ac097e484f797f462282feb372..38da734bd38a5b6add540937a7ab56680b0d014b 100644 (file)
   "Ideal distance between `line' reference position and `next-line'
  reference position. If next-line is #f, return #f."
   (and next-line
-       (max 0
-           (+ (- (+ (interval-end (paper-system-staff-extents next-line))
-                    (if ignore-padding 0 (line-next-padding line next-line layout)))
-                 (interval-start (paper-system-staff-extents line)))
-              (line-next-space line next-line layout)))))
+       (max (+ (max 0 (- (+ (interval-end (paper-system-staff-extents next-line))
+                           (if ignore-padding 0 (line-next-padding line next-line layout)))
+                        (interval-start (paper-system-staff-extents line))))
+              (line-next-space line next-line layout))
+           (line-minimum-distance line next-line layout ignore-padding))))
 
 (define (first-line-position line layout)
   "Position of the first line on page"