]> git.donarmstrong.com Git - lilypond.git/blob - lily/chord-name.cc
release: 1.3.105
[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--2000 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 "score-element.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 = dynamic_cast<Item*> (unsmob_element (smob));
24   assert (me);
25     
26   SCM s = me->get_elt_property ("begin-of-line-visible");
27   if (to_boolean (s))
28     {
29       if (Paper_column::rank_i (me->column_l ()) -
30           /*
31             hmm, what's my column number in this line?
32             why doesn't this work?
33             me->line_l ()->rank_i_ > 2)
34           */
35           me->line_l ()->spanned_rank_iv ()[LEFT] > 1)
36         me->suicide ();
37     }
38   return SCM_UNSPECIFIED;
39 }
40
41 MAKE_SCHEME_CALLBACK (Chord_name,brew_molecule,1);
42 SCM
43 Chord_name::brew_molecule (SCM smob) 
44 {
45   Score_element *me = unsmob_element (smob);
46   SCM style = me->get_elt_property ("style");
47
48   if (!gh_string_p (style))
49     style = ly_str02scm ("banter");
50
51   SCM inversion = me-> get_elt_property ("inversion");
52   if (inversion == SCM_EOL)
53     inversion = SCM_BOOL_F;
54
55   SCM bass =  me->get_elt_property ("bass");
56   if (bass == SCM_EOL)
57     bass = SCM_BOOL_F;
58
59   SCM pitches =  me->get_elt_property ("pitches");
60   SCM func = me->get_elt_property (ly_symbol2scm ("chord-name-function"));
61   SCM text = gh_call3 (func, style, pitches, gh_cons (inversion, bass));
62
63   SCM properties = Font_interface::font_alist_chain (me);
64   Molecule mol = Text_item::text2molecule (me, text, properties);
65
66   SCM space =  me->get_elt_property ("word-space");
67   if (gh_number_p (space))
68     {
69       Molecule m;
70       m.set_empty (false);
71       mol.add_at_edge (X_AXIS, RIGHT, m, gh_scm2double (space)*
72                        Staff_symbol_referencer::staff_space (me));
73     }
74
75   return mol.smobbed_copy ();
76 }