]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/text-def.cc
release: 1.0.1
[lilypond.git] / lily / text-def.cc
index 1e75aa83aec358037dd75034f44dc5464b33d715..faf0dae1c4cfc65862599f7ea89dbea837cd8fec 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "debug.hh"
 #include "paper-def.hh"
 #include "molecule.hh"
 #include "text-def.hh"
-#include "dimen.hh"
+#include "dimension.hh"
+
+Direction
+Text_def::staff_dir () const
+{
+  if (style_str_ == "finger")
+    return UP;
+  return DOWN;
+}
 
 Interval
 Text_def::width (Paper_def * p) const
@@ -20,7 +28,7 @@ Text_def::width (Paper_def * p) const
 
   Real guess_width_f = text_str_.length_i() * a.dim_.x ().length (); // ugh
   Interval i (0, guess_width_f);
-  i += - (align_i_ + 1)* i.center();
+  i += - (align_dir_ + 1)* i.center();
   return i;
 }
 
@@ -28,13 +36,13 @@ void
 Text_def::do_print() const
 {
 #ifndef NPRINT
-  DOUT << "align " <<align_i_ << " `" << text_str_ << "'";
+  DOUT << "align " << align_dir_ << " `" << text_str_ << "'";
 #endif
 }
 
 Text_def::Text_def()
 {   
-  align_i_ = RIGHT;
+  align_dir_ = RIGHT;
   style_str_ = "roman";
 }
 
@@ -42,21 +50,26 @@ bool
 Text_def::do_equal_b (General_script_def const *gdef) const
 {
   Text_def const *def= (Text_def*)gdef;
-  return align_i_ == def->align_i_ && text_str_ == def->text_str_
+  return align_dir_ == def->align_dir_ && text_str_ == def->text_str_
        && style_str_ == def->style_str_;
 }
 
 Atom
 Text_def::get_atom (Paper_def *p, Direction) const
 {
-  return p->lookup_l()->text (style_str_, text_str_, -align_i_);
+  Atom a= p->lookup_l(0)->text (style_str_, text_str_);
+
+  Real guess_width_f = text_str_.length_i() * a.dim_.x ().length (); // ugh
+  a.translate_axis (-(align_dir_ + 1)* guess_width_f/ 2, X_AXIS);
+  
+  return a;
 }
 
 void
 Text_def::print() const
 {
   DOUT << "Text `" << text_str_ << "\', style " <<
-       style_str_ << "align " << align_i_ << '\n';
+       style_str_ << "align " << align_dir_ << '\n';
 }