]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/parenthesis-engraver.cc (acknowledge_grob): don't do
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 10 Feb 2006 12:03:58 +0000 (12:03 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 10 Feb 2006 12:03:58 +0000 (12:03 +0000)
set_parent() for parentheses. This will make it show up in bbox
calculations.

* scm/output-lib.scm (parentheses-item::print): rewrite, using
ly:grob-common* functions.

* lily/grob-scheme.cc (LY_DEFINE):
ly:grob-common-refpoint-of-array: new function
ly:grob-common-refpoint: new function
ly:grob-relative-coordinate: new function

* lily/instrument-name-engraver.cc (process_music): use
Text_interface::is_markup(). This fixes \markup on instrument names.

* scm/define-grobs.scm (all-grob-descriptions): set line-thickness
for ties and slurs.

* lily/slur.cc (print): idem.

* lily/tie.cc: add line-thickness for ties.

ChangeLog
Documentation/topdocs/NEWS.tely
input/regression/parenthesize.ly
lily/grob-scheme.cc
lily/instrument-name-engraver.cc
lily/parenthesis-engraver.cc
lily/slur.cc
lily/tie.cc
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/output-lib.scm

index 44cab2c9c757cc7d2852d62ae78451846659fc6b..baaf24c08f68c608ce5a55fca9a12077be549a20 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2006-02-10  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * lily/parenthesis-engraver.cc (acknowledge_grob): don't do
+       set_parent() for parentheses. This will make it show up in bbox
+       calculations.
+
+       * scm/output-lib.scm (parentheses-item::print): rewrite, using
+       ly:grob-common* functions.
+
+       * lily/grob-scheme.cc (LY_DEFINE):
+       ly:grob-common-refpoint-of-array: new function 
+       ly:grob-common-refpoint: new function 
+       ly:grob-relative-coordinate: new function 
+
+       * lily/instrument-name-engraver.cc (process_music): use
+       Text_interface::is_markup(). This fixes \markup on instrument names.  
+
+       * scm/define-grobs.scm (all-grob-descriptions): set line-thickness
+       for ties and slurs.
+
+       * lily/slur.cc (print): idem.
+
+       * lily/tie.cc: add line-thickness for ties. 
+
 2006-02-10  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * scm/output-svg.scm: Document diversion from GNU coding standards
@@ -5,6 +29,9 @@
 
 2006-02-10  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/instrument-name-engraver.cc (process_music): use
+       is_markup() iso. is_string()
+
        * Documentation/user/changing-defaults.itely (Module): add menu entry.
 
        * lily/percent-repeat-engraver.cc (process_music): only look at
index 07f3715861fc1073b59b5cd6ca3e32963b219a05..db850bdf918e1f8a80fd8bb930ed7a22fab02c58 100644 (file)
@@ -63,12 +63,14 @@ which scares away people.
 * only show user-visible changes. 
 
 @end ignore
-@item Items  directly connected with a music input element may be
-parenthesized, for example,
 
 
+
+@item Items directly connected with a music input element may be
+parenthesized, for example,
+
 @lilypond[verbatim,ragged-right,fragment,relative=2]
-c4 -\parenthesize -.
+c4-\parenthesize -.
 <d \parenthesize fis a> 
 @end lilypond
 
index e8b5050cc69528fcdcbfb740c23a4564efa3c21e..e554b3647f1668de1785534a61c674fdf5fef995 100644 (file)
@@ -4,20 +4,20 @@
 
   texidoc = "The parenthesize function is a special tweak that
   encloses objects in parentheses. The associated grob is
-  @code{Score.ParenthesesItem}.
-
-" 
+  @code{Score.ParenthesesItem}." 
 }
 
 
 \paper {
   ragged-right = ##t
-  }
+}
+
 \version "2.7.32"
 
 \relative {
   c4 -\parenthesize -.
 
+  \override ParenthesesItem #'padding = #0.1
   <d \parenthesize fis a> 
 
 }
index 4e44d8937dc2d50ded91cb71cc7bcf933f364a0f..d510a11bcb9a327f47db2fa0ad3c94fb70497080 100644 (file)
@@ -156,6 +156,32 @@ LY_DEFINE (ly_get_extent, "ly:grob-extent",
   return ly_interval2scm (sc->extent (ref, a));
 }
 
+
+LY_DEFINE (ly_grob_relative_coordinate, "ly:grob-relative-coordinate",
+          3, 0, 0, (SCM grob, SCM refp, SCM axis),
+          "Get the coordinate in @var{axis} direction of @var{grob} relative to "
+          "the grob @var{refp}")
+{
+  Grob *sc = unsmob_grob (grob);
+  Grob *ref = unsmob_grob (refp);
+  
+  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
+  SCM_ASSERT_TYPE (ref, refp, SCM_ARG2, __FUNCTION__, "grob");
+  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+
+  Axis a = Axis (scm_to_int (axis));
+
+    
+  if (ref->common_refpoint (sc, a) != ref)
+    {
+      // ugh. should use other error message
+      SCM_ASSERT_TYPE (false, refp, SCM_ARG2, __FUNCTION__, "common refpoint");
+    }
+
+  return scm_from_double (sc->relative_coordinate (ref,a));
+}
+
+
 LY_DEFINE (ly_grob_parent, "ly:grob-parent",
           2, 0, 0, (SCM grob, SCM axis),
           "Get the parent of @var{grob}.  @var{axis} is 0 for the X-axis, "
@@ -282,3 +308,38 @@ LY_DEFINE (ly_grob_default_font, "ly:grob-default-font",
 
   return Font_interface::get_default_font (gr)->self_scm ();
 }
+
+LY_DEFINE (ly_grob_common_refpoint, "ly:grob-common-refpoint",
+          3, 0, 0,  (SCM grob, SCM other, SCM axis),
+          "Find the common refpoint of @var{grob} and @var{other} for @var{axis}."
+          )
+{
+  
+  Grob *gr = unsmob_grob (grob);
+  SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "grob");
+
+  Grob *o = unsmob_grob (other);
+  SCM_ASSERT_TYPE (o, other, SCM_ARG2, __FUNCTION__, "grob");
+
+  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+
+  Grob *refp = gr->common_refpoint (o,  Axis (scm_to_int (axis)));
+  return refp ? refp->self_scm () : SCM_BOOL_F;
+}
+
+LY_DEFINE (ly_grob_common_refpoint_of_array, "ly:grob-common-refpoint-of-array",
+          3, 0, 0,  (SCM grob, SCM others, SCM axis),
+          "Find the common refpoint of @var{grob} and @var{others} "
+          "(a grob-array) for @var{axis}."
+          )
+{
+  Grob *gr = unsmob_grob (grob);
+  SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "grob");
+
+  Grob_array *ga = unsmob_grob_array (others);
+  SCM_ASSERT_TYPE (ga, others, SCM_ARG2, __FUNCTION__, "grob array");
+  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+
+  Grob *refp = common_refpoint_of_array (ga->array (), gr, Axis (scm_to_int (axis)));
+  return refp ? refp->self_scm () : SCM_BOOL_F;
+}
index e8fcfbef03efaaf2e909ad5988b0dc9ff88dc5eb..5320dfd5f77bb8d7403624b0c7614bc1403cec14 100644 (file)
@@ -12,6 +12,7 @@
 #include "side-position-interface.hh"
 #include "axis-group-interface.hh"
 #include "align-interface.hh"
+#include "text-interface.hh"
 
 #include "translator.icc"
 
@@ -41,18 +42,19 @@ Instrument_name_engraver::process_music ()
       SCM long_text = get_property ("instrument");
       SCM short_text = get_property ("instr");
 
-      if (! (scm_is_string (long_text)
-            || scm_is_string (short_text)))
+      if (!(Text_interface::is_markup (long_text)
+           || Text_interface::is_markup (short_text)))
        {
          long_text = get_property ("vocalName");
          short_text = get_property ("vocNam");
        }
   
-      if (scm_is_string (long_text)
-         || scm_is_string (short_text))
+      if (Text_interface::is_markup (long_text)
+         || Text_interface::is_markup (short_text))
        {
          text_spanner_ = make_spanner ("InstrumentName", SCM_EOL);
-         text_spanner_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
+         text_spanner_->set_bound (LEFT,
+                                   unsmob_grob (get_property ("currentCommandColumn")));
          text_spanner_->set_property ("text", short_text);
          text_spanner_->set_property ("long-text", long_text);
        }
index 13aba090bd091fe2f645a8429b88f4606ca59b9a..1f6a196e32fd00f81745cb25c7b11653767aca79 100644 (file)
@@ -14,6 +14,7 @@
 #include "music.hh"
 #include "grob.hh"
 #include "item.hh"
+#include "pointer-group-interface.hh"
 
 #include "translator.icc"
 
@@ -29,8 +30,6 @@ Parenthesis_engraver::Parenthesis_engraver()
 {
 }
 
-
-
 void
 Parenthesis_engraver::acknowledge_grob (Grob_info info)
 {
@@ -46,8 +45,8 @@ Parenthesis_engraver::acknowledge_grob (Grob_info info)
                                                       victim->self_scm (),
                                                       "ParenthesesItem");
 
-             paren->set_parent (victim, Y_AXIS);
-             paren->set_parent (victim, X_AXIS);
+             Pointer_group_interface::add_grob (paren, ly_symbol2scm ("elements"), victim);
+             
              Real size = robust_scm2double (paren->get_property ("font-size"), 0.0)
                + robust_scm2double (victim->get_property ("font-size"), 0.0);
              paren->set_property ("font-size", scm_from_double (size));
index 7c015019ffd3fb1d1dd2ca842023896c61a42728..8c1e7e090e366fd4d6db17c48a1a6624cf0c3ab9 100644 (file)
@@ -84,8 +84,11 @@ Slur::print (SCM smob)
     }
 
   Real staff_thick = Staff_symbol_referencer::line_thickness (me);
-  Real base_thick = robust_scm2double (me->get_property ("thickness"), 1);
-  Real thick = base_thick * staff_thick;
+  Real base_thick = staff_thick
+    * robust_scm2double (me->get_property ("thickness"), 1);
+  Real line_thick = staff_thick
+    * robust_scm2double (me->get_property ("line-thickness"), 1);
+
   Bezier one = get_curve (me);
   Stencil a;
 
@@ -95,12 +98,12 @@ Slur::print (SCM smob)
   SCM p = me->get_property ("dash-period");
   SCM f = me->get_property ("dash-fraction");
   if (scm_is_number (p) && scm_is_number (f))
-    a = Lookup::dashed_slur (one, thick, robust_scm2double (p, 1.0),
+    a = Lookup::dashed_slur (one, line_thick, robust_scm2double (p, 1.0),
                             robust_scm2double (f, 0));
   else
     a = Lookup::slur (one,
-                     get_grob_direction (me) * staff_thick * 1.0,
-                     thick);
+                     get_grob_direction (me) * base_thick,
+                     line_thick);
 
 #if DEBUG_SLUR_SCORING
   SCM quant_score = me->get_property ("quant-score");
index 9cf7468d6c8544054c6a80a465580c83c2cf8d83..4b0404d690ca4e02755f058414082f123bebc728 100644 (file)
@@ -201,7 +201,9 @@ Tie::calc_control_points (SCM smob)
   return SCM_UNSPECIFIED;
 }
 
-
+/*
+  TODO: merge witnh Slur::print.
+ */
 MAKE_SCHEME_CALLBACK (Tie, print, 1);
 SCM
 Tie::print (SCM smob)
@@ -211,8 +213,8 @@ Tie::print (SCM smob)
   SCM cp = me->get_property ("control-points");
 
   Real staff_thick = Staff_symbol_referencer::line_thickness (me);
-  Real base_thick = robust_scm2double (me->get_property ("thickness"), 1);
-  Real thick = base_thick * staff_thick;
+  Real base_thick = staff_thick * robust_scm2double (me->get_property ("thickness"), 1);
+  Real line_thick = staff_thick * robust_scm2double (me->get_property ("line-thickness"), 1);
 
   Bezier b;
   int i = 0;
@@ -228,13 +230,13 @@ Tie::print (SCM smob)
   SCM f = me->get_property ("dash-fraction");
   if (scm_is_number (p) && scm_is_number (f))
     a = Lookup::dashed_slur (b,
-                            thick,
+                            line_thick,
                             robust_scm2double (p, 1.0),
                             robust_scm2double (f, 0));
   else
     a = Lookup::slur (b,
-                     get_grob_direction (me) * staff_thick,
-                     thick);
+                     get_grob_direction (me) * base_thick,
+                     line_thick);
 
   return a.smobbed_copy ();
 }
@@ -253,6 +255,7 @@ ADD_INTERFACE (Tie,
               "dash-period "
               "details "
               "direction "
+              "line-thickness " 
               "thickness "
               );
 
index 4233361c26d3179a13c6161f2c8e17db37d87f02..49e8a20d6e6bdfc7f1d75fc5d2a9fe5cdb191282 100644 (file)
@@ -274,6 +274,7 @@ column is the start of a system.")
 
      (line-count ,integer? "The number of staff lines.")
      (line-positions ,list? "Vertical positions of staff lines.")
+     (line-thickness ,number? "The thickness of the tie/slur contour.")
      (long-text ,markup? "Text markup.  See @usermanref{Text markup}.")
      (measure-length ,ly:moment? "Length of a
 measure. Used in some spacing situations.")
index 660eacd0a5c2bd7cb9f270f1c4079046dda5943d..f7b9c530c6fb68a57014b22a0e8f80d93a7a885a 100644 (file)
        (Y-extent . ,ly:slur::height)
        (stencil . ,ly:slur::print)
        
-       (thickness . 1.0)
+       (thickness . 1.2)
+       (line-thickness . 0.8)
        (minimum-length . 1.5)
                                        ; ly:slur::height)
        (height-limit . 2.0)
                    (outer-tie-vertical-distance-symmetry-penalty-factor . 10)
                    (outer-tie-length-symmetry-penalty-factor . 10)
                    (between-length-limit . 1.0)))
-       (thickness . 1.0)
+       (thickness . 1.2)
+       (line-thickness . 0.8)
        (meta . ((class . Spanner)
                 (interfaces . (tie-interface))))
        ))
index ade314be23dd90114525cd2ad8c365927387ac43..1a7747e9e6936fa9f6dca81693b7742a3a6d4aab 100644 (file)
@@ -271,46 +271,47 @@ centered, X==1 is at the right, X == -1 is at the left."
 ;; * Pitch Trill Heads
 ;; * Parentheses
 
-(define (parenthesize-elements grob)
+(define (parenthesize-elements grob . rest)
   (let*
-      ((elts (ly:grob-object grob 'elements))
-       (x-ext (ly:relative-group-extent elts grob X))
+      (
+       (refp (if (null? rest)
+                grob
+                (car rest)))
+       (elts (ly:grob-object grob 'elements))
+       (x-ext (ly:relative-group-extent elts refp X))
 
        (font (ly:grob-default-font grob))
        (lp (ly:font-get-glyph font "accidentals.leftparen"))
        (rp (ly:font-get-glyph font "accidentals.rightparen"))
-       (padding (ly:grob-property grob 'padding 0.1))
+       (padding (ly:grob-property grob 'padding 0.1)))
 
     (ly:stencil-add
      (ly:stencil-translate-axis lp (- (car x-ext) padding) X)
      (ly:stencil-translate-axis rp (+ (cdr x-ext) padding) X))
-  )))
-
-
-(define (parenthesize-element me grob)
-  (let*
-      ((x-ext (ly:grob-extent grob grob X))
-       (y-center
-       (interval-center (ly:grob-extent grob grob Y)))
-       (font (ly:grob-default-font me))
-       (lp (ly:font-get-glyph font "accidentals.leftparen"))
-       (rp (ly:font-get-glyph font "accidentals.rightparen"))
-       (padding (ly:grob-property grob 'padding 0.1))
-       )
-
-    (ly:stencil-add
-     (ly:stencil-translate lp
-                          (cons
-                           (- (car x-ext) padding)
-                           y-center))
-     (ly:stencil-translate rp
-                          (cons
-                           (+ (cdr x-ext) padding)
-                           y-center)))
   ))
 
+
 (define (parentheses-item::print me)
-  (parenthesize-element me (ly:grob-parent me Y)))
+  (let*
+      ((elts (ly:grob-object me 'elements))
+       (y-ref (ly:grob-common-refpoint-of-array me elts Y))
+       (x-ref (ly:grob-common-refpoint-of-array me elts X))
+       (stencil (parenthesize-elements me x-ref))
+       (elt-y-ext  (ly:relative-group-extent elts y-ref Y))
+       (y-center (interval-center elt-y-ext)))
+
+    (ly:stencil-translate
+     stencil
+     (cons
+      (-
+       (ly:grob-relative-coordinate me x-ref X))
+      (-
+       y-center
+       (ly:grob-relative-coordinate me y-ref Y))))
+    ))
+
+       
+       
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;