From 58ced4ee3e8b57d7bf32c25309501196af31c70a Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Fri, 1 Dec 2006 17:20:10 +0200 Subject: [PATCH] Add outside-staff-priority defaults for several grobs. Add outside-staff-padding. Fix outside-staff positioning for grobs whose parent is System. --- input/mutopia/W.A.Mozart/mozart-hrn-3.ly | 1 - lily/axis-group-interface.cc | 29 ++++++++++++++++++++---- scm/define-grob-properties.scm | 2 ++ scm/define-grobs.scm | 9 +++++++- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/input/mutopia/W.A.Mozart/mozart-hrn-3.ly b/input/mutopia/W.A.Mozart/mozart-hrn-3.ly index 9f1ae8ab57..1e7960dd22 100644 --- a/input/mutopia/W.A.Mozart/mozart-hrn-3.ly +++ b/input/mutopia/W.A.Mozart/mozart-hrn-3.ly @@ -49,7 +49,6 @@ virtuoso that taught in Geneva. \include "mozart-hrn3-rondo.ily" \paper { - between-system-padding = 0.0 between-system-space = 20 \mm } diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 2ede25493a..2f5ca17d12 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -269,6 +269,22 @@ staff_priority_less (Grob * const &g1, Grob * const &g2) return rank_1 < rank_2; } +static void +add_boxes (Grob *me, Grob *x_common, Grob *y_common, vector *const boxes) +{ + if (Axis_group_interface::has_interface (me) + && Axis_group_interface::has_axis (me, Y_AXIS)) + { + Grob_array *elements = unsmob_grob_array (me->get_object ("elements")); + if (elements) + for (vsize i = 0; i < elements->size (); i++) + add_boxes (elements->grob (i), x_common, y_common, boxes); + } + else + boxes->push_back (Box (me->extent (x_common, X_AXIS), + me->extent (y_common, Y_AXIS))); +} + void Axis_group_interface::skyline_spacing (Grob *me, vector elements) { @@ -281,9 +297,7 @@ Axis_group_interface::skyline_spacing (Grob *me, vector elements) for (i = 0; i < elements.size () && !scm_is_number (elements[i]->get_property ("outside-staff-priority")); i++) - boxes.push_back (Box (elements[i]->extent (x_common, X_AXIS), - elements[i]->extent (y_common, Y_AXIS))); - + add_boxes (elements[i], x_common, y_common, &boxes); Drul_array skylines (Skyline (boxes, X_AXIS, DOWN), Skyline (boxes, X_AXIS, UP)); @@ -298,10 +312,17 @@ Axis_group_interface::skyline_spacing (Grob *me, vector elements) Box b (elements[i]->extent (x_common, X_AXIS), elements[i]->extent (y_common, Y_AXIS)); + if (b[X_AXIS].is_empty () || b[Y_AXIS].is_empty ()) + { + warning (_f ("outside-staff object %s has an empty extent", elements[i]->name ().c_str ())); + continue; + } + boxes.clear (); boxes.push_back (b); Skyline other = Skyline (boxes, X_AXIS, -dir); - Real dist = skylines[dir].distance (other); + Real padding = robust_scm2double (elements[i]->get_property ("outside-staff-padding"), 0.5); + Real dist = skylines[dir].distance (other) + padding; if (dist > 0) { diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 5e9c175702..0081da0636 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -274,6 +274,8 @@ get stems extending to the middle staff line.") (non-musical ,boolean? "True if the grob belongs in a NonMusicalPaperColumn.") (number-type ,symbol? "Type of numbers to use in label. Choices include @code{roman-lower}, @code{roman-upper}, and @code{arabic}.") + (outside-staff-padding ,number? "The padding to place between this grob and the staff when +spacing according to outside-staff-priority.") (outside-staff-priority ,number? "When set, the grob will be positioned outside the staff in such a way as to avoid all collisions. In case of a potential collision, the grob with the smaller outside-staff-priority will be closer to the staff.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 3506ea0892..8916c63440 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -575,6 +575,7 @@ (minimum-space . 1.2) (direction . ,DOWN) (side-axis . ,Y) + (outside-staff-priority . 250) (Y-extent . ,ly:axis-group-interface::height) (X-extent . ,ly:axis-group-interface::width) (meta . ((class . Spanner) @@ -601,6 +602,7 @@ (avoid-slur . around) (no-spacing-rods . #t) (script-priority . 100) + (outside-staff-priority . 300) (meta . ((class . Item) (interfaces . (font-interface text-interface @@ -1156,6 +1158,7 @@ (dash-fraction . 0.3) (edge-height . (0 . 1.2)) (direction . ,UP) + (outside-staff-priority . 400) (meta . ((class . Spanner) (interfaces . (ottava-bracket-interface horizontal-bracket-interface @@ -1269,6 +1272,7 @@ (break-visibility . ,end-of-line-invisible) (break-align-symbol . staff-bar) (padding . 0.8) + (outside-staff-priority . 1000) (meta . ((class . Item) (interfaces . (text-interface side-position-interface @@ -1367,7 +1371,6 @@ (SeparationItem . ( (avoid-slur . inside) - (skylines . ,ly:separation-item::calc-skylines) (X-extent . ,ly:axis-group-interface::width) (Y-extent . ,ly:axis-group-interface::height) (meta . ((class . Item) @@ -1738,6 +1741,7 @@ (stencil . ,ly:text-interface::print) (direction . ,ly:script-interface::calc-direction) + (outside-staff-priority . 450) (avoid-slur . around) (slur-padding . 0.5) (script-priority . 200) @@ -1759,6 +1763,7 @@ (dash-period . 3.0) (side-axis . ,Y) (direction . ,UP) + (outside-staff-priority . 350) (meta . ((class . Spanner) (interfaces . (text-spanner-interface line-spanner-interface @@ -1835,6 +1840,7 @@ (direction . ,UP) (Y-offset . ,ly:side-position-interface::y-aligned-side) (side-axis . ,Y) + (outside-staff-priority . 50) (meta . ((class . Spanner) (interfaces . (text-spanner-interface line-spanner-interface @@ -1988,6 +1994,7 @@ (edge-height . (2.0 . 2.0)) ;; staff-space; (minimum-space . 5) (font-size . -4) + (outside-staff-priority . 100) (meta . ((class . Spanner) (interfaces . (volta-bracket-interface horizontal-bracket-interface -- 2.39.5