]> git.donarmstrong.com Git - lilypond.git/blob - lily/rest.cc
release: 1.3.62
[lilypond.git] / lily / rest.cc
1 /*
2  rest.cc -- implement Rest
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "molecule.hh"
10 #include "paper-def.hh"
11 #include "lookup.hh"
12 #include "rest.hh"
13 #include "dots.hh"
14 #include "paper-score.hh"
15 #include "staff-symbol-referencer.hh"
16
17 // -> offset callback
18 GLUE_SCORE_ELEMENT(Rest,after_line_breaking);
19 SCM
20 Rest::member_after_line_breaking ()
21 {
22   if (balltype_i () == 0)
23     {
24       Staff_symbol_referencer_interface si (this);
25       si.set_position (si.position_f () + 2);
26     }
27   
28   Dots * d = dots_l ();
29   if (d && balltype_i () > 4) // UGH.
30     {
31       /*
32         UGH. 
33        */
34       staff_symbol_referencer (d)
35         .set_position ((balltype_i () == 7) ? 4 : 3);
36     }
37
38   return SCM_UNDEFINED;
39 }
40
41
42 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Rest,brew_molecule)
43
44 SCM 
45 Rest::brew_molecule (SCM smob) 
46 {
47   Score_element* sc = unsmob_element (smob);
48   
49   bool ledger_b =false;
50
51   SCM balltype = sc->get_elt_property ("duration-log");
52   
53   if (balltype == gh_int2scm (0) || balltype == gh_int2scm (1))
54     {
55       Staff_symbol_referencer_interface si(sc);
56       ledger_b = abs(si.position_f ()  - (2* gh_scm2int (balltype) - 1))
57         > si.line_count (); 
58     }
59   
60   String style; 
61   SCM style_sym =sc->get_elt_property ("style");
62   if (gh_scm2int (balltype) >= 2 && gh_string_p (style_sym))
63     {
64       style = ly_scm2string (style_sym);
65     }
66
67   String idx =  ("rests-") + to_str (gh_scm2int (balltype))
68     + (ledger_b ? "o" : "") + style;
69
70   return sc-> lookup_l ()->afm_find (idx).create_scheme();
71 }
72
73
74
75 Rest::Rest (SCM s)
76   : Rhythmic_head (s)
77 {
78 }
79