]> git.donarmstrong.com Git - lilypond.git/commitdiff
(get_stencil): new file: separate out
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 13 Feb 2006 10:23:12 +0000 (10:23 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 13 Feb 2006 10:23:12 +0000 (10:23 +0000)
system-start-delimiter text support.

ChangeLog
lily/include/system-start-delimiter.hh
lily/system-start-delimiter.cc
lily/system-start-text.cc [new file with mode: 0644]
scm/define-grobs.scm

index ad31886c67e834741004299090aae52f80aecaf8..ea7dc7216341ca0d0386f5fc4cd54a67c3b6aa24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2006-02-13  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/system-start-text.cc (get_stencil): new file: separate out
+       system-start-delimiter text support.
+
        * input/**ly: replace \context with \new where appropriate.
        
        * THANKS: add Don.
index 863ff1c523a5a562284dd21e16f4dd8899c0d91e..115c8cd37a74a02ac148a7dbc9c04e30d03c011a 100644 (file)
@@ -27,7 +27,6 @@ public:
   static Stencil staff_brace (Grob *, Real);
   static Stencil simple_bar (Grob *, Real);
   static Stencil line_bracket (Grob *, Real);
-  static Stencil text (Grob *, Real);
   
 };
 
index c33180540dbf3e849eb8a21c2bd9ff282a4f3bf0..7099ca7e7a30039bd40abd0f408f12316129e4cb 100644 (file)
@@ -75,34 +75,6 @@ System_start_delimiter::line_bracket (Grob *me, Real height)
   return vline;
 }
 
-Stencil
-System_start_delimiter::text (Grob *me_grob, Real h)
-{
-  (void) h;
-  
-  Spanner *me = dynamic_cast<Spanner*> (me_grob);
-  SCM t = me->get_property ("text");
-  if (me->get_break_index () == 0)
-    t = me->get_property ("long-text");
-          
-  
-  SCM chain = Font_interface::text_font_alist_chain (me);
-
-  SCM scm_stencil = Text_interface::is_markup (t)
-    ? Text_interface::interpret_markup (me->layout ()->self_scm (), chain, t)
-    : SCM_EOL;
-
-  
-  if (Stencil *p = unsmob_stencil (scm_stencil))
-    {
-      SCM align_y  = me_grob->get_property ("self-alignment-Y");
-      if (scm_is_number (align_y))
-       p->align_to (Y_AXIS, robust_scm2double (align_y, 0.0));
-      return *p;
-    }
-  return Stencil();
-}
-
 Stencil
 System_start_delimiter::simple_bar (Grob *me, Real h)
 {
@@ -158,8 +130,6 @@ System_start_delimiter::print (SCM smob)
     m = simple_bar (me, len);
   else if (glyph_sym == ly_symbol2scm ("line-bracket"))
     m = line_bracket (me, len);
-  else if (glyph_sym == ly_symbol2scm ("text"))
-    m = text (me, len);
 
   m.translate_axis (ext.center (), Y_AXIS);
   return m.smobbed_copy ();
@@ -172,7 +142,7 @@ System_start_delimiter::staff_brace (Grob *me, Real y)
   /* We go through the style sheet to lookup the font file
      name.  This is better than using find_font directly,
      esp. because that triggers mktextfm for non-existent
->     fonts. */
+     fonts. */
   SCM fam = scm_cons (ly_symbol2scm ("font-encoding"),
                      ly_symbol2scm ("fetaBraces"));
 
@@ -204,15 +174,13 @@ System_start_delimiter::staff_brace (Grob *me, Real y)
   return stil;
 }
 
-ADD_INTERFACE (System_start_delimiter, "system-start-delimiter-interface",
+ADD_INTERFACE (System_start_delimiter,
+              "system-start-delimiter-interface",
               "The brace, bracket or bar in front of the system. "
               ,
 
               /* properties */
               "collapse-height "
               "style "
-              "text "
-              "long-text "
-              "self-alignment-Y "
               "thickness "
               );
diff --git a/lily/system-start-text.cc b/lily/system-start-text.cc
new file mode 100644 (file)
index 0000000..1e73994
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+  system-start-text.cc -- implement System_start_text
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "text-interface.hh"
+#include "pointer-group-interface.hh"
+#include "output-def.hh"
+#include "font-interface.hh"
+#include "spanner.hh"
+#include "stencil.hh"
+
+class System_start_text
+{
+public:
+  static Stencil get_stencil (Grob *);
+  static bool has_interface (Grob *);
+
+  DECLARE_SCHEME_CALLBACK (print, (SCM));
+};
+
+Stencil
+System_start_text::get_stencil (Grob *me_grob)
+{
+  Spanner *me = dynamic_cast<Spanner*> (me_grob);
+  SCM t = me->get_property ("text");
+  if (me->get_break_index () == 0)
+    t = me->get_property ("long-text");
+          
+  
+  SCM chain = Font_interface::text_font_alist_chain (me);
+
+  SCM scm_stencil = Text_interface::is_markup (t)
+    ? Text_interface::interpret_markup (me->layout ()->self_scm (), chain, t)
+    : SCM_EOL;
+
+  
+  if (Stencil *p = unsmob_stencil (scm_stencil))
+    {
+      SCM align_y  = me_grob->get_property ("self-alignment-Y");
+      if (scm_is_number (align_y))
+       p->align_to (Y_AXIS, robust_scm2double (align_y, 0.0));
+      return *p;
+    }
+  return Stencil();
+}
+
+
+MAKE_SCHEME_CALLBACK (System_start_text, print, 1);
+SCM
+System_start_text::print (SCM smob)
+{
+  Spanner *me = unsmob_spanner (smob);
+
+  extract_grob_set (me, "elements", elts);
+  Grob *common = common_refpoint_of_array (elts, me, Y_AXIS);
+
+  Interval ext;
+  for (vsize i = elts.size (); i--;)
+    {
+      Spanner *sp = dynamic_cast<Spanner *> (elts[i]);
+
+      if (sp
+         && sp->get_bound (LEFT) == me->get_bound (LEFT))
+       ext.add_point (sp->relative_coordinate (common, Y_AXIS));
+    }
+
+  Stencil m = get_stencil (me);
+  m.translate_axis (ext.center (), Y_AXIS);
+  return m.smobbed_copy ();
+}
+
+
+ADD_INTERFACE (System_start_text,
+              "system-start-text-interface",
+              "Text in front of the system.",
+
+              /* properties */
+              "text "
+              "long-text "
+              "self-alignment-Y "
+              );
index 3ac61bc13d8308316da8a0799a6911b1a36ec8e1..abffe9bc65fa78fbedcc97bfb9a207af086850dd 100644 (file)
                                spanner-interface))))))
     (InstrumentName
      . (
-       (style . text)
        (padding . 0.3)
-       (stencil . ,ly:system-start-delimiter::print)
+       (stencil . ,ly:system-start-text::print)
        (X-offset . ,ly:side-position-interface::x-aligned-side)
        (direction . ,LEFT)
        (self-alignment-Y . ,CENTER)
        (meta . ((class . Spanner)
                 (interfaces . (system-start-text-interface
-                               system-start-delimiter-interface
                                side-position-interface
                                font-interface))))))