diff options
author | Mike Solomon <mike@apollinemike.com> | 2011-04-05 16:55:28 -0400 |
---|---|---|
committer | Mike Solomon <mike@apollinemike.com> | 2011-04-05 16:55:28 -0400 |
commit | ec96fa3e252e98f3f540e9a0076510486c3a06d7 (patch) | |
tree | 8ff721ec3d6107e4009f248c70a9a08db9386074 | |
parent | 2e8af646c57285dc4946205ddab0257bc4ef6270 (diff) |
Allows users to opt out of beam collision on an interface by interface basis.
This is controlled by the property collision-interfaces, which is a list
of interfaces to which automatic collision resolution will be applied.
-rw-r--r-- | input/regression/beam-collision-off.ly | 32 | ||||
-rw-r--r-- | lily/beam-collision-engraver.cc | 20 | ||||
-rw-r--r-- | lily/beam.cc | 1 | ||||
-rw-r--r-- | scm/define-grob-properties.scm | 3 | ||||
-rw-r--r-- | scm/define-grobs.scm | 6 |
5 files changed, 60 insertions, 2 deletions
diff --git a/input/regression/beam-collision-off.ly b/input/regression/beam-collision-off.ly new file mode 100644 index 0000000000..b0a020fbc0 --- /dev/null +++ b/input/regression/beam-collision-off.ly @@ -0,0 +1,32 @@ +\version "2.13.47" +\header { + texidoc = "Beams can be allowed to collide with grobs by overriding +the collision-interfaces property." +} + +\relative c' { + c8 [ des' ] + \once \override Beam #'collision-interfaces = #'(beam-interface + clef-interface + ;inline-accidental-interface + key-signature-interface + note-head-interface + time-signature-interface) + c,8 [ des'! ] + c, [ \key des \major d ] + \once \override Beam #'collision-interfaces = #'(beam-interface + clef-interface + inline-accidental-interface + ;key-signature-interface + note-head-interface + time-signature-interface) + c [ \key c \major d ] + g [ \grace { a [ d ] } g, ] + \once \override Beam #'collision-interfaces = #'(;beam-interface + clef-interface + inline-accidental-interface + key-signature-interface + note-head-interface + time-signature-interface) + g [ \grace { a [ d ] } g, ] +} diff --git a/lily/beam-collision-engraver.cc b/lily/beam-collision-engraver.cc index a12311602c..5e9006f9b6 100644 --- a/lily/beam-collision-engraver.cc +++ b/lily/beam-collision-engraver.cc @@ -38,12 +38,29 @@ protected: virtual void finalize (); +private: + bool covered_grob_has_interface (Grob *covered_grob, Grob *beam); + public: TRANSLATOR_DECLARATIONS (Beam_collision_engraver); }; Beam_collision_engraver::Beam_collision_engraver () {} +bool +Beam_collision_engraver::covered_grob_has_interface (Grob *covered_grob, Grob *beam) +{ + SCM interfaces = beam->get_property ("collision-interfaces"); + + for (SCM l = interfaces; scm_is_pair (l); l = scm_cdr (l)) + { + if (covered_grob->internal_has_interface (scm_car (l))); + return true; + } + + return false; +} + void Beam_collision_engraver::finalize () { @@ -65,7 +82,8 @@ Beam_collision_engraver::finalize () for (vsize j = start; j < covered_grobs_.size (); j++) { Interval_t<int> covered_grob_spanned_rank = covered_grobs_[j]->spanned_rank_interval (); - if (covered_grob_spanned_rank[LEFT] > beam_spanned_rank_[RIGHT]) + if ((covered_grob_spanned_rank[LEFT] > beam_spanned_rank_[RIGHT] + || !covered_grob_has_interface (covered_grobs_[j], beams_[i]))) break; /* Only consider grobs whose end falls at or after the beam's beginning. diff --git a/lily/beam.cc b/lily/beam.cc index 6fbd71d7d6..6ae2ed4819 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -1818,6 +1818,7 @@ ADD_INTERFACE (Beam, "break-overshoot " "clip-edges " "concaveness " + "collision-interfaces " "covered-grobs " "damping " "details " diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 83b327413d..62d7cf070c 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -170,6 +170,8 @@ hairpins (al/del niente).") edges of beams?") (collapse-height ,ly:dimension? "Minimum height of system start delimiter. If equal or smaller, the bracket/brace/line is removed.") + (collision-interfaces ,list? "A list of interfaces for which +automatic beam-collision resolution is run.") (color ,color? "The color of this grob.") (common-shortest-duration ,ly:moment? "The most common shortest note length. This is used in spacing. Enlarging this sets the score @@ -184,7 +186,6 @@ this grob looks as a continued break.") control points for the tie, slur, or bracket shape. For B@'eziers, this should list the control points of a third-order B@'ezier curve.") - ;; ;; d ;; diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index ab2a87ae3f..8333674850 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -349,6 +349,12 @@ (beaming . ,ly:beam::calc-beaming) (clip-edges . #t) + (collision-interfaces . (beam-interface + clef-interface + inline-accidental-interface + key-signature-interface + note-head-interface + time-signature-interface)) (concaveness . ,ly:beam::calc-concaveness) (cross-staff . ,ly:beam::calc-cross-staff) (damping . 1) |