From 6ec65b15b95eb3bd700579a9f85ce209ecd0812d Mon Sep 17 00:00:00 2001
From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Fri, 10 Feb 2006 12:03:58 +0000
Subject: [PATCH] * 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.
---
 ChangeLog                        | 27 ++++++++++++++
 Documentation/topdocs/NEWS.tely  |  8 +++--
 input/regression/parenthesize.ly |  8 ++---
 lily/grob-scheme.cc              | 61 ++++++++++++++++++++++++++++++++
 lily/instrument-name-engraver.cc | 12 ++++---
 lily/parenthesis-engraver.cc     |  7 ++--
 lily/slur.cc                     | 13 ++++---
 lily/tie.cc                      | 15 ++++----
 scm/define-grob-properties.scm   |  1 +
 scm/define-grobs.scm             |  6 ++--
 scm/output-lib.scm               | 57 ++++++++++++++---------------
 11 files changed, 158 insertions(+), 57 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 44cab2c9c7..baaf24c08f 100644
--- 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
diff --git a/Documentation/topdocs/NEWS.tely b/Documentation/topdocs/NEWS.tely
index 07f3715861..db850bdf91 100644
--- a/Documentation/topdocs/NEWS.tely
+++ b/Documentation/topdocs/NEWS.tely
@@ -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
 
diff --git a/input/regression/parenthesize.ly b/input/regression/parenthesize.ly
index e8b5050cc6..e554b3647f 100644
--- a/input/regression/parenthesize.ly
+++ b/input/regression/parenthesize.ly
@@ -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> 
 
 }
diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc
index 4e44d8937d..d510a11bcb 100644
--- a/lily/grob-scheme.cc
+++ b/lily/grob-scheme.cc
@@ -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;
+}
diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc
index e8fcfbef03..5320dfd5f7 100644
--- a/lily/instrument-name-engraver.cc
+++ b/lily/instrument-name-engraver.cc
@@ -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);
 	}
diff --git a/lily/parenthesis-engraver.cc b/lily/parenthesis-engraver.cc
index 13aba090bd..1f6a196e32 100644
--- a/lily/parenthesis-engraver.cc
+++ b/lily/parenthesis-engraver.cc
@@ -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));
diff --git a/lily/slur.cc b/lily/slur.cc
index 7c015019ff..8c1e7e090e 100644
--- a/lily/slur.cc
+++ b/lily/slur.cc
@@ -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");
diff --git a/lily/tie.cc b/lily/tie.cc
index 9cf7468d6c..4b0404d690 100644
--- a/lily/tie.cc
+++ b/lily/tie.cc
@@ -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 "
 	       );
 
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index 4233361c26..49e8a20d6e 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -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.")
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 660eacd0a5..f7b9c530c6 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -1348,7 +1348,8 @@
 	(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)
@@ -1721,7 +1722,8 @@
 		    (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))))
 	))
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index ade314be23..1a7747e9e6 100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -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))))
+    ))
+
+       
+       
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; 
-- 
2.39.5