2 dot-column.cc -- implement Dot_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 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"
21 Dot_column::add_head (Score_element
* me
, Score_element
*rh
)
23 Score_element
* d
= unsmob_element (rh
->get_elt_property ("dot"));
26 Side_position::add_support (me
,rh
);
28 Pointer_group_interface
gi (me
, "dots");
31 d
->add_offset_callback (force_shift_callback
, Y_AXIS
);
32 Axis_group_interface::add_element (me
, d
);
40 Dot_column::set_interface (Score_element
* me
)
42 me
->set_elt_property ("dots", SCM_EOL
);
43 Directional_element_interface (me
).set (RIGHT
);
45 Axis_group_interface::set_interface (me
);
46 Axis_group_interface::set_axes (me
, X_AXIS
,X_AXIS
);
50 Will fuck up in this case.
67 Dot_column::force_shift_callback (Score_element
* dot
, Axis a
)
70 Score_element
* me
= dot
->parent_l (X_AXIS
);
71 SCM dots
= me
->get_elt_property ("dots");
77 Dot_column::do_shifts (SCM l
)
79 Link_array
<Score_element
> dots
;
82 dots
.push (unsmob_element (gh_car (l
)));
86 dots
.sort (compare_position
);
93 Array
<int> taken_posns
;
95 for (int i
=0; i
< dots
.size (); i
++)
97 Real p
= Staff_symbol_referencer::position_f (dots
[i
]);
98 for (int j
=0; j
< taken_posns
.size (); j
++)
100 if (taken_posns
[j
] == (int) p
)
103 taken_posns
.push ((int)p
);
104 s
.unite (Slice ((int)p
,
109 return SCM_UNDEFINED
;
111 int middle
= s
.center ();
115 int pos
= middle
- dots
.size () + 1;
117 pos
++; // center () rounds down.
119 for (int i
=0; i
< dots
.size (); pos
+= 2, i
++)
121 Score_element
* d
= dots
[i
];
122 Staff_symbol_referencer::set_position (d
,pos
);
125 return SCM_UNDEFINED
;
129 Dot_column::has_interface (Score_element
*m
)
131 return m
&& m
->has_interface (ly_symbol2scm ("dot-column-interface"));