]> git.donarmstrong.com Git - lilypond.git/blob - lily/chord-name.cc
release: 1.5.29
[lilypond.git] / lily / chord-name.cc
1 /*
2   chord-name.cc -- implement Chord_name
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1999--2002 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "chord-name.hh"
10 #include "molecule.hh"
11 #include "paper-def.hh"
12 #include "font-interface.hh"
13 #include "grob.hh"
14 #include "paper-column.hh"
15 #include "line-of-score.hh"
16 #include "staff-symbol-referencer.hh"
17 #include "text-item.hh"
18
19 MAKE_SCHEME_CALLBACK (Chord_name,after_line_breaking,1);
20 SCM
21 Chord_name::after_line_breaking (SCM smob)
22 {
23   Item* me = unsmob_item (smob);
24   assert (me);
25     
26   SCM s = me->get_grob_property ("begin-of-line-visible");
27   if (to_boolean (s))
28     {
29       if (Paper_column::rank_i (me->column_l ()) -
30           me->line_l ()->spanned_rank_iv ()[LEFT] > 1)
31         me->suicide ();
32     }
33   return SCM_UNSPECIFIED;
34 }
35
36 MAKE_SCHEME_CALLBACK (Chord_name,brew_molecule,1);
37 SCM
38 Chord_name::brew_molecule (SCM smob) 
39 {
40   Grob *me = unsmob_grob (smob);
41   SCM style = me->get_grob_property ("style");
42
43   if (!gh_symbol_p (style))
44     style = ly_symbol2scm ("banter");
45
46   SCM chord = me->get_grob_property ("chord");
47   SCM func = me->get_grob_property ("chord-name-function");
48   SCM text = gh_call2 (func, style, chord);
49
50   SCM properties = Font_interface::font_alist_chain (me);
51   Molecule mol = Text_item::text2molecule (me, text, properties);
52
53   SCM space =  me->get_grob_property ("word-space");
54   if (gh_number_p (space))
55     {
56       Molecule m;
57       m.set_empty (false);
58       mol.add_at_edge (X_AXIS, RIGHT, m, gh_scm2double (space)*
59                        Staff_symbol_referencer::staff_space (me));
60     }
61
62   return mol.smobbed_copy ();
63 }