]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/staff-side.cc
release: 0.1.61
[lilypond.git] / lily / staff-side.cc
index 704dc21ede07d9d59670f6123c0ae86c03412a81..7b99d06f998516627239d984f1fc5a4bc67f3a16 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
 #include "interval.hh"
 #include "staff-sym.hh"
 #include "debug.hh"
 
-void
-Staff_side::set_staffsym (Staff_symbol* s_l)
-{
-    staff_sym_l_ = s_l;
-    add_dependency (s_l);
-}
 
 Staff_side::Staff_side()
 {
-    pos_i_ =0;
-    sym_int_ = Interval (0,0);
-    staff_size_i_ = 0;
-    staff_sym_l_=0;
-    dir_i_ =0;
-    inside_staff_b_ =false;
-}
-
-void
-Staff_side::read_staff_sym()
-{
-    if (! staff_sym_l_)
-       return ;
-    staff_size_i_ = staff_sym_l_->steps_i();
+  y_=0;
+  sym_int_ = Interval (0,0);
+  dir_ = CENTER;
 }
 
 
 Interval
 Staff_side::support_height() const
 {
-    Interval r;
-    
-    for (int i=0; i < support_l_arr_.size(); i++)
-       r.unite (support_l_arr_[i]->height());
-    if (r.empty_b()) {
-       r = Interval (0,0);
+  Interval y_int;
+  for (int i=0; i < support_l_arr_.size(); i++) 
+    {
+      Axis_group_element *common = 
+       common_group (support_l_arr_[i], Y_AXIS);
+       
+      Real y = support_l_arr_[i]->relative_coordinate (common, Y_AXIS)  
+       -relative_coordinate (common,Y_AXIS);
+
+      y_int.unite (y + support_l_arr_[i]->height());
     }
-    return r;
+
+
+  if (y_int.empty_b())
+    {
+      y_int = Interval (0,0);
+    }
+  return y_int;
 }
 
 void
 Staff_side::add_support (Score_elem*i)
 {
-    support_l_arr_.push (i);
-    add_dependency (i);
+  support_l_arr_.push (i);
+  add_dependency (i);
 }
 
-int
-Staff_side::get_position_i()const
+Real
+Staff_side::get_position_f () const
 {
-    if (!dir_i_) {
-       warning ("Staff_side::get_position_i(): " 
-               "somebody forgot to set my vertical direction, returning -20");
-       return -20;
+  if (!dir_)
+    {
+      warning (_("Staff_side::get_position_f(): "
+                "somebody forgot to set my vertical direction, returning -20"));
+      return -20;
     }
-    
-
-    Real y=0;
-    Real inter_f = paper()-> internote_f ();
-    if (!inside_staff_b_) {
-       y  = (dir_i_ > 0 && staff_sym_l_) ? staff_sym_l_->steps_i() + 2: -2; 
-       y *=inter_f;
-       Interval v= support_height();
-
-       if (dir_i_ > 0) {
-           y = y >? (v.max() + 2*inter_f);
-       } else if (dir_i_ < 0) {
-           y = y <? (v.min() - 2*inter_f);
-       }
-    } else {
-       Interval v= support_height();
-       y = v[dir_i_]  + 2*dir_i_*inter_f;      // ugh
+
+
+  Real y = 0;
+  Real inter_f = paper()-> internote_f ();
+
+  Interval v = support_height();
+
+  // ugh, dim[y] = PT over here
+  y = v[dir_] + 1 * dir_ * inter_f;
+
+  int y_i = (int)rint (y / inter_f);
+  // ugh: 5 -> staff_lines
+  if (abs (y_i) < 5)
+    {
+      if (!(abs (y_i) % 2))
+       y += (Real)dir_ * inter_f;
     }
-    return int (rint (Real (y)/inter_f)); // should ret a float?
+//  else
+//    y = v[dir_] + 1 * dir_ * inter_f;
+
+  return y;
 }
 
 Interval
 Staff_side::symbol_height() const
 {
-    return Interval (0,0);
+  return Interval (0,0);
 }
 
 void
 Staff_side::do_post_processing()
 {
-    sym_int_ = symbol_height();
-    pos_i_ = get_position_i();
-    if (dir_i_)
-       pos_i_ += int (rint (- sym_int_[-dir_i_] / paper()->internote_f ()));
+  sym_int_ = symbol_height();
+  y_ = get_position_f();
+  if (dir_)
+    y_ += - sym_int_[-dir_];
 }
 
 void
 Staff_side::do_substitute_dependency (Score_elem*o, Score_elem*n)
-{ 
-    support_l_arr_.unordered_substitute (o,n);
-    if (staff_sym_l_ == o)
-       staff_sym_l_ = n ? (Staff_symbol*) n->spanner():0;
+{
+  support_l_arr_.unordered_substitute (o,n);
 }