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