]> git.donarmstrong.com Git - lilypond.git/blob - lily/clef-item.cc
285d904a099bdfc45a0ca707b1b5a4c0cd851bd8
[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 Clef_item::Clef_item()
32 {
33   breakable_b_ =true;
34   default_b_ = false;
35   change_b_ = true;
36   octave_dir_ = CENTER;
37   symbol_ = "violin";
38   y_position_i_ = -2;
39   
40   // Ugh: This should be const, I guess.
41   octave_marker_td_p_.set_p (new Text_def());
42   octave_marker_td_p_->text_str_ = "8";
43   octave_marker_td_p_->style_str_ = "italic";
44 }
45
46
47 void
48 Clef_item::read (Clef_engraver const &k)
49 {
50   symbol_ = k.clef_type_str_;
51   y_position_i_ = k.clef_position_i_;
52   octave_dir_ = k.octave_dir_;
53 }
54
55 Molecule*
56 Clef_item::brew_molecule_p() const
57 {
58   String t = symbol_;
59   if  (change_b_)
60     t += "_change";
61   Atom s = lookup_l ()->clef (t);
62   Molecule*output = new Molecule (Atom (s));
63   output->translate_axis (paper()->internote_f () * y_position_i_, Y_AXIS);
64   if (octave_dir_) {
65     Molecule octave_marker = Molecule(octave_marker_td_p_->get_atom(paper(),
66                                                                 CENTER));
67     Real offset = output->extent()[Y_AXIS][octave_dir_]
68                    - octave_marker.extent()[Y_AXIS][- octave_dir_];
69     if (octave_dir_ == DOWN)
70       offset += octave_marker.extent()[Y_AXIS][UP] * 0.35 ;
71     octave_marker.translate_axis (offset, Y_AXIS);
72     output->add_molecule (octave_marker);
73   }
74   return output;
75 }
76
77
78 IMPLEMENT_IS_TYPE_B1(Clef_item,Item);
79
80 #include "pointer.tcc"
81 template class P<Text_def>;     // ugh
82
83