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