From: Joe Neeman Date: Tue, 12 Dec 2006 15:42:19 +0000 (+0200) Subject: Set horizon_padding by default for tie formatting, vertical staff distance X-Git-Tag: release/2.11.3-1~32^2~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=424dee2dd114c4b69c3b58d2ef61e310e5d492f8;p=lilypond.git Set horizon_padding by default for tie formatting, vertical staff distance and separation-item spacing. Make it per-grob configurable for grobs with outside-staff-priority. --- diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 44293f6d54..5eebdf2b89 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -314,6 +314,8 @@ 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)); + SCM horizon_padding_scm = elements[i]->get_property ("outside-staff-horizontal-padding"); + Real horizon_padding = robust_scm2double (horizon_padding_scm, 0.0); 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 ())); @@ -322,7 +324,7 @@ Axis_group_interface::skyline_spacing (Grob *me, vector elements) boxes.clear (); boxes.push_back (b); - Skyline other = Skyline (boxes, 0, X_AXIS, -dir); + Skyline other = Skyline (boxes, horizon_padding, X_AXIS, -dir); Real padding = robust_scm2double (elements[i]->get_property ("outside-staff-padding"), 0.5); Real dist = skylines[dir].distance (other) + padding; diff --git a/lily/grob.cc b/lily/grob.cc index 3ff7b5df46..139a387989 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -623,6 +623,7 @@ ADD_INTERFACE (Grob, "meta " "minimum-X-extent " "minimum-Y-extent " + "outside-staff-horizontal-padding " "outside-staff-padding " "outside-staff-priority " "rotation " diff --git a/lily/separation-item.cc b/lily/separation-item.cc index a07668d13b..20de8fbbd5 100644 --- a/lily/separation-item.cc +++ b/lily/separation-item.cc @@ -128,7 +128,8 @@ Separation_item::calc_skylines (SCM smob) vector bs = boxes (me); do { - Skyline l (bs, 0, Y_AXIS, d); + /* todo: the horizon_padding is somewhat arbitrary */ + Skyline l (bs, 0.1, Y_AXIS, d); index_set_cell (lines, d, l.smobbed_copy ()); } while (flip (&d) != LEFT); @@ -161,7 +162,6 @@ Separation_item::boxes (Grob *me) continue; Interval y (il->pure_height (ycommon, 0, very_large)); - y.widen (0.1); // fixme Box b (il->extent (pc, X_AXIS), y); out.push_back (b); diff --git a/lily/skyline.cc b/lily/skyline.cc index 6c3caab69e..ab877f28ce 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -12,12 +12,12 @@ /* A skyline is a sequence of non-overlapping buildings: something like this: _______ - / \ ________ - / \ ________/ \ - /\ / \ / \ - / -----/ \ / \ - / \ / \ - / ------------/ ---- + | \ ________ + | \ ________/ \ + /\ | \ / \ + / -------- \ / \ + / \ / \ + / ------------/ ---- -- Each building has a starting position, and ending position, a starting height and an ending height. @@ -259,13 +259,13 @@ single_skyline (Building b, Real horizon_padding, list *const ret) if (!isinf (b.iv_[RIGHT])) ret->push_front (Building (b.iv_[RIGHT], -infinity_f, -infinity_f, infinity_f)); - if (horizon_padding > 0) + if (horizon_padding > 0 && !isinf (b.iv_.length ())) ret->push_front (b.sloped_neighbour (horizon_padding, RIGHT)); if (b.iv_[RIGHT] > b.iv_[LEFT]) ret->push_front (b); - if (horizon_padding > 0) + if (horizon_padding > 0 && !isinf (b.iv_.length ())) ret->push_front (b.sloped_neighbour (horizon_padding, LEFT)); if (!isinf (b.iv_[LEFT])) ret->push_front (Building (-infinity_f, -infinity_f, @@ -350,7 +350,7 @@ Skyline::Skyline (vector const &boxes, Real horizon_padding, Axis horizon_a iv.widen (EPS); Building front = Building (iv[LEFT], height, height, iv[RIGHT]); bldgs.push_front (front); - if (horizon_padding > 0) + if (horizon_padding > 0 && !isinf (front.iv_.length ())) { bldgs.push_front (front.sloped_neighbour (horizon_padding, LEFT)); bldgs.push_front (front.sloped_neighbour (horizon_padding, RIGHT)); diff --git a/lily/system.cc b/lily/system.cc index 8f375a8db8..90eb463c44 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -532,8 +532,10 @@ System::build_skylines () boxes.push_back (Box (xiv, yiv)); } - skylines_[UP] = Skyline (boxes, 0, X_AXIS, UP); - skylines_[DOWN] = Skyline (boxes, 0, X_AXIS, DOWN); + SCM horizon_padding_scm = get_property ("skyline-horizontal-padding"); + Real horizon_padding = robust_scm2double (horizon_padding_scm, 0); + skylines_[UP] = Skyline (boxes, horizon_padding, X_AXIS, UP); + skylines_[DOWN] = Skyline (boxes, horizon_padding, X_AXIS, DOWN); } @@ -547,4 +549,5 @@ ADD_INTERFACE (System, "pure-Y-extent " "spaceable-staves " "skyline-distance " + "skyline-horizontal-padding " ) diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc index 3937c5194e..a55f313735 100644 --- a/lily/tie-formatting-problem.cc +++ b/lily/tie-formatting-problem.cc @@ -174,8 +174,9 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, boxes.push_back (Box (x, y)); } while (flip (&updowndir) != DOWN); - - chord_outlines_[key] = Skyline (boxes, 0, Y_AXIS, -dir); + + /* todo: the horizon_padding is somewhat arbitrary */ + chord_outlines_[key] = Skyline (boxes, 0.1, Y_AXIS, -dir); if (bounds[0]->break_status_dir ()) { Real x = robust_relative_extent (bounds[0], x_refpoint_, X_AXIS)[-dir]; diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 24f1fe0a2b..d0364bf495 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -275,6 +275,9 @@ 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-horizontal-padding ,number? "By default, an outside-staff-object can be +placed so that is it very close to another grob horizontally. If this property is set, +the outside-staff-object will be raised so that it is not so close to its neighbour.") (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 @@ -558,6 +561,7 @@ than a whole rest.") (spaceable-staves ,ly:grob-array? "Objects to be spaced during page layout.") (skyline-distance ,number? "The distance between this staff and the next one, as determined by a skyline algorithm.") + (skyline-horizontal-padding ,number? "For determining the vertical distance between 2 staves, it is possible to have a configuration which would result in a tight interleaving of grobs from the top staff and the bottom staff. The larger this parameter is, the farther apart the staves will be placed in such a configuration.") (skyline-spacing ,boolean? "When true, this axis-group will vertically space its children using a skyline algorithm.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 4f5f9a6f51..a9dd4edfbc 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1657,6 +1657,7 @@ (X-extent . ,ly:axis-group-interface::width) (Y-extent . ,ly:axis-group-interface::height) (skyline-spacing . #t) + (skyline-horizontal-padding . 1.0) (meta . ((class . System) (interfaces . (system-interface axis-group-interface))))))