grow_dir_ =0;
dir_ = DOWN ;
dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
- inside_staff_b_ = false;
}
Interval
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;
}
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;
}
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;
}
*/
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
if (!dir_)
set_default_dir();
- inside_staff_b_ = specs_l_->inside_b();
}
Interval
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;
}
#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
add_dependency (i);
}
-int
-Staff_side::get_position_i() const
+Real
+Staff_side::get_position_f() const
{
if (!dir_)
{
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
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;
}
#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;
}
#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);
}
Real
Staff_symbol::inter_note_f() const
{
+ if (interline_f_)
+ return interline_f_/2;
+
return paper()->internote_f ();
}
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;
}