lilypond-1.3.28
[lilypond.git] / lily / clef-item.cc
blob35f4d46bf377e947cfeb8cc7fc5302d629ebbc1d
1 /*
2 clef-item.cc -- implement Clef_item
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
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"
21 void
22 Clef_item::do_pre_processing()
24 SCM style_sym =get_elt_property ("style");
25 String style;
26 if (gh_string_p (style_sym))
27 style = ly_scm2string (style_sym);
29 SCM glyph = get_elt_property ("glyph");
30 if (gh_string_p (glyph))
32 String s = ly_scm2string (glyph);
34 if (break_status_dir() != RIGHT && style != "fullSizeChanges")
36 s += "_change";
38 s = "clefs-" + s;
39 set_elt_property ("glyph", ly_str02scm (s.ch_C()));
41 else
43 set_elt_property ("transparent", SCM_BOOL_T);
46 if (style == "transparent") // UGH. JUNKME
48 set_elt_property ("transparent", SCM_BOOL_T);
49 set_empty (X_AXIS);
54 void
55 Clef_item::do_add_processing ()
57 if (!break_status_dir ()) // broken stuff takes care of their own texts
59 Text_item *g =0;
61 SCM octave_dir = remove_elt_property ("octave-dir");
62 if (isdir_b (octave_dir))
64 g = new Text_item;
65 Side_position_interface spi (g);
66 spi.set_axis (Y_AXIS);
68 pscore_l_->typeset_element (g);
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);
76 g->set_elt_property ("self-alignment-X", gh_int2scm (0));
77 g->dim_cache_[X_AXIS]->off_callbacks_.push (Side_position_interface::aligned_on_self);
78 g->dim_cache_[X_AXIS]->off_callbacks_.push (Side_position_interface::centered_on_parent);
80 g->set_elt_property ("direction", octave_dir);
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);