lilypond-1.1.9
[lilypond.git] / lily / clef-item.cc
blobd860b494f2c9f2836b691adb079eb2abb8350ef6
1 /*
2 clef-item.cc -- implement Clef_item
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 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 "clef-engraver.hh"
16 #include "text-item.hh"
18 void
19 Clef_item::do_pre_processing()
21 bool b= (break_status_dir() != RIGHT);
22 change_b_ = b;
24 if (default_b_)
26 set_empty(b);
27 transparent_b_ = b;
32 FIXME
34 Clef_item::Clef_item()
36 breakable_b_ =true;
37 default_b_ = false;
38 change_b_ = true;
39 octave_dir_ = CENTER;
40 symbol_ = "treble";
41 y_position_i_ = -2;
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";
52 Molecule*
53 Clef_item::brew_molecule_p() const
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);
71 return output;
77 #include "pointer.tcc"
78 template class P<Text_def>; // ugh