source file of the GNU LilyPond music typesetter
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include <math.h> // ceil.
+
#include "beam.hh"
#include "debug.hh"
#include "rest-collision.hh"
#include "paper-def.hh"
#include "rest.hh"
#include "group-interface.hh"
+#include "staff-symbol-referencer.hh"
+#include "duration.hh"
void
Rest_collision::add_column (Note_column *nc_l)
gi.add_element (nc_l);
}
+static Duration
+to_duration (int type, int dots)
+{
+ Duration d;
+ d.durlog_i_ = type;
+ d.dots_i_ = dots;
+ return d;
+}
+
+static Moment
+rhythmic_head2mom (Rhythmic_head* r)
+{
+ return to_duration (r->balltype_i (), r->dot_count ()).length_mom ();
+}
+
+static Rhythmic_head*
+col2rhythmic_head (Note_column* c)
+{
+ SCM s = c->get_elt_property ("rests");
+ assert (gh_pair_p (s));
+ Score_element* e = unsmob_element (gh_car (s));
+ return dynamic_cast<Rhythmic_head*> (e);
+}
+
void
-Rest_collision::do_pre_processing()
+Rest_collision::before_line_breaking ()
{
Link_array<Note_column> rest_l_arr =
Group_interface__extract_elements (this, (Note_column*) 0, "rests");
// meisjes met meisjes
if (!ncol_l_arr.size())
{
+ Moment m = rhythmic_head2mom (col2rhythmic_head (rest_l_arr[0]));
+ int i = 1;
+ for (; i < rest_l_arr.size (); i++)
+ {
+ Moment me = rhythmic_head2mom (col2rhythmic_head (rest_l_arr[i]));
+ if (me != m)
+ break;
+ }
+
+ /*
+ If all durations are the same, we'll check if there are more
+ rests than maximum-rest-count.
+ Otherwise (different durations), we'll try to display them all
+ (urg: all 3 of them, currently).
+ */
+ int display_count;
+ SCM s = get_elt_property ("maximum-rest-count");
+ if (i == rest_l_arr.size ()
+ && gh_number_p (s) && gh_scm2int (s) < rest_l_arr.size ())
+ {
+ display_count = gh_scm2int (s);
+ for (; i > display_count; i--)
+ col2rhythmic_head (rest_l_arr[i-1])
+ ->set_elt_property ("transparent", SCM_BOOL_T);
+ }
+ else
+ display_count = rest_l_arr.size ();
+
/*
UGH. Should get dims from table. Should have minimum dist.
*/
- int dy = rest_l_arr.size() > 2 ? 6 : 4;
-
- rest_l_arr[0]->translate_rests (rest_l_arr[0]->dir () *dy);
- rest_l_arr.top()->translate_rests (rest_l_arr.top ()->dir ()* dy);
+ int dy = display_count > 2 ? 6 : 4;
+ if (display_count > 1)
+ {
+ rest_l_arr[0]->translate_rests (dy);
+ rest_l_arr[1]->translate_rests (-dy);
+ }
}
// meisjes met jongetjes
else
/* FIXME
staff_space = rcol->rest_l_arr[0]->staff_space ();
*/
- Real internote_f = staff_space/2;
+ Real half_staff_space_f = staff_space/2;
Real minimum_dist = paper_l ()->get_var ("restcollision_minimum_dist")
- * internote_f;
+ * half_staff_space_f;
/*
assumption: ref points are the same.
// FIXME
- int stafflines = 5; // rcol->rest_l_arr[0]->lines_i ();
-
+ //int stafflines = 5; // rcol->rest_l_arr[0]->line_count;
+ int stafflines = Staff_symbol_referencer_interface (this).line_count ();
+ // hurg?
+ stafflines = stafflines != 0 ? stafflines : 5;
// move discretely by half spaces.
int discrete_dist = int (ceil (dist / (0.5 *staff_space)));
set_elt_property ("rests", SCM_EOL);
set_elt_property ("notes", SCM_EOL);
set_elt_property ("transparent", SCM_BOOL_T);
- set_empty (X_AXIS);
- set_empty (Y_AXIS);
+ set_extent_callback (0, X_AXIS);
+ set_extent_callback (0, Y_AXIS);
}