2 dot-column.cc -- implement Dot_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "dot-column.hh"
11 #include "rhythmic-head.hh"
12 #include "group-interface.hh"
13 #include "staff-symbol-referencer.hh"
14 #include "directional-element-interface.hh"
15 #include "side-position-interface.hh"
16 #include "axis-group-interface.hh"
20 TODO: let Dot_column communicate with stem via Note_column.
23 MAKE_SCHEME_CALLBACK (Dot_column
,force_shift_callback
,2);
25 Dot_column::force_shift_callback (SCM element_smob
, SCM axis
)
27 Grob
*me
= unsmob_grob (element_smob
);
28 Axis a
= (Axis
) gh_scm2int (axis
);
30 me
= me
->get_parent (X_AXIS
);
31 SCM l
= me
->get_grob_property ("dots");
33 return gh_double2scm (0.0);
36 MAKE_SCHEME_CALLBACK(Dot_column
,side_position
, 2);
38 Dot_column::side_position (SCM element_smob
, SCM axis
)
40 Grob
*me
= unsmob_grob (element_smob
);
41 Axis a
= (Axis
) gh_scm2int (axis
);
44 Grob
* stem
= unsmob_grob (me
->get_grob_property ("stem"));
46 && !Stem::get_beam (stem
)
47 && Stem::duration_log (stem
) > 2
48 && !Stem::invisible_b (stem
)
52 trigger stem end & direction calculation.
54 This will add the stem to the support if a flag collision happens.
56 Stem::stem_end_position (stem
);
58 return Side_position_interface::aligned_side (element_smob
, axis
);
63 Will fuck up in this case.
78 Dot_column::do_shifts (SCM l
)
80 Link_array
<Grob
> dots
;
83 dots
.push (unsmob_grob (ly_car (l
)));
87 dots
.sort (compare_position
);
90 return SCM_UNSPECIFIED
;
94 Array
<int> taken_posns
;
96 for (int i
=0; i
< dots
.size (); i
++)
98 Real p
= Staff_symbol_referencer::get_position (dots
[i
]);
99 for (int j
=0; j
< taken_posns
.size (); j
++)
101 if (taken_posns
[j
] == (int) p
)
104 taken_posns
.push ((int)p
);
105 s
.unite (Slice ((int)p
,
110 return SCM_UNSPECIFIED
;
112 int middle
= s
.center ();
116 int pos
= middle
- dots
.size () + 1;
118 pos
++; // center () rounds down.
120 for (int i
=0; i
< dots
.size (); pos
+= 2, i
++)
123 Staff_symbol_referencer::set_position (d
,pos
);
126 return SCM_UNSPECIFIED
;
132 Dot_column::add_head (Grob
* me
, Grob
*rh
)
134 Grob
* d
= unsmob_grob (rh
->get_grob_property ("dot"));
137 Side_position_interface::add_support (me
,rh
);
139 Pointer_group_interface::add_grob (me
, ly_symbol2scm ("dots"), d
);
140 d
->add_offset_callback (Dot_column::force_shift_callback_proc
, Y_AXIS
);
141 Axis_group_interface::add_element (me
, d
);
148 ADD_INTERFACE (Dot_column
, "dot-column-interface",
149 "Interface that groups dots so they form a column",