]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/notehead.cc
release: 0.1.13
[lilypond.git] / lily / notehead.cc
index 85132fe55e9cede48d0980640e142b8d1e92ca09..389ff0cf60ff8ed33cdf6014e21fef790f78e0e5 100644 (file)
@@ -1,5 +1,14 @@
+/*
+  notehead.cc -- implement Note_head
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
 #include "misc.hh"
-#include "notehead.hh"
+#include "dots.hh"
+#include "note-head.hh"
 #include "dimen.hh" 
 #include "debug.hh"
 #include "paper-def.hh"
 #include "musical-request.hh"
 
 
-
-Notehead::Notehead(int ss)
+Note_head::Note_head ()
 {
-    x_dir = 0;
-    staff_size=ss;
-    position = 0;
-    balltype = 0;
-    dots = 0;
-    extremal = 0;
-    rest_b_ = false;
+  x_dir_ = CENTER;
+  staff_size_i_= 8;            // UGH
+  position_i_ = 0;
+  extremal_i_ = 0;
 }
 
 void
-Notehead::set_rhythmic(Rhythmic_req*r_req_l)
+Note_head::do_pre_processing ()
 {
-    balltype = r_req_l->duration_.type_i_;
-    dots = r_req_l->duration_.dots_i_;
+  // 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_;
 }
-    
-IMPLEMENT_STATIC_NAME(Notehead);
 
-void
-Notehead::do_print()const
-{
-#ifndef NPRINT
-    if (rest_b_)
-       mtor << "REST! ";
-    mtor << "balltype "<< balltype << ", position = "<< position
-        << "dots " << dots;
-#endif
-}
+IMPLEMENT_IS_TYPE_B1(Note_head,Rhythmic_head);
 
 
 int
-Notehead::compare(Notehead *const  &a, Notehead * const &b)
+Note_head::compare (Note_head *const  &a, Note_head * const &b)
 {
-    return a->position - b->position;
+  return a->position_i_ - b->position_i_;
 }
 
 Molecule*
-Notehead::brew_molecule_p() const return out;
+Note_head::brew_molecule_p() const 
 {
-    Paper_def *p = paper();
+  Molecule*out = 0;
+  Paper_def *p = paper();
+  Real inter_f = p->internote_f ();
 
-    Real dy = p->internote();
-    Symbol s;
-    if (!rest_b_)
-       s = p->lookup_l()->ball(balltype);
-    else 
-       s = p->lookup_l()->rest(balltype);
-    
-    out = new Molecule(Atom(s));
-    if (dots) {
-       Symbol d = p->lookup_l()->dots(dots);
-       Molecule dm;
-       dm.add(Atom(d));
-       if (!(position %2))
-           dm.translate(Offset(0,dy));
-       out->add_right(dm);
-    }
-    out->translate(Offset(x_dir * p->note_width(),0));
-    bool streepjes = (position<-1)||(position > staff_size+1);
-    if (streepjes) {
-       int dir = sign(position);
-       int s =(position<-1) ? -((-position)/2): (position-staff_size)/2;
-       Symbol str = p->lookup_l()->streepjes(s);
-       Molecule sm;
-       sm.add(Atom(str));
-       if (position % 2)
-           sm.translate(Offset(0,-dy* dir));
-       out->add(sm);       
+  // ugh
+  bool streepjes_b = (position_i_<-1) || (position_i_ > staff_size_i_+1);
+  
+  Symbol  s = p->lookup_l()->ball (balltype_i_);
+  out = new Molecule (Atom (s));
+  out->translate (x_dir_ * s.dim.x().length (), X_AXIS);
+
+  if (streepjes_b) 
+    {
+      int dir = sign (position_i_);
+      int s =(position_i_<-1) 
+       ? -((-position_i_)/2)
+       : (position_i_-staff_size_i_)/2;
+       
+      Symbol str = p->lookup_l()->streepjes (s);
+      Molecule sm;
+      sm.add (Atom (str));
+      if (position_i_ % 2)
+       sm.translate (-inter_f* dir, Y_AXIS);
+      out->add (sm);       
     }
-    
-    out->translate(Offset(0,dy*position));
+  
+  out->translate (inter_f*position_i_, Y_AXIS);
+  return out;
 }
-