]> git.donarmstrong.com Git - lilypond.git/blob - lily/clef-item.cc
patch::: 1.1.2.hwn1
[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 "text-item.hh"
17
18 void
19 Clef_item::do_pre_processing()
20 {
21   bool b= (break_status_dir() != RIGHT);
22   change_b_ = b;
23
24   if (default_b_)
25     {
26       set_empty(b);
27       transparent_b_ = b;
28     }
29 }
30
31 /*
32   FIXME
33 */
34 Clef_item::Clef_item()
35 {
36   breakable_b_ =true;
37   default_b_ = false;
38   change_b_ = true;
39   octave_dir_ = CENTER;
40   symbol_ = "treble";
41   y_position_i_ = -2;
42   
43   // Ugh: This should be const, I guess.
44   octave_marker_td_p_.set_p (new Text_def());// UGH!
45   octave_marker_td_p_->text_str_ = "8";
46   octave_marker_td_p_->style_str_ = "italic";
47 }
48
49
50
51
52 Molecule*
53 Clef_item::brew_molecule_p() const
54 {
55   String t = symbol_;
56   if  (change_b_)
57     t += "_change";
58   Atom s = lookup_l ()->clef (t);
59   Molecule*output = new Molecule (Atom (s));
60   output->translate_axis (paper()->internote_f () * y_position_i_, Y_AXIS);
61   if (octave_dir_) {
62     Molecule octave_marker = Molecule(octave_marker_td_p_->get_atom(paper(),
63                                                                 CENTER));
64     Real offset = output->extent()[Y_AXIS][octave_dir_]
65                    - octave_marker.extent()[Y_AXIS][- octave_dir_];
66     if (octave_dir_ == DOWN)
67       offset += octave_marker.extent()[Y_AXIS][UP] * 0.35 ;
68     octave_marker.translate_axis (offset, Y_AXIS);
69     output->add_molecule (octave_marker);
70   }
71   return output;
72 }
73
74
75 IMPLEMENT_IS_TYPE_B1(Clef_item,Item);
76
77 #include "pointer.tcc"
78 template class P<Text_def>;     // ugh
79
80