]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-item.cc
release: 1.1.1
[lilypond.git] / lily / text-item.cc
1 /*
2   text-item.cc -- implement Text_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
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"
17
18 Text_item::Text_item (General_script_def* tdef_l, Direction d) 
19 {
20   dir_ = d;
21   fat_b_ = false;
22   tdef_p_ = tdef_l->clone ();
23 }
24
25 Text_item::~Text_item ()
26 {
27   delete tdef_p_;
28 }
29
30 void
31 Text_item::do_pre_processing ()
32 {
33   if (!dir_)
34     dir_ = DOWN;
35 }
36
37 Real
38 Text_item::get_position_f () const
39 {
40   // uhuh, tdef/gdef?
41   if (Text_def *tdl = dynamic_cast<Text_def*>(tdef_p_))
42     {
43       if (tdl->style_str_ != "finger") // HUHH?
44         return Staff_side::get_position_f ();
45     }
46
47   if (!dir_)
48     {
49       warning (_ ("Text_item::get_position_f(): "
50                  "somebody forgot to set my vertical direction, returning -20"));
51       return -20;
52     }
53
54   Interval v = support_extent ();
55   // add no extra: fingers should be just above note, no?
56   return v[dir_];
57 }
58
59 Interval
60 Text_item::symbol_height () const
61 {
62   return tdef_p_->get_atom (paper (), dir_).dim_.y ();
63 }
64   
65 Molecule*
66 Text_item::brew_molecule_p () const
67 {
68   Atom a (tdef_p_->get_atom (paper (), dir_));
69
70
71   if (fat_b_)
72     a.dim_[X_AXIS] = tdef_p_->width (paper ());
73   Molecule* mol_p = new Molecule (a);
74
75   if (dir_<0)           // should do something better anyway.
76     mol_p->translate_axis (-mol_p->extent ().y ().left , Y_AXIS);
77   mol_p->translate_axis (coordinate_offset_f_, Y_AXIS);
78
79   
80   return mol_p;
81 }
82
83
84 IMPLEMENT_IS_TYPE_B1 (Text_item,Item);