]> git.donarmstrong.com Git - lilypond.git/blob - lily/clef-item.cc
release: 1.1.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--1999 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 "g-text-item.hh"
16 #include "p-score.hh"
17
18 void
19 Clef_item::do_pre_processing()
20 {
21   dim_cache_[Y_AXIS].translate (paper()->internote_f () * y_position_i_);
22   change_b_ = (break_status_dir() != RIGHT);
23 }
24
25 /*
26   FIXME
27 */
28 Clef_item::Clef_item()
29 {
30   breakable_b_ =true;
31   default_b_ = false;
32   change_b_ = true;
33   octave_dir_ = CENTER;
34   symbol_ = "treble";
35   y_position_i_ = -2;
36 }
37
38 void
39 Clef_item::do_add_processing ()
40 {
41   if (!break_status_dir_)       // broken stuff takes care of their own texts
42     {
43       SCM defvis = gh_eval_str ("(lambda (d) (if (= d 1) '(#f . #f) '(#t . #t)))");
44       G_text_item *g =0;
45       if (octave_dir_)
46         {
47           g = new G_text_item;
48           pscore_l_->typeset_element (g);
49       
50           g->text_str_ = "8";
51           g->style_str_ = "italic";
52           g->dim_cache_[Y_AXIS].parent_l_ = &dim_cache_[Y_AXIS];
53           g->dim_cache_[X_AXIS].parent_l_ = &dim_cache_[X_AXIS];
54           add_dependency (g);   // just to be sure.
55
56           Real r = do_height ()[octave_dir_] + g->extent (Y_AXIS)[-octave_dir_];
57           g->dim_cache_[Y_AXIS].set_offset (r);
58         }
59       
60       if (default_b_)
61         {
62           set_elt_property (ly_symbol ("visibility_lambda"),
63                             defvis);
64
65           if (g)
66             g->set_elt_property (ly_symbol ("visibility_lambda"),
67                                  defvis);
68         }
69     }
70 }
71
72 Molecule*
73 Clef_item::do_brew_molecule_p() const
74 {
75   String t = symbol_;
76   if  (change_b_)
77     t += "_change";
78
79   Molecule*output = new Molecule (lookup_l ()->clef (t));
80   return output;
81 }
82
83
84