]> git.donarmstrong.com Git - lilypond.git/blob - lily/clef-item.cc
af14a41828c35d82ab9509bc4b608b1ec8e6d5fa
[lilypond.git] / lily / clef-item.cc
1 /*
2   clef-item.cc -- implement Clef_item
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
10 #include "clef-item.hh"
11 #include "string.hh"
12 #include "molecule.hh"
13 #include "paper-def.hh"
14 #include "lookup.hh"
15 #include "text-item.hh"
16 #include "paper-score.hh"
17 #include "dimension-cache.hh"
18 #include "side-position-interface.hh"
19 #include "warn.hh"
20 #include "line-of-score.hh"
21
22 void
23 Clef_item::before_line_breaking ()
24 {
25   SCM style_sym =get_elt_property ("style");
26   String style;
27   if (gh_string_p (style_sym))
28     style = ly_scm2string (style_sym);
29
30   SCM glyph = get_elt_property ("glyph");
31   if (gh_string_p (glyph))
32     {
33       String s = ly_scm2string (glyph);
34         
35       if (break_status_dir() != RIGHT && style != "fullSizeChanges")
36         {
37           s += "_change";
38         }
39       s = "clefs-" +  s;
40       set_elt_property ("glyph", ly_str02scm (s.ch_C()));
41     }
42   else
43     {
44       set_elt_property ("transparent", SCM_BOOL_T);
45     }
46   
47   if (style == "transparent")   // UGH. JUNKME
48     {
49       set_elt_property ("transparent", SCM_BOOL_T);
50       set_extent_callback (0, X_AXIS);
51     }
52 }
53
54
55 void
56 Clef_item::do_add_processing ()
57 {
58   if (!break_status_dir ())     // broken stuff takes care of their own texts
59     {
60       Text_item *g =0;
61
62       SCM octave_dir = remove_elt_property ("octave-dir");
63       if (isdir_b (octave_dir))
64         {
65           g = new Text_item;
66           Side_position_interface spi (g);
67           spi.set_axis (Y_AXIS);
68           
69           pscore_l_->line_l_->typeset_element (g);
70       
71           spi.add_support (this);
72           g->set_elt_property ("text", ly_str02scm ( "8"));
73           g->set_elt_property ("style", gh_str02scm ("italic"));
74           g->set_parent (this, Y_AXIS);
75           g->set_parent (this, X_AXIS);
76           
77           g->set_elt_property ("self-alignment-X", gh_int2scm (0));
78           g->add_offset_callback (Side_position_interface::aligned_on_self, X_AXIS);
79           g->add_offset_callback (Side_position_interface::centered_on_parent, X_AXIS);
80
81           g->set_elt_property ("direction", octave_dir);
82           
83           add_dependency (g);   // just to be sure.
84           SCM my_vis = get_elt_property ("visibility-lambda");
85           if (gh_procedure_p (my_vis))
86             g->set_elt_property ("visibility-lambda", my_vis);
87                         
88         }
89
90     }
91 }
92
93