]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.112
authorfred <fred>
Wed, 27 Mar 2002 00:33:48 +0000 (00:33 +0000)
committerfred <fred>
Wed, 27 Mar 2002 00:33:48 +0000 (00:33 +0000)
input/test/broken-thread-line.ly [new file with mode: 0644]
lily/grob.cc
lily/line-spanner.cc [new file with mode: 0644]
scm/element-descriptions.scm
scm/interface.scm

diff --git a/input/test/broken-thread-line.ly b/input/test/broken-thread-line.ly
new file mode 100644 (file)
index 0000000..6c765fe
--- /dev/null
@@ -0,0 +1,23 @@
+
+
+% followThread: connect note heads with line when thread switches staff 
+
+\score{
+    \context PianoStaff <
+        \context Staff=one \notes\relative c''{
+           \context Thread
+            a1 \break
+           \translator Staff=two
+           a,
+
+       }
+       \context Staff=two { \clef bass; \skip 1*2; }
+    >
+    \paper{
+        linewidth = 70.\mm;
+       \translator {
+           \ScoreContext
+           followThread = ##t
+       }
+    }
+}
index 3cf09fcc4aaf0317245c19e0ac59c7876b1de927..fdfb97c06995c800d8d6eddcd4a0a189c810cc85 100644 (file)
@@ -77,7 +77,7 @@ Grob::Grob(SCM basicprops)
     /*
       Should change default to be empty? 
      */
-    if (!gh_procedure_p (cb) && !gh_pair_p (cb))
+    if (cb != SCM_BOOL_F && !gh_procedure_p (cb) && !gh_pair_p (cb))
       cb = molecule_extent_proc;
     
     dim_cache_[a].dimension_ = cb;
diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc
new file mode 100644 (file)
index 0000000..bece984
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+  line-spanner.cc -- implement Line_spanner
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "molecule.hh"
+#include "item.hh"
+#include "spanner.hh"
+#include "line-spanner.hh"
+#include "paper-def.hh"
+#include "paper-column.hh"
+#include "staff-symbol-referencer.hh"
+
+SCM
+Line_spanner::line_atom (Grob* me, Real dx, Real dy)
+{
+  SCM list = SCM_EOL;
+  SCM type = me->get_grob_property ("type");
+  if (gh_symbol_p (type)
+      && (type == ly_symbol2scm ("line")
+         || type == ly_symbol2scm ("dashed-line")
+         || type == ly_symbol2scm ("dotted-line")))
+    {
+      Real staff_space = Staff_symbol_referencer::staff_space (me);
+      Real thick = me->paper_l ()->get_var ("stafflinethickness");  
+
+      SCM s = me->get_grob_property ("line-thickness");
+      if (gh_number_p (s))
+       thick *= gh_scm2double (s);
+  
+      // maybe these should be in line-thickness?
+      Real length = staff_space;
+      s = me->get_grob_property ("dash-length");
+      if (gh_number_p (s))
+       length = gh_scm2double (s) * staff_space;
+
+      Real period = 2 * length + thick;
+      s = me->get_grob_property ("dash-period");
+      if (gh_number_p (s))
+       period = gh_scm2double (s) * staff_space;
+      
+      if (type == ly_symbol2scm ("dotted-line"))
+       length = thick;
+       
+      if (type == ly_symbol2scm ("line"))
+       length = period + thick;
+
+      Real on = length - thick;
+      Real off = period - on;
+
+      list = gh_list (ly_symbol2scm ("dashed-line"),
+                     gh_double2scm (thick),
+                     gh_double2scm (on),
+                     gh_double2scm (off),
+                     gh_double2scm (dx),
+                     gh_double2scm (dy),
+                     SCM_UNDEFINED);
+    }
+  return list;
+}
+
+
+
+/*
+  Warning: this thing is a cross-staff object, so it should have empty Y-dimensions.
+
+  (If not, you risk that this is called from the staff-alignment
+  routine, via molecule_extent. At this point, the staffs aren't
+  separated yet, so it doesn't work cross-staff.
+
+*/
+
+MAKE_SCHEME_CALLBACK (Line_spanner, brew_molecule, 1);
+SCM
+Line_spanner::brew_molecule (SCM smob) 
+{
+  Grob *me= unsmob_grob (smob);
+  Spanner *spanner = dynamic_cast<Spanner*> (me);
+
+  Grob *common[] = { 0, 0 };
+
+  Item *l = spanner->get_bound (LEFT);
+  Item *r = spanner->get_bound (RIGHT);  
+
+  /*
+    FIXME: should also do something sensible across line breaks.
+   */
+  if (l->break_status_dir () || r->break_status_dir ())
+    return SCM_EOL;
+  
+  for (Axis a = X_AXIS;  a < NO_AXES; a = Axis (a + 1))
+    {
+      common[a] = l->common_refpoint (r, a);
+  
+    if (!common[a])
+      return SCM_EOL;
+    }
+  
+  Offset dxy ; 
+  for (Axis a = X_AXIS;  a < NO_AXES; a = Axis (a + 1))
+    {
+      dxy[a] = r->extent (common[a], a)[LEFT] -
+       l->extent (common[a], a)[RIGHT];
+    }
+  
+  Molecule line;
+  Real gap = gh_scm2double (me->get_grob_property ("gap"));
+
+  Offset my_off(me->relative_coordinate (common[X_AXIS], X_AXIS),
+               me->relative_coordinate (common[Y_AXIS], Y_AXIS) ); 
+  Offset his_off(l->relative_coordinate (common[X_AXIS], X_AXIS),
+                l->relative_coordinate (common[Y_AXIS], Y_AXIS) ); 
+  dxy *= (dxy.length () - 2 * gap) / dxy.length ();
+  
+  SCM list = Line_spanner::line_atom (me, dxy[X_AXIS], dxy[Y_AXIS]);
+    
+  if (list == SCM_EOL)
+    return SCM_EOL;
+  
+  Box b (Interval (0, dxy[X_AXIS]), Interval (0, dxy[Y_AXIS]));
+  
+  line = Molecule (b, list);
+  line.translate_axis (l->extent (l, X_AXIS).length (), X_AXIS); 
+  
+  
+  Offset g = dxy * (gap / dxy.length ());
+  line.translate (g - my_off + his_off);
+      
+  return line.smobbed_copy ();
+}
+
+
index 97c1fac4b0e582d2b74b94cbd466439bff590122..5ab89e84dfdf44b8d800dd7c810b86d0a730f03d 100644 (file)
@@ -4,6 +4,7 @@
 (define all-element-descriptions
   `((Arpeggio . (
               (X-extent-callback . ,Arpeggio::width_callback)
+              (Y-extent-callback . #f)        
               (molecule-callback . ,Arpeggio::brew_molecule)
               (Y-offset-callbacks . (,Staff_symbol_referencer::callback))
               (X-offset-callbacks . (,Side_position::aligned_side))
                        rhythmic-head-interface font-interface 
                        note-head-interface ))
        ))
+       (NoteHeadLine . (
+                        (type . line)
+                        (gap . 0.5)
+                        (X-extent-callback . #f)
+                        (Y-extent-callback . #f)                        
+                        (molecule-callback . ,Line_spanner::brew_molecule)
+                        (meta . ,(element-description "NoteHeadLine"
+                                                      line-spanner-interface))
+                        ))
 
        (NoteName . (
                (molecule-callback . ,Text_item::brew_molecule)
                (meta . ,(element-description "SpacingSpanner"  spacing-spanner-interface))
        ))
        (SpanBar . (
-
                (break-align-symbol . Staff_bar)
                (barsize-procedure . ,Span_bar::get_bar_size) 
                (molecule-callback . ,Bar::brew_molecule)
                (meta . ,(element-description "SustainPedal" sustain-pedal-interface side-position-interface font-interface))
        ))
 
+       ; should split in 3
        (SystemStartDelimiter . (
                (molecule-callback . ,System_start_delimiter::brew_molecule)
                (after-line-breaking-callback . ,System_start_delimiter::after_line_breaking)
index a989bdbef8749483011bc4d2b441dcc225a450c1..f8e19e52ce73566863116e820400162ed621bbbd 100644 (file)
@@ -472,20 +472,29 @@ font-point-size font-relative-size)
 
     )))
 
+(define line-spanner-interface
+  (lily-interface
+   'line-spanner-interface
+   "Generic line drawn between two objects, eg. for use with glissandi.
+gap is relative to the total length of the line.   "
+
+   '(gap 
+    dash-period 
+    dash-length 
+    line-thickness 
+    type 
+    )
+   ))
+
 (define lyric-hyphen-interface
   (lily-interface
    'lyric-hyphen-interface
    "A centred hyphen is a simple line between lyrics used to divide
 syllables.   The length of the hyphen line should stretch based on the
   size of the gap between syllables."
-   '(
-    
-    thickness 
-    height 
 
-    minimum-length 
-    word-space 
-    )))
+   '( thickness height minimum-length word-space )
+   ))
 
 (define key-signature-interface
   (lily-interface
@@ -534,32 +543,21 @@ numbers, fields from font-interface may be used.
 padding is the space between number and rest. Measured in staffspace.
  
 "
-   '(
-    
-    columns  
-    expand-limit  
-    minimum-width 
-    padding  
-    )))
+   '(    columns expand-limit minimum-width padding )
+
+   ))
 
 (define paper-column-interface
   (lily-interface
    'paper-column-interface
    ""
-   '(
-    column-space-strength 
-    before-musical-spacing-factor 
-    stem-spacing-correction 
-    before-grace-spacing-factor 
-    when 
-    bounded-by-me 
-    dir-list  
-    shortest-playing-duration  
-    shortest-starter-duration  
-    contains-grace  
-    extra-space  
-    stretch-distance 
-    )))
+
+   '(column-space-strength before-musical-spacing-factor
+stem-spacing-correction before-grace-spacing-factor when bounded-by-me
+dir-list shortest-playing-duration shortest-starter-duration
+contains-grace extra-space stretch-distance ))
+
+  )
 
 (define spaceable-element-interface
   (lily-interface