]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/system-start-delimiter.cc (print): allow style = text too.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 5 Feb 2006 18:19:16 +0000 (18:19 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 5 Feb 2006 18:19:16 +0000 (18:19 +0000)
* lily/system-start-delimiter-engraver.cc
(acknowledge_system_start_text): new function, also add add to
support of system-start-text (instrument names). This fixes
instrument names on piano staves.

* lily/instrument-name-engraver.cc: rewrite. Use
system-start-delimiter approach. This save memory and cpu.

* scm/define-grobs.scm (all-grob-descriptions): remove
instrument-name from break-alignment.

* mf/GNUmakefile ($(NCSB_TTFS)): depend on pfx2ttf script too.

ChangeLog
input/regression/instrument-name-hara-kiri.ly [new file with mode: 0644]
input/regression/instrument-name.ly
lily/include/system-start-delimiter.hh
lily/instrument-name-engraver.cc
lily/system-start-delimiter-engraver.cc
lily/system-start-delimiter.cc
ly/engraver-init.ly
mf/GNUmakefile
scm/define-grob-properties.scm
scm/define-grobs.scm

index a627649398229ba00f987dc1b9c2e92cf3024a8e..4fd6f43b93557c00dc05fa5fea1821a483a0684f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2006-02-05  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * lily/system-start-delimiter.cc (print): allow style = text too.
+
+       * lily/system-start-delimiter-engraver.cc
+       (acknowledge_system_start_text): new function, also add add to
+       support of system-start-text (instrument names). This fixes
+       instrument names on piano staves.
+
+       * lily/instrument-name-engraver.cc: rewrite. Use
+       system-start-delimiter approach. This save memory and cpu.
+
+       * scm/define-grobs.scm (all-grob-descriptions): remove
+       instrument-name from break-alignment.
+
+       * mf/GNUmakefile ($(NCSB_TTFS)): depend on pfx2ttf script too.
+
 2006-02-05  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * stepmake/stepmake/generic-vars.make (LOOP): Add PLUS to keep -j
@@ -14,6 +31,8 @@
 
 2006-02-05  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * VERSION (PACKAGE_NAME): 2.7.31
+
        * scm/framework-ps.scm (dump-stencil-as-EPS): don't hardcode left
        EPS edge at 0, but take minimum with left-overshoot. This fixes
        cut off system start delims. 
diff --git a/input/regression/instrument-name-hara-kiri.ly b/input/regression/instrument-name-hara-kiri.ly
new file mode 100644 (file)
index 0000000..1b77506
--- /dev/null
@@ -0,0 +1,21 @@
+
+\header {
+
+  texidoc = "@code{PianoStaff.instrument} and
+@code{PianoStaff.instr} are removed when the staves are killed off.
+
+In this example, the 2nd staff (marked by the barnumber 2) disappears
+as does the instrument name.  "
+
+}
+
+\version "2.7.31"
+        
+  \new PianoStaff <<
+    \new Staff {
+      \override Staff.VerticalAxisGroup #'remove-empty = ##t  
+      \set PianoStaff.instrument="up" 
+      \set PianoStaff.instr="u"
+      c'1\break R
+    }
+  >>
index 0851304124271826f750dfb1d67518cbca4a2b2f..3590326fde50197360665195b105f886dc23ae6f 100644 (file)
@@ -20,9 +20,13 @@ PianoStaff.
 
 \context PianoStaff <<
   \context Staff = "treble"    {
-    \set PianoStaff.instrument = "Piano "
-    \set Staff.instrument = "Right " { c''4 }}
-  \context Staff = "bass" { \set Staff.instrument = "Left " \clef bass c4 }>>
+    \set PianoStaff.instrument = "Piano"
+    \set Staff.instrument = "Right" { c''4 }}
+  \context Staff = "bass" {
+    \set Staff.instrument = "Left"
+    \clef bass c4
+  }
+>>
 
 
 
index 3bcb397201f7bca85488caf33e97d559543a18dd..863ff1c523a5a562284dd21e16f4dd8899c0d91e 100644 (file)
@@ -27,6 +27,8 @@ public:
   static Stencil staff_brace (Grob *, Real);
   static Stencil simple_bar (Grob *, Real);
   static Stencil line_bracket (Grob *, Real);
+  static Stencil text (Grob *, Real);
+  
 };
 
 #endif /* SYSTEM_START_DELIMITER_HH */
index 0620ae8cfb77016d9549ed481539aca08881bcaf..e6850fba0b6b9bdfcabcc87f0ff219ef8550798a 100644 (file)
 */
 
 #include "engraver.hh"
-#include "bar-line.hh"
-#include "system-start-delimiter.hh"
+#include "spanner.hh"
+#include "pointer-group-interface.hh"
 #include "side-position-interface.hh"
-#include "align-interface.hh"
 #include "axis-group-interface.hh"
-#include "context.hh"
-#include "text-interface.hh"
-#include "grob-array.hh"
+#include "align-interface.hh"
 
 #include "translator.icc"
 
-class Instrument_name_engraver : public Engraver
+class New_instrument_name_engraver : public Engraver
 {
-  bool first_;
 public:
-  TRANSLATOR_DECLARATIONS (Instrument_name_engraver);
+  TRANSLATOR_DECLARATIONS (New_instrument_name_engraver);
 
 protected:
-  Grob *text_;
+  Spanner *text_spanner_;
 
-  virtual void create_text ();
-  virtual void initialize ();
-
-  DECLARE_ACKNOWLEDGER (bar_line);
+  virtual void finalize ();
   DECLARE_ACKNOWLEDGER (axis_group);
-
-  void stop_translation_timestep ();
   void process_music ();
 };
 
-Instrument_name_engraver::Instrument_name_engraver ()
+New_instrument_name_engraver::New_instrument_name_engraver ()
 {
-  text_ = 0;
-  first_ = true;
+  text_spanner_ = 0;
 }
 
 void
-Instrument_name_engraver::initialize ()
+New_instrument_name_engraver::process_music ()
 {
-  context ()->set_property ("instrumentSupport", SCM_EOL);
-}
-
-void
-Instrument_name_engraver::stop_translation_timestep ()
-{
-  if (text_)
+  if (!text_spanner_)
     {
-      SCM support = get_property ("instrumentSupport");
-      text_->set_object ("side-support-elements",
-                        grob_list_to_grob_array (support));
-
-      /*
-       Hack to get texts on piano staves to disappear.
-       */
-      if (!text_->get_parent (Y_AXIS)
-         && scm_is_pair (support))
+      SCM long_text = get_property ("instrument");
+      SCM short_text = get_property ("instr");
+
+      if (! (scm_is_string (long_text)
+            || scm_is_string (short_text)))
+       {
+         long_text = get_property ("vocalName");
+         short_text = get_property ("vocNam");
+       }
+  
+      if (scm_is_string (long_text)
+         || scm_is_string (short_text))
        {
-         Axis_group_interface::add_element (unsmob_grob (scm_car (support)),
-                                            text_);
+         text_spanner_ = make_spanner ("InstrumentName", SCM_EOL);
+         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);
        }
-      text_ = 0;
     }
-
-  first_ = false;
 }
 
 void
-Instrument_name_engraver::create_text ()
+New_instrument_name_engraver::acknowledge_axis_group (Grob_info info)
 {
-  if (text_)
-    return;
-
-  SCM txt = get_property ("instrument");
-
-  if (now_mom () > Moment (0))
-    txt = get_property ("instr");
-  /*
-    UGH.
-  */
-  if (txt == SCM_EOL)
-    return;
-
-  text_ = make_item ("InstrumentName", SCM_EOL);
-
-  if (text_->get_property ("text") != txt)
-    text_->set_property ("text", txt);
-}
-
-void
-Instrument_name_engraver::acknowledge_bar_line (Grob_info info)
-{
-  (void) info;
-  create_text ();
-}
-
-void
-Instrument_name_engraver::acknowledge_axis_group (Grob_info info)
-{
-  /*
-    Ugh - typechecking for pedal and dynamic sucks.
-  */
-  if (dynamic_cast<Spanner *> (info.grob ())
-      && (info.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface"))
-         || info.grob ()->internal_has_interface (ly_symbol2scm ("piano-pedal-interface"))))
-    return;
-
-  /*
-    Hang the instrument names on the staves, but not on the alignment
-    groups enclosing that staff. The alignment has no real location,
-    but is only a vehicle for the placement routine it contains, and
-    therefore the location of its refpoint won't be very useful.
-
-    We could also just use stavesFound, but lets keep this working
-    without staffs as well.
-  */
-  if (dynamic_cast<Spanner *> (info.grob ())
-      && ((Axis_group_interface::has_interface (info.grob ())
-          && Axis_group_interface::has_axis (info.grob (), Y_AXIS))))
+  if (text_spanner_ 
+      && dynamic_cast<Spanner *> (info.grob ())
+      && Axis_group_interface::has_axis (info.grob (), Y_AXIS)
+      && (!Align_interface::has_interface (info.grob ())))
     {
-      if (!Align_interface::has_interface (info.grob ()))
-       {
-         SCM nl = scm_cons (info.grob ()->self_scm (),
-                            get_property ("instrumentSupport"));
-
-         context ()->set_property ("instrumentSupport", nl);
-       }
+      Grob *staff = info.grob();
+      Pointer_group_interface::add_grob (text_spanner_, ly_symbol2scm ("elements"), staff);
+      Side_position_interface::add_support (text_spanner_, staff);
     }
 }
 
 void
-Instrument_name_engraver::process_music ()
+New_instrument_name_engraver::finalize ()
 {
-  /*
-    Also create text if barlines in other groups. This allows
-    a name to be attached to lyrics or chords.
-  */
-  if (scm_is_string (get_property ("whichBar"))
-      || first_)
-    create_text ();
+  if (text_spanner_)
+    {
+      text_spanner_->set_bound (RIGHT,
+                               unsmob_grob (get_property ("currentCommandColumn")));
+    }
 }
 
 #include "translator.icc"
 
-ADD_ACKNOWLEDGER (Instrument_name_engraver, bar_line);
-ADD_ACKNOWLEDGER (Instrument_name_engraver, axis_group);
-
-ADD_TRANSLATOR (Instrument_name_engraver,
-               /* doc */ " Prints the name of the instrument (specified by "
-               " @code{Staff.instrument} and @code{Staff.instr}) "
-               "at the left of the staff. ",
-               /* create */ "InstrumentName",
-               /* accept */ "",
-               /* read */ "instrument instr",
-               /* write */ "");
-
-/****************************************************************/
-
-class Vocal_name_engraver : public Instrument_name_engraver
-{
-public:
-  TRANSLATOR_DECLARATIONS (Vocal_name_engraver);
-  virtual void create_text ();
-};
-
-Vocal_name_engraver::Vocal_name_engraver ()
-{
-}
-
-void
-Vocal_name_engraver::create_text ()
-{
-  if (text_)
-    return;
-
-  SCM txt = get_property ("vocalName");
-
-  if (now_mom () > Moment (0))
-    txt = get_property ("vocNam");
-
-  /*
-    UGH.
-  */
-  if (txt == SCM_EOL)
-    return;
+ADD_ACKNOWLEDGER (New_instrument_name_engraver, axis_group);
 
-  text_ = make_item ("VocalName", SCM_EOL);
+ADD_TRANSLATOR (New_instrument_name_engraver,
 
-  if (text_->get_property ("text") != txt)
-    text_->set_property ("text", txt);
-}
-
-ADD_ACKNOWLEDGER (Vocal_name_engraver, bar_line);
-ADD_ACKNOWLEDGER (Vocal_name_engraver, axis_group);
-ADD_TRANSLATOR (Vocal_name_engraver,
-               /* doc */ " Prints the name of the a lyric voice (specified by "
-               " @code{Staff.vocalName} and @code{Staff.vocNam}) "
-               "at the left of the staff. ",
-               /* create */ "VocalName",
+               /* doc */
+               "Creates a system start text for instrument or vocal names.",
+               
+               /* create */
+               "InstrumentName ",
+               
                /* accept */ "",
-               /* read */ "vocNam vocalName",
+               
+               /* read */
+               "vocNam vocalName instrument instr "
+               "currentCommandColumn",
+
                /* write */ "");
index 9808148fd9615107e0b484c44e2ff3a009b989c4..bbab59328d6f49b6a33ee477e4223b8bc4046ce1 100644 (file)
@@ -178,6 +178,7 @@ protected:
   Bracket_nesting_group *nesting_;
   
   DECLARE_ACKNOWLEDGER (system_start_delimiter);
+  DECLARE_ACKNOWLEDGER (system_start_text);
   DECLARE_ACKNOWLEDGER (staff_symbol);
 
   void process_music ();
@@ -189,8 +190,6 @@ System_start_delimiter_engraver::System_start_delimiter_engraver ()
   nesting_ = 0;
 }
 
-
-
 void
 System_start_delimiter_engraver::process_music ()
 {
@@ -231,6 +230,13 @@ System_start_delimiter_engraver::acknowledge_staff_symbol (Grob_info inf)
 }
 
 
+
+void
+System_start_delimiter_engraver::acknowledge_system_start_text (Grob_info inf)
+{
+  nesting_->add_support (inf.grob ());
+}
+
 void
 System_start_delimiter_engraver::acknowledge_system_start_delimiter (Grob_info inf)
 {
@@ -241,10 +247,18 @@ System_start_delimiter_engraver::acknowledge_system_start_delimiter (Grob_info i
 
 ADD_ACKNOWLEDGER (System_start_delimiter_engraver, staff_symbol);
 ADD_ACKNOWLEDGER (System_start_delimiter_engraver, system_start_delimiter);
+ADD_ACKNOWLEDGER (System_start_delimiter_engraver, system_start_text);
 
 ADD_TRANSLATOR (System_start_delimiter_engraver,
                /* doc */ "Creates a system start delimiter (ie. SystemStart@{Bar, Brace, Bracket@} spanner",
-               /* create */ "SystemStartSquare SystemStartBrace SystemStartBracket SystemStartBar",
+               /* create */ "SystemStartSquare "
+               "SystemStartBrace "
+               "SystemStartBracket "
+               "SystemStartBar",
                /* accept */ "",
-               /* read */ "systemStartDelimiter systemStartDelimiterHierarchy currentCommandColumn",
+               /* read */
+               "systemStartDelimiter "
+               "systemStartDelimiterHierarchy "
+               "currentCommandColumn",
+
                /* write */ "");
index e7b1269e923608c197a7b6edccdf1119c6ce3f0d..73b350976e35edb25a8edb019eda9633ca16f4bf 100644 (file)
@@ -7,7 +7,7 @@
 */
 
 #include "system-start-delimiter.hh"
-
+#include "text-interface.hh" 
 #include "all-font-metrics.hh"
 #include "axis-group-interface.hh"
 #include "font-interface.hh"
@@ -75,6 +75,23 @@ System_start_delimiter::line_bracket (Grob *me, Real height)
   return vline;
 }
 
+Stencil
+System_start_delimiter::text (Grob *me_grob, Real 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::interpret_markup (me->layout ()->self_scm (), chain, t);
+  if (Stencil *p = unsmob_stencil (scm_stencil))
+    return *p;
+  return Stencil();
+}
+
 Stencil
 System_start_delimiter::simple_bar (Grob *me, Real h)
 {
@@ -130,6 +147,8 @@ 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 ();
@@ -181,5 +200,7 @@ ADD_INTERFACE (System_start_delimiter, "system-start-delimiter-interface",
               /* properties */
               "collapse-height "
               "style "
+              "text "
+              "long-text " 
               "thickness "
               );
index 1f8aca50b509fa78e19c1310fdac16a333ba14aa..f60ff00515f8f117da5a87a8ee1d07ca98d9bf32 100644 (file)
@@ -35,7 +35,7 @@
   \consists "Rest_collision_engraver"
   \consists "Accidental_engraver"
   \consists "Piano_pedal_engraver"
-  \consists "Instrument_name_engraver"
+  \consists "New_instrument_name_engraver"
   \consists "String_number_engraver"
   \consists "Axis_group_engraver"
 
@@ -144,7 +144,7 @@ contained staves are not connected vertically."
   \consists "Staff_symbol_engraver"
   \consists "Pitch_squash_engraver"
   \consists "Time_signature_engraver"
-  \consists "Instrument_name_engraver"
+  \consists "New_instrument_name_engraver"
   \consists "Axis_group_engraver"
   
   \accepts "Voice"
@@ -284,7 +284,7 @@ contained staves are not connected vertically."
   \override VerticalAlignment #'self-alignment-Y = #0
 
   \consists "Vertical_align_engraver"
-  \consists "Instrument_name_engraver"
+  \consists "New_instrument_name_engraver"
   
   instrument = #'()
   instr = #'()
@@ -343,14 +343,14 @@ printing of a single line of lyrics.  "
   \consists "Extender_engraver"
   \consists "Hyphen_engraver"
   \consists "Stanza_number_engraver"
-  \consists "Vocal_name_engraver"
+  \consists "New_instrument_name_engraver"
   \consists "Skip_event_swallow_translator"
   \consists "Font_size_engraver"
   \consists "Hara_kiri_engraver"
   \override VerticalAxisGroup #'remove-first = ##t
   \override VerticalAxisGroup #'remove-empty = ##t
   \override SeparationItem #'padding = #0.2
-
+  \override InstrumentName #'Y-offset = #0.0 
 
   %% make sure that barlines aren't collapsed, when
   %% Bar_engraver is there.
index 8ff1afa9baecd0e3647727b1b241a2c8dbb6ff42..8bc4bdbb56cdb5aa55526aa43e6c1ae2417792f0 100644 (file)
@@ -247,7 +247,7 @@ $(outdir)/%.enc.in: %.enc
        cp $< $@
 
 
-$(NCSB_TTFS): $(addsuffix .pfb,$(addprefix $(NCSB_DIR)/,$(NCSB_SOURCE_FILES)))
+$(NCSB_TTFS): $(addsuffix .pfb,$(addprefix $(NCSB_DIR)/,$(NCSB_SOURCE_FILES))) $(buildscript-dir)/pfx2ttf.fontforge
        $(foreach i,$(NCSB_SOURCE_FILES), \
                $(FONTFORGE) -script $(buildscript-dir)/pfx2ttf.fontforge \
                        $(NCSB_DIR)/$(i).pfb $(NCSB_DIR)/$(i).afm $(outdir)/ && ) true
index 5d530ab5d2e7691f05f10f8adb7ba8934f9babe8..1c0396967d3e144dd592ac86bb257674633ad9b6 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.")
+     (long-text ,markup? "Text markup.  See @usermanref{Text markup}.")
      (measure-length ,ly:moment? "Length of a
 measure. Used in some spacing situations.")
 
index 4d491af89e9e949808c8ad1a142db987643bc8ef..4ba3869e69c13c0161762c99af842c1999cecbc7 100644 (file)
        (positioning-done . ,ly:break-align-interface::calc-positioning-done)
        (X-extent . ,ly:axis-group-interface::width)
        (break-align-orders . ;; end of line
-                           #((instrument-name
+                           #((
                               left-edge
                               ambitus
                               breathing-sign
                               custos)
 
                              ;; unbroken
-                             (instrument-name
+                             (
                               left-edge
                               ambitus
                               breathing-sign
                               time-signature custos)
 
                              ;; begin of line
-                             (instrument-name
+                             (
                               left-edge
                               ambitus
                               breathing-sign
                                spanner-interface))))))
     (InstrumentName
      . (
-       (breakable . #t)
-       (Y-offset . ,(ly:make-simple-closure
-                     `(,+ ,(ly:make-simple-closure
-                            (list ly:self-alignment-interface::y-aligned-on-self))
-                          ,(ly:make-simple-closure
-                            (list ly:side-position-interface::y-aligned-on-support-refpoints)))))
-       
-       ;; This direction is for aligned_on_support_refpoints
-       ;; (?) --hwn
-       (direction . ,CENTER)
-       (space-alist . (
-                       (left-edge . (extra-space . 1.0))))
-
-       (self-alignment-Y . 0)
-       (stencil . ,ly:text-interface::print)
-       (break-align-symbol . instrument-name)
-       (break-visibility . ,begin-of-line-visible)
-       (baseline-skip . 2)
-       (side-axis . ,X)
-       (meta . ((class . Item)
-                (interfaces . (font-interface
-                               self-alignment-interface
+       (style . text)
+       (padding . 0.3)
+       (stencil . ,ly:system-start-delimiter::print)
+       (collapse-height . 5.0)
+       (X-offset . ,ly:side-position-interface::x-aligned-side)
+       (direction . ,LEFT)
+       (Y-offset . -0.75)
+       (Y-extent . #f)
+       (meta . ((class . Spanner)
+                (interfaces . (system-start-text-interface
                                side-position-interface
-                               text-interface
-                               break-aligned-interface))))))
+                               font-interface))))))
 
     (KeyCancellation
      . (
                                side-position-interface
                                font-interface))))))
 
+
     (SystemStartSquare
      . (
        (Y-extent . #f)
                                hara-kiri-group-interface
                                vertically-spaceable-interface))))))
 
-    (VocalName
-     . (
-       (breakable . #t)
-       (Y-offset . ,ly:side-position-interface::y-aligned-on-support-refpoints)
-       (direction . ,CENTER)
-       (space-alist . ((left-edge . (extra-space . 1.0))))
-       (break-align-symbol . instrument-name)
-       (stencil . ,ly:text-interface::print)
-       (break-align-symbol . clef)
-       (break-visibility . ,begin-of-line-visible)
-       (baseline-skip . 2)
-       (side-axis . ,Y)
-       (meta . ((class . Item)
-                (interfaces . (font-interface
-                               self-alignment-interface
-                               side-position-interface
-                               text-interface
-                               break-aligned-interface))))))
 
     (VoltaBracket
      . (