-#include "pointer-group-interface.hh"
-#include "grob-array.hh"
-
-/*
- TODO: this file/class is too complex. Should figure out how to chop
- this up even more.
-*/
-
-class Spacing_spanner
-{
-public:
- static void standard_breakable_column_spacing (Grob *me, Item *l, Item *r,
- Real *fixed, Real *space, Moment);
-
- static Real default_bar_spacing (Grob *, Grob *, Grob *, Moment);
- static Real note_spacing (Grob *, Grob *, Grob *, Moment, bool *);
- static Real get_duration_space (Grob *, Moment dur, Rational shortest, bool *);
- static Rational find_shortest (Grob *, Link_array<Grob> const &);
- static void breakable_column_spacing (Grob *, Item *l, Item *r, Moment);
- static void find_loose_columns () {}
- static void prune_loose_columns (Grob *, Link_array<Grob> *cols, Rational);
- static void find_loose_columns (Link_array<Grob> cols);
- static void set_explicit_neighbor_columns (Link_array<Grob> const &cols);
- static void set_implicit_neighbor_columns (Link_array<Grob> const &cols);
- static void do_measure (Rational, Grob *me, Link_array<Grob> *cols);
- static void musical_column_spacing (Grob *, Item *, Item *, Real, Rational);
- DECLARE_SCHEME_CALLBACK (set_springs, (SCM));
- static bool has_interface (Grob *);
-};
-
-/*
- Return whether COL is fixed to its neighbors by some kind of spacing
- constraint.
-
-
- If in doubt, then we're not loose; the spacing engine should space
- for it, risking suboptimal spacing.
-
- (Otherwise, we might risk core dumps, and other weird stuff.)
-*/
-static bool
-loose_column (Grob *l, Grob *c, Grob *r)
-{
- extract_grob_set (c, "right-neighbors", rns);
- extract_grob_set (c, "left-neighbors", lns);
-
- /*
- If this column doesn't have a proper neighbor, we should really
- make it loose, but spacing it correctly is more than we can
- currently can handle.
-
- (this happens in the following situation:
-
- |
- | clef G
- *
-
- | | ||
- | | ||
- O O ||
-
-
- the column containing the clef is really loose, and should be
- attached right to the first column, but that is a lot of work for
- such a borderline case.)
-
- */
- if (lns.is_empty () || rns.is_empty ())
- return false;
-
- Item *l_neighbor = dynamic_cast<Item *> (lns[0]);
- Item *r_neighbor = dynamic_cast<Item *> (rns[0]);
-
- if (!l_neighbor || !r_neighbor)
- return false;
-
- l_neighbor = l_neighbor->get_column ();
- r_neighbor = dynamic_cast<Item *> (Note_spacing::right_column (r_neighbor));
-
- if (l == l_neighbor && r == r_neighbor)
- return false;
-
- if (!l_neighbor || !r_neighbor)
- return false;
-
- /*
- Only declare loose if the bounds make a little sense. This means
- some cases (two isolated, consecutive clef changes) won't be
- nicely folded, but hey, then don't do that.
- */
- if (! ((Paper_column::is_musical (l_neighbor) || Item::is_breakable (l_neighbor))
- && (Paper_column::is_musical (r_neighbor) || Item::is_breakable (r_neighbor))))
- {
- return false;
- }
-
- /*
- A rather hairy check, but we really only want to move around
- clefs. (anything else?)
-
- in any case, we don't want to move bar lines.
- */
- extract_grob_set (c, "elements", elts);
- for (int i = elts.size (); i--; )
- {
- Grob *g = elts[i];
- if (g && Break_align_interface::has_interface (g))
- {
- extract_grob_set (g, "elements", gelts);
- for (int j = gelts.size (); j--; )
- {
- Grob *h = gelts[j];
-
- /*
- ugh. -- fix staff-bar name?
- */
- if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar"))
- return false;
- }
- }
- }