lilypond-0.1.57
[lilypond.git] / lily / text-item.cc
blobc471fa1453f7c96c82c8ec14a077c1c319d74f06
1 /*
2 text-item.cc -- implement Text_item
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
10 #include "musical-request.hh"
11 #include "paper-def.hh"
12 #include "text-item.hh"
13 #include "stem.hh"
14 #include "molecule.hh"
15 #include "lookup.hh"
16 #include "debug.hh"
18 Text_item::Text_item (General_script_def* tdef_l, Direction d)
20 dir_ = d;
21 fat_b_ = false;
22 tdef_p_ = tdef_l->clone ();
25 Text_item::~Text_item ()
27 delete tdef_p_;
30 void
31 Text_item::do_pre_processing ()
33 if (!dir_)
34 dir_ = DOWN;
37 Real
38 Text_item::get_position_f () const
40 // uhuh, tdef/gdef?
41 if ( (tdef_p_->name () != Text_def::static_name ())
42 || ( ( (Text_def*)tdef_p_)->style_str_ != "finger"))
43 return Staff_side::get_position_f ();
45 if (!dir_)
47 warning (_ ("Text_item::get_position_f(): "
48 "somebody forgot to set my vertical direction, returning -20"));
49 return -20;
52 Interval v = support_height ();
53 // add no extra: fingers should be just above note, no?
54 return v[dir_];
57 Interval
58 Text_item::symbol_height () const
60 return tdef_p_->get_atom (paper (), dir_).dim_.y ();
63 Molecule*
64 Text_item::brew_molecule_p () const
66 Atom a (tdef_p_->get_atom (paper (), dir_));
69 if (fat_b_)
70 a.dim_[X_AXIS] = tdef_p_->width (paper ());
71 Molecule* mol_p = new Molecule (a);
73 if (dir_<0) // should do something better anyway.
74 mol_p->translate_axis (-mol_p->extent ().y ().left , Y_AXIS);
75 mol_p->translate_axis (y_, Y_AXIS);
77 return mol_p;
81 IMPLEMENT_IS_TYPE_B1 (Text_item,Item);