+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
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.
--- /dev/null
+
+\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
+ }
+ >>
\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
+ }
+>>
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 */
*/
#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 */ "");
Bracket_nesting_group *nesting_;
DECLARE_ACKNOWLEDGER (system_start_delimiter);
+ DECLARE_ACKNOWLEDGER (system_start_text);
DECLARE_ACKNOWLEDGER (staff_symbol);
void process_music ();
nesting_ = 0;
}
-
-
void
System_start_delimiter_engraver::process_music ()
{
}
+
+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)
{
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 */ "");
*/
#include "system-start-delimiter.hh"
-
+#include "text-interface.hh"
#include "all-font-metrics.hh"
#include "axis-group-interface.hh"
#include "font-interface.hh"
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)
{
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 ();
/* properties */
"collapse-height "
"style "
+ "text "
+ "long-text "
"thickness "
);
\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"
\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"
\override VerticalAlignment #'self-alignment-Y = #0
\consists "Vertical_align_engraver"
- \consists "Instrument_name_engraver"
+ \consists "New_instrument_name_engraver"
instrument = #'()
instr = #'()
\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.
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
(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.")
(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
. (