2 dot-column.cc -- implement Dot_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 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 Dot_column::set_interface (Grob
* me
)
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
->parent_l (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::beam_l (stem
)
47 && Stem::flag_i (stem
))
50 trigger stem end & direction calculation.
52 This will add the stem to the support if a flag collision happens.
54 Stem::stem_end_position (stem
);
56 return Side_position_interface::aligned_side (element_smob
, axis
);
61 Will fuck up in this case.
76 Dot_column::do_shifts (SCM l
)
78 Link_array
<Grob
> dots
;
81 dots
.push (unsmob_grob (gh_car (l
)));
85 dots
.sort (compare_position
);
88 return SCM_UNSPECIFIED
;
92 Array
<int> taken_posns
;
94 for (int i
=0; i
< dots
.size (); i
++)
96 Real p
= Staff_symbol_referencer::position_f (dots
[i
]);
97 for (int j
=0; j
< taken_posns
.size (); j
++)
99 if (taken_posns
[j
] == (int) p
)
102 taken_posns
.push ((int)p
);
103 s
.unite (Slice ((int)p
,
108 return SCM_UNSPECIFIED
;
110 int middle
= s
.center ();
114 int pos
= middle
- dots
.size () + 1;
116 pos
++; // center () rounds down.
118 for (int i
=0; i
< dots
.size (); pos
+= 2, i
++)
121 Staff_symbol_referencer::set_position (d
,pos
);
124 return SCM_UNSPECIFIED
;
128 Dot_column::has_interface (Grob
*m
)
130 return m
&& m
->has_interface (ly_symbol2scm ("dot-column-interface"));
135 Dot_column::add_head (Grob
* me
, Grob
*rh
)
137 Grob
* d
= unsmob_grob (rh
->get_grob_property ("dot"));
140 Side_position_interface::add_support (me
,rh
);
142 Pointer_group_interface ::add_element (me
, "dots",d
);
143 d
->add_offset_callback (Dot_column::force_shift_callback_proc
, Y_AXIS
);
144 Axis_group_interface::add_element (me
, d
);