source file of the GNU LilyPond music typesetter
- (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "dots.hh"
#include "directional-element-interface.hh"
#include "side-position-interface.hh"
#include "axis-group-interface.hh"
+#include "stem.hh"
+/*
+ TODO: let Dot_column communicate with stem via Note_column.
+ */
-// todo: dots and elements duplicate each other.
-void
-Dot_column::add_dots (Dots *d)
+MAKE_SCHEME_CALLBACK (Dot_column,force_shift_callback,2);
+SCM
+Dot_column::force_shift_callback (SCM element_smob, SCM axis)
{
- Pointer_group_interface gi (this, "dots");
- gi.add_element (d);
-
- add_dependency (d);
- Axis_group_interface (this).add_element (d);
+ Grob *me = unsmob_grob (element_smob);
+ Axis a = (Axis) gh_scm2int (axis);
+ assert (a == Y_AXIS);
+ me = me->get_parent (X_AXIS);
+ SCM l = me->get_grob_property ("dots");
+ do_shifts (l);
+ return gh_double2scm (0.0);
}
-void
-Dot_column::add_head (Rhythmic_head *r)
+MAKE_SCHEME_CALLBACK(Dot_column,side_position, 2);
+SCM
+Dot_column::side_position (SCM element_smob, SCM axis)
{
- if (!r->dots_l ())
- return ;
-
- Side_position_interface (this).add_support (r);
- add_dots (r->dots_l ());
-}
-
+ Grob *me = unsmob_grob (element_smob);
+ Axis a = (Axis) gh_scm2int (axis);
+ assert (a == X_AXIS);
+
+ Grob * stem = unsmob_grob (me->get_grob_property ("stem"));
+ if (stem
+ && !Stem::get_beam (stem)
+ && Stem::duration_log (stem) > 2
+ && !Stem::invisible_b (stem)
+ )
+ {
+ /*
+ trigger stem end & direction calculation.
-int
-Dot_column::compare (Dots * const &d1, Dots * const &d2)
-{
- Staff_symbol_referencer_interface s1(d1);
- Staff_symbol_referencer_interface s2(d2);
-
- return int (s1.position_f () - s2.position_f ());
+ This will add the stem to the support if a flag collision happens.
+ */
+ Stem::stem_end_position (stem);
+ }
+ return Side_position_interface::aligned_side (element_smob, axis);
}
-Dot_column::Dot_column (SCM s)
- : Item (s)
-{
- Pointer_group_interface gi (this, "dots");
- gi.set_interface ();
- directional_element (this).set (RIGHT);
-
- Axis_group_interface (this).set_interface ();
- Axis_group_interface (this).set_axes(X_AXIS,X_AXIS);
-}
-
/*
Will fuck up in this case.
Should be smarter.
*/
-
-GLUE_SCORE_ELEMENT(Dot_column,after_line_breaking);
SCM
-Dot_column::member_after_line_breaking ()
+Dot_column::do_shifts (SCM l)
{
- Link_array<Dots> dots = Pointer_group_interface__extract_elements (this, (Dots*)0 , "dots");
- dots.sort (Dot_column::compare);
+ Link_array<Grob> dots;
+ while (gh_pair_p (l))
+ {
+ dots.push (unsmob_grob (ly_car (l)));
+ l = ly_cdr (l);
+ }
+
+ dots.sort (compare_position);
if (dots.size () < 2)
- return SCM_UNDEFINED;
+ return SCM_UNSPECIFIED;
Slice s;
s.set_empty ();
int conflicts = 0;
for (int i=0; i < dots.size (); i++)
{
- Real p = Staff_symbol_referencer_interface (dots[i]).position_f ();
+ Real p = Staff_symbol_referencer::get_position (dots[i]);
for (int j=0; j < taken_posns.size (); j++)
{
if (taken_posns[j] == (int) p)
}
taken_posns.push ((int)p);
s.unite (Slice ((int)p,
- (int)p));
+ (int)p));
}
if (!conflicts)
- return SCM_UNDEFINED;
-
+ return SCM_UNSPECIFIED;
int middle = s.center ();
/*
+1 -> off by one
*/
int pos = middle - dots.size () + 1;
- if (!(pos % 2))
+ if (! (pos % 2))
pos ++; // center () rounds down.
for (int i=0; i < dots.size (); pos += 2, i++)
{
- staff_symbol_referencer (dots[i]).set_position(pos);
+ Grob * d = dots[i];
+ Staff_symbol_referencer::set_position (d,pos);
}
- return SCM_UNDEFINED;
+ return SCM_UNSPECIFIED;
+}
+
+
+
+void
+Dot_column::add_head (Grob * me, Grob *rh)
+{
+ Grob * d = unsmob_grob (rh->get_grob_property ("dot"));
+ if (d)
+ {
+ Side_position_interface::add_support (me,rh);
+
+ Pointer_group_interface::add_grob (me, ly_symbol2scm ("dots"), d);
+ d->add_offset_callback (Dot_column::force_shift_callback_proc , Y_AXIS);
+ Axis_group_interface::add_element (me, d);
+ }
}
+
+
+
+
+ADD_INTERFACE (Dot_column, "dot-column-interface",
+ "Interface that groups dots so they form a column",
+ "direction stem");
+