summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Neeman <joeneeman@gmail.com>2007-09-25 07:32:43 +1000
committerJoe Neeman <joeneeman@gmail.com>2007-09-25 16:58:38 +1000
commitb51d7ad0977e9f43915fff9e2313a150c8a44c77 (patch)
treeb8cb7a2a1a6fb29d976aa6fad7f408069a1491c5
parent9ffc3569ba5f2a5bd13f2920b135f28066a60e97 (diff)
Fix 464.
Center a multimeasure rest between BreakAlignments, not according to the extent of the columns.
-rw-r--r--input/regression/multi-measure-rest-center2.ly13
-rw-r--r--lily/include/multi-measure-rest.hh1
-rw-r--r--lily/include/paper-column.hh1
-rw-r--r--lily/multi-measure-rest.cc46
-rw-r--r--lily/paper-column.cc18
5 files changed, 54 insertions, 25 deletions
diff --git a/input/regression/multi-measure-rest-center2.ly b/input/regression/multi-measure-rest-center2.ly
new file mode 100644
index 0000000000..71fb64b696
--- /dev/null
+++ b/input/regression/multi-measure-rest-center2.ly
@@ -0,0 +1,13 @@
+\version "2.11.32"
+
+\header
+{
+ texidoc = "The existence of a text mark does not affect the placement of a multimeasure rest."
+}
+
+\paper{ ragged-right=##t }
+
+\relative g' {
+ \mark \markup{ "foo foo foo foo foo foo"}
+ R1 | g4 g g g |
+}
diff --git a/lily/include/multi-measure-rest.hh b/lily/include/multi-measure-rest.hh
index 554a328b6e..966741aaef 100644
--- a/lily/include/multi-measure-rest.hh
+++ b/lily/include/multi-measure-rest.hh
@@ -28,6 +28,7 @@ public:
static Stencil big_rest (Grob *, Real);
static Stencil symbol_stencil (Grob *, Real);
static Stencil church_rest (Grob *, Font_metric *, int, Real);
+ static Interval bar_width (Spanner *me);
};
#endif /* MULTI_MEASURE_REST_HH */
diff --git a/lily/include/paper-column.hh b/lily/include/paper-column.hh
index 9109e4e697..350ed4e635 100644
--- a/lily/include/paper-column.hh
+++ b/lily/include/paper-column.hh
@@ -49,6 +49,7 @@ public:
static bool is_used (Grob *);
static bool is_breakable (Grob *);
static Real minimum_distance (Grob *l, Grob *r);
+ static Interval break_align_width (Grob *me);
};
#endif // PAPER_COLUMN_HH
diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc
index 279f2d011f..8afc641439 100644
--- a/lily/multi-measure-rest.cc
+++ b/lily/multi-measure-rest.cc
@@ -16,11 +16,30 @@
#include "misc.hh"
#include "spanner.hh"
#include "staff-symbol-referencer.hh"
+#include "system.hh"
#include "text-interface.hh"
#include "percent-repeat-item.hh"
#include "lookup.hh"
#include "separation-item.hh"
+Interval
+Multi_measure_rest::bar_width (Spanner *me)
+{
+ Interval iv;
+ Direction d = LEFT;
+ do
+ {
+ Item *col = me->get_bound (d)->get_column ();
+
+ Interval coldim = Paper_column::break_align_width (col);
+
+ iv[d] = coldim[-d];
+ }
+ while ((flip (&d)) != LEFT);
+
+ return iv;
+}
+
MAKE_SCHEME_CALLBACK (Multi_measure_rest, percent, 1);
SCM
Multi_measure_rest::percent (SCM smob)
@@ -34,17 +53,7 @@ Multi_measure_rest::percent (SCM smob)
Grob *common_x = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT),
X_AXIS);
- Interval sp_iv;
- Direction d = LEFT;
- do
- {
- Item *col = sp->get_bound (d)->get_column ();
-
- Interval coldim = robust_relative_extent (col, common_x, X_AXIS);
-
- sp_iv[d] = coldim[-d];
- }
- while ((flip (&d)) != LEFT);
+ Interval sp_iv = bar_width (sp);
Real x_off = 0.0;
Real rx = sp->get_bound (LEFT)->relative_coordinate (common_x, X_AXIS);
@@ -71,20 +80,7 @@ Multi_measure_rest::print (SCM smob)
Grob *me = unsmob_grob (smob);
Spanner *sp = dynamic_cast<Spanner *> (me);
- Interval sp_iv;
- Direction d = LEFT;
-
- Grob *common = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
- do
- {
- Item *b = sp->get_bound (d);
-
- Interval coldim = b->extent (common, X_AXIS);
-
- sp_iv[d] = coldim.is_empty () ? b->relative_coordinate (common, X_AXIS) : coldim[-d];
- }
- while ((flip (&d)) != LEFT);
-
+ Interval sp_iv = bar_width (sp);
Real space = sp_iv.length ();
Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS);
diff --git a/lily/paper-column.cc b/lily/paper-column.cc
index 53dfd4a906..0cd8eda9d9 100644
--- a/lily/paper-column.cc
+++ b/lily/paper-column.cc
@@ -8,6 +8,7 @@
#include "paper-column.hh"
+#include "break-align-interface.hh"
#include "moment.hh"
#include "paper-score.hh"
#include "warn.hh"
@@ -157,6 +158,23 @@ Paper_column::minimum_distance (Grob *left, Grob *right)
return max (0.0, skys[LEFT].distance (skys[RIGHT]));
}
+Interval
+Paper_column::break_align_width (Grob *me)
+{
+ if (is_musical (me))
+ {
+ me->programming_error ("tried to get break-align-width of a non-musical column");
+ return Interval (0, 0);
+ }
+
+ Grob *align = Pointer_group_interface::find_grob (me, ly_symbol2scm ("elements"),
+ Break_alignment_interface::has_interface);
+ if (!align)
+ return Interval (0, 0);
+
+ return align->extent (me->get_parent (X_AXIS), X_AXIS);
+}
+
/*
Print a vertical line and the rank number, to aid debugging.
*/