]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/clef-item.cc
release: 1.0.1
[lilypond.git] / lily / clef-item.cc
index 920d2c5512fda8c06d55f21e120f2fb036416fc9..285d904a099bdfc45a0ca707b1b5a4c0cd851bd8 100644 (file)
@@ -3,26 +3,28 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
+#include <ctype.h>
 #include "clef-item.hh"
 #include "string.hh"
 #include "molecule.hh"
 #include "paper-def.hh"
 #include "lookup.hh"
-#include "clef-grav.hh"
-
+#include "clef-engraver.hh"
+#include "text-item.hh"
 
 void
 Clef_item::do_pre_processing()
 {
-  change_b_ = ! (break_status_i() == 1);
+  bool b= (break_status_dir() != RIGHT);
+  change_b_ = b;
 
   if (default_b_)
     {
-      set_empty(break_status_i() != 1);
-      transparent_b_ = (break_status_i() != 1);
+      set_empty(b);
+      transparent_b_ = b;
     }
 }
 
@@ -31,39 +33,51 @@ Clef_item::Clef_item()
   breakable_b_ =true;
   default_b_ = false;
   change_b_ = true;
-  read ("violin");
+  octave_dir_ = CENTER;
+  symbol_ = "violin";
+  y_position_i_ = -2;
+  
+  // Ugh: This should be const, I guess.
+  octave_marker_td_p_.set_p (new Text_def());
+  octave_marker_td_p_->text_str_ = "8";
+  octave_marker_td_p_->style_str_ = "italic";
 }
 
-void
-Clef_item::read (String t)
-{
-  type_= t;
-  if (type_ == "violin")
-    y_off = 2;
-  if (type_ == "alto")
-    y_off = 4;
-  if (type_ == "tenor")
-    y_off = 6;
-  if (type_ == "bass")
-    y_off = 6;
-}
+
 void
 Clef_item::read (Clef_engraver const &k)
 {
-  read (k.clef_type_str_);
+  symbol_ = k.clef_type_str_;
+  y_position_i_ = k.clef_position_i_;
+  octave_dir_ = k.octave_dir_;
 }
 
 Molecule*
 Clef_item::brew_molecule_p() const
 {
-  String t = type_;
+  String t = symbol_;
   if  (change_b_)
     t += "_change";
-  Symbol s = paper()->lookup_l ()->clef (t);
+  Atom s = lookup_l ()->clef (t);
   Molecule*output = new Molecule (Atom (s));
-  output->translate (paper()->internote_f () * y_off, Y_AXIS);
+  output->translate_axis (paper()->internote_f () * y_position_i_, Y_AXIS);
+  if (octave_dir_) {
+    Molecule octave_marker = Molecule(octave_marker_td_p_->get_atom(paper(),
+                                                               CENTER));
+    Real offset = output->extent()[Y_AXIS][octave_dir_]
+                  - octave_marker.extent()[Y_AXIS][- octave_dir_];
+    if (octave_dir_ == DOWN)
+      offset += octave_marker.extent()[Y_AXIS][UP] * 0.35 ;
+    octave_marker.translate_axis (offset, Y_AXIS);
+    output->add_molecule (octave_marker);
+  }
   return output;
 }
 
 
 IMPLEMENT_IS_TYPE_B1(Clef_item,Item);
+
+#include "pointer.tcc"
+template class P<Text_def>;    // ugh
+
+