]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-head.cc
release: 1.2.6
[lilypond.git] / lily / note-head.cc
index b779d0e8a651562d10d0699195e968efe7a5fafd..8ea7cb460dc1d4ea95c9390c6f2770b79cff30d6 100644 (file)
 #include "dots.hh"
 #include "note-head.hh"
 #include "debug.hh"
-#include "paper-def.hh"
 #include "lookup.hh"
 #include "molecule.hh"
 #include "musical-request.hh"
+#include "stem.hh"
 
+void
+Note_head::flip_around_stem (Direction d)
+{
+  translate_axis (do_width ().length () * d, X_AXIS);
+}
 
 Note_head::Note_head ()
 {
-  x_dir_ = CENTER;
-  staff_size_i_= 8;            // UGH
-  steps_i_ = 0;
-  position_i_ = 0;
-  extremal_i_ = 0;
 }
 
 void
 Note_head::do_pre_processing ()
 {
+  Rhythmic_head::do_pre_processing ();
   // 8 ball looks the same as 4 ball:
   if (balltype_i_ > 2)
     balltype_i_ = 2;
   if (dots_l_)                 // move into Rhythmic_head?
-    dots_l_->position_i_ = position_i_;
+    dots_l_->position_i_ = position_i ();
 }
 
 
 
-
 int
 Note_head::compare (Note_head *const  &a, Note_head * const &b)
 {
-  return a->position_i_ - b->position_i_;
+  return a->position_i () - b->position_i ();
 }
 
+/**
+ Don't account for ledgerlines in the width.
+ */
 Interval
 Note_head::do_width () const
 {
-  Molecule a =  lookup_l ()->ball (balltype_i_);
+  Molecule a =  lookup_l ()->notehead (balltype_i_, ""); // UGH
   Interval i = a.dim_[X_AXIS];
-  i+= x_dir_ * i.length ();
   return i;
 }
 
 Molecule*
 Note_head::do_brew_molecule_p() const 
 {
-  Molecule*out = 0;
-  Paper_def *p = paper();
-  Real inter_f = p->internote_f ();
+  Real inter_f = staff_line_leading_f ()/2;
+  int sz = lines_i ()-1;
 
-  // ugh
-  int streepjes_i = abs (position_i_) < staff_size_i_/2 
+  int streepjes_i = abs (position_i ()) < sz 
     ? 0
-    : (abs(position_i_) - staff_size_i_/2) /2;
-  
-  Molecule head; 
+    : (abs(position_i ()) - sz) /2;
 
-  if (note_head_type_str_.length_i ()) {
-    if (note_head_type_str_ == "normal") // UGH
-      note_head_type_str_ = "";
-    head = lookup_l()->special_ball (balltype_i_, note_head_type_str_);
+
+  String type; 
+  SCM style  =get_elt_property (style_scm_sym);
+  if (style != SCM_BOOL_F)
+    {
+      type = ly_scm2string (SCM_CDR(style));
     }
-  else
-    head = lookup_l()->ball (balltype_i_);
   
-  out = new Molecule (Molecule (head));
-  out->translate_axis (x_dir_ * head.dim_[X_AXIS].length (), X_AXIS);
-
+  Molecule*  out = new Molecule (lookup_l()->notehead (balltype_i_, type));
 
+  Box b = out->dim_;
 
   if (streepjes_i) 
     {
-      Direction dir = sign (position_i_);
-      Interval hd = head.dim_[X_AXIS];
+      Direction dir = (Direction)sign (position_i ());
+      Interval hd = out->dim_[X_AXIS];
       Real hw = hd.length ()/4;
       
       Molecule ledger
        = lookup_l ()->ledger_line  (Interval (hd[LEFT] - hw,
                                               hd[RIGHT] + hw));
       
-      int parity =  abs(position_i_) % 2;
+      int parity =  abs(position_i ()) % 2;
       
       for (int i=0; i < streepjes_i; i++)
        {
@@ -100,7 +97,7 @@ Note_head::do_brew_molecule_p() const
          out->add_molecule (s);
        }
     }
-  
-  out->translate_axis (inter_f*position_i_, Y_AXIS);
+
+  out->dim_ = b;
   return out;
 }