]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.30
authorfred <fred>
Sun, 24 Mar 2002 20:01:42 +0000 (20:01 +0000)
committerfred <fred>
Sun, 24 Mar 2002 20:01:42 +0000 (20:01 +0000)
lily/crescendo.cc
lily/dynamic-grav.cc
lily/include/staff-side.hh
lily/script.cc
lily/staff-side.cc
lily/staff-sym.cc
lily/text-item.cc

index acb8a5bdf3f6c90234bfc69056247e8fc1937c1f..ffe6648c531067a18b47ac658642fea48965e2c8 100644 (file)
@@ -18,7 +18,6 @@ Crescendo::Crescendo()
   grow_dir_ =0;
   dir_ = DOWN ;
   dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
-  inside_staff_b_ = false;
 }
 
 Interval
@@ -62,7 +61,7 @@ Crescendo::brew_molecule_p() const
   m_p = new Molecule;
   Atom s (get_symbol());
   m_p->add (Atom (s));
-  m_p->translate (Offset (x_off_dim, pos_i_ * paper()->internote_f ()));
+  m_p->translate (Offset (x_off_dim, y_));
   return m_p;
 }
 
index 7a62123f83aeeef5036844faa34418b8347dcf46..d4b9544e3a5282b8a51c4e9b0c83254fe8942504 100644 (file)
@@ -105,7 +105,8 @@ Dynamic_engraver::do_pre_move_processing()
   Staff_symbol* s_l = get_staff_info().staff_sym_l_;
   if (dynamic_p_)
     {
-      dynamic_p_->set_staffsym (s_l);
+      
+      dynamic_p_->add_support (s_l);
       typeset_element (dynamic_p_);
       dynamic_p_ = 0;
     }
@@ -115,7 +116,7 @@ Dynamic_engraver::do_pre_move_processing()
        to_end_cresc_p_->dyn_b_drul_[RIGHT]=true;
 
       to_end_cresc_p_->set_bounds(RIGHT,get_staff_info().musical_l ());
-      to_end_cresc_p_->set_staffsym (s_l);
+      to_end_cresc_p_->add_support (s_l);
       typeset_element (to_end_cresc_p_);
       to_end_cresc_p_ = 0;
     }
index c682c9efbd24d9dcf0e16bc6a36567e0ca66a28c..131b265186f5bd03bbe8c80bd09fa55d586f8531 100644 (file)
 
   */
 class Staff_side : virtual Score_elem {
-    Link_array<Score_elem> support_l_arr_;
-    int staff_size_i_;
-    Interval support_height() const;
-    Staff_symbol* staff_sym_l_;
-    int get_position_i() const;
+  Link_array<Score_elem> support_l_arr_;
+  int staff_size_i_;
+  Interval support_height() const;
+  Staff_symbol* staff_sym_l_;
+  Real get_position_f() const;
 
-    void read_staff_sym();
+  void read_staff_sym();
 public:
 
-    /**
-      Vertical dir of symbol relative to staff. -1 = below staff?
-      */
-    Direction dir_;
-    Interval sym_int_;
+  /**
+    Vertical dir of symbol relative to staff. -1 = below staff?
+    */
+  Direction dir_;
+  Interval sym_int_;
     
-    /// follow the support inside the staff?
-    bool inside_staff_b_;
+  /// follow the support inside the staff?
+  bool inside_staff_b_;
 
-    int pos_i_;
+  Real y_;
 
-    void set_staffsym (Staff_symbol * );
+
+  void set_staffsym (Staff_symbol * );
   
-    Staff_side();
-    void add_support (Score_elem*);
-    DECLARE_MY_RUNTIME_TYPEINFO;
+  Staff_side();
+  void add_support (Score_elem*);
+  DECLARE_MY_RUNTIME_TYPEINFO;
     
 protected:
-    virtual Interval symbol_height() const;
-    virtual void do_substitute_dependency (Score_elem *, Score_elem*);
-    virtual void do_post_processing();
+  virtual Interval symbol_height() const;
+  virtual void do_substitute_dependency (Score_elem *, Score_elem*);
+  virtual void do_post_processing();
 };
 #endif // STAFF_SIDE_HH
index ceaeacd4c3e24e35a8474ded3d09c352bbeb4148..0979cfe8245a61d38c8637c698ea9fca39d3a360 100644 (file)
@@ -86,7 +86,6 @@ Script::do_pre_processing()
 
   if (!dir_)
     set_default_dir();
-  inside_staff_b_ = specs_l_->inside_b();
 }
 
 Interval
@@ -98,11 +97,10 @@ Script::symbol_height() const
 Molecule*
 Script::brew_molecule_p() const
 {
-  Real dy = paper()->internote_f ();
   Real dx = paper()->note_width()/2;
 
   Molecule*out = new Molecule (specs_l_->get_atom (paper(), dir_));
-  out->translate_axis (dy * pos_i_, Y_AXIS);
+  out->translate_axis (y_, Y_AXIS);
   out->translate_axis (dx, X_AXIS);    // FIXME! ugh
   return out;
 }
index 7f9abeeb8316d55e7c27db8e4c61a81fad0bdc9a..4099f2eecec1d5d928d2f20da55b1ecc1488721e 100644 (file)
 #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;
+   y_=0;
   sym_int_ = Interval (0,0);
-  staff_size_i_ = 0;
-  staff_sym_l_ = 0;
   dir_ = CENTER;
   inside_staff_b_ = false;
 }
 
-void
-Staff_side::read_staff_sym()
-{
-  if (! staff_sym_l_)
-    return ;
-  staff_size_i_ = staff_sym_l_->steps_i();
-}
-
 
 Interval
 Staff_side::support_height() const
 {
-  Interval r;
+  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);
 
-  for (int i=0; i < support_l_arr_.size(); i++)
-    r.unite (support_l_arr_[i]->height());
-  if (r.empty_b())
+      y_int.unite (y + support_l_arr_[i]->height());
+    }
+
+
+  if (y_int.empty_b())
     {
-      r = Interval (0,0);
+      y_int = Interval (0,0);
     }
-  return r;
+  return y_int;
 }
 
 void
@@ -60,8 +53,8 @@ Staff_side::add_support (Score_elem*i)
   add_dependency (i);
 }
 
-int
-Staff_side::get_position_i() const
+Real
+Staff_side::get_position_f() const
 {
   if (!dir_)
     {
@@ -73,28 +66,11 @@ Staff_side::get_position_i() const
 
   Real y=0;
   Real inter_f = paper()-> internote_f ();
-  if (!inside_staff_b_)
-    {
-      y  = (staff_sym_l_) ? dir_ * (staff_sym_l_->steps_i()/2 + 2) : -2;
-      y *=inter_f;
-
-      Interval v= support_height();
-
-      if (dir_ > 0)
-       {
-         y = y >? (v.max() + 2*inter_f);
-       }
-      else if (dir_ < 0)
-       {
-         y = y <? (v.min() - 2*inter_f);
-       }
-    }
-  else
-    {
-      Interval v= support_height();
-      y = v[dir_]  + 2*dir_*inter_f;   // ugh
-    }
-  return int (rint (Real (y)/inter_f)); // should ret a float?
+
+  Interval v= support_height();
+  y = v[dir_]  + 2*dir_*inter_f;       // ugh
+
+  return y;
 }
 
 Interval
@@ -107,17 +83,15 @@ void
 Staff_side::do_post_processing()
 {
   sym_int_ = symbol_height();
-  pos_i_ = get_position_i();
+  y_ = get_position_f();
   if (dir_)
-    pos_i_ += int (rint (- sym_int_[-dir_] / paper()->internote_f ()));
+    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;
 }
 
 
index ebacee46f730c62499eec09272213c51b09ac7b3..4cd214b79bc36015a4ea9b5c9bd75220f1c293c7 100644 (file)
 #include "paper-def.hh"
 #include "molecule.hh"
 #include "debug.hh"
-
+#include "dimen.hh"
 
 
 Staff_symbol::Staff_symbol (int l)
 {
   no_lines_i_ = l;
+  interline_f_ =  0 PT;
 }
 
 
@@ -30,19 +31,25 @@ Staff_symbol::do_print() const
 #endif
 }
 
+Interval
+Staff_symbol::do_height() const
+{
+  int n = no_lines_i_ -1;
+  return 2* inter_note_f () * Interval (-n, n);
+}
+
 Molecule*
 Staff_symbol::brew_molecule_p() const
 {
   Paper_def * p = paper();
   Atom rule  = p->lookup_l ()->rule_symbol (p->get_var ("rule_thickness"), 
                                            width ().length ());
-  Real inter = p->interline_f ();
-  Real height = (no_lines_i_-1) * inter/2;
+  Real height = (no_lines_i_-1) * inter_note_f();
   Molecule * m = new Molecule;
   for (int i=0; i < no_lines_i_; i++)
     {
       Atom a (rule);
-      a.translate_axis (height - i * inter, Y_AXIS);
+      a.translate_axis (height - i * inter_note_f()*2, Y_AXIS);
       m->add (a);
     }
 
@@ -52,6 +59,9 @@ Staff_symbol::brew_molecule_p() const
 Real
 Staff_symbol::inter_note_f() const
 {
+  if (interline_f_)
+    return interline_f_/2;
+
   return paper()->internote_f ();
 }
 
index 8d62ea72896dd97d231c54e3b6ef5ff41b2dbc0f..16a45977f17d9bcf043e97c4fa2a6c3349ea3e77 100644 (file)
@@ -52,7 +52,7 @@ Text_item::brew_molecule_p() const
 
   if (dir_<0)          // should do something better anyway.
     mol_p->translate_axis (-mol_p->extent().y ().left , Y_AXIS);
-  mol_p->translate_axis (pos_i_ * paper()->internote_f (), Y_AXIS);
+  mol_p->translate_axis (y_, Y_AXIS);
   
   return mol_p;
 }