From: Han-Wen Nienhuys Date: Fri, 7 Oct 2005 10:43:36 +0000 (+0000) Subject: * lily/beam.cc (set_beaming): don't clip edges. X-Git-Tag: release/2.7.12~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4348b2762d1101d731add0c01bb77a9ce162efec;hp=95007e0bdb368a9eb77e241e9952cb3a8651633d;p=lilypond.git * lily/beam.cc (set_beaming): don't clip edges. (connect_beams): don't clip edges. * lily/beaming-info.cc (clip_edges): new function. * lily/enclosing-bracket.cc (struct Enclosing_bracket): new file. --- diff --git a/ChangeLog b/ChangeLog index 581aa1d5b1..2ad2da6790 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-10-07 Han-Wen Nienhuys + * lily/beam.cc (set_beaming): don't clip edges. + (connect_beams): don't clip edges. + + * lily/beaming-info.cc (clip_edges): new function. + * lily/enclosing-bracket.cc (struct Enclosing_bracket): new file. * Documentation/user/instrument-notation.itely (Figured bass): diff --git a/lily/beam.cc b/lily/beam.cc index d0fc280075..4c7d8b85ef 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -217,7 +217,9 @@ Beam::connect_beams (Grob *me) Slice last_int; last_int.set_empty (); - SCM last_beaming = SCM_EOL; + + // SCM last_beaming = SCM_EOL; + SCM last_beaming = scm_cons (SCM_EOL, scm_list_1 (scm_from_int (0))); Direction last_dir = CENTER; for (int i = 0; i < stems.size (); i++) { @@ -229,15 +231,13 @@ Beam::connect_beams (Grob *me) { int start_point = position_with_maximal_common_beams (last_beaming, this_beaming, - last_dir, this_dir); + last_dir ? last_dir : this_dir, + this_dir); Direction d = LEFT; Slice new_slice; do { - if (d == RIGHT && i == stems.size () - 1) - continue; - new_slice.set_empty (); SCM s = index_get_cell (this_beaming, d); for (; scm_is_pair (s); s = scm_cdr (s)) @@ -256,7 +256,6 @@ Beam::connect_beams (Grob *me) } else { - scm_set_car_x (this_beaming, SCM_EOL); SCM s = scm_cdr (this_beaming); for (; scm_is_pair (s); s = scm_cdr (s)) { @@ -265,10 +264,7 @@ Beam::connect_beams (Grob *me) last_int.add_point (np); } } - - if (i == stems.size () -1) - scm_set_cdr_x (this_beaming, SCM_EOL); - + if (scm_ilength (scm_cdr (this_beaming)) > 0) { last_beaming = this_beaming; @@ -444,16 +440,22 @@ Beam::print (SCM grob) if (i > 0) rw = min (nw_f, ((xposn - last_xposn) / 2)); else - rw = xposn - me->get_bound (LEFT)->extent (xcommon, X_AXIS)[RIGHT] - + break_overshoot[LEFT]; - + { + if (me->get_bound (LEFT)->break_status_dir ()) + rw = xposn - me->get_bound (LEFT)->extent (xcommon, X_AXIS)[RIGHT] + + break_overshoot[LEFT]; + else + rw = 1.0; // ugh. + } + if (stem) lw = min (nw_f, ((xposn - last_xposn) / 2)); else - lw = me->get_bound (RIGHT)->relative_coordinate (xcommon, X_AXIS) - - last_xposn - + break_overshoot[RIGHT]; - + { + lw = me->get_bound (RIGHT)->relative_coordinate (xcommon, X_AXIS) + - last_xposn + + break_overshoot[RIGHT]; + } rw += stem_width / 2; lw += last_stem_width / 2; @@ -1160,7 +1162,7 @@ Beam::set_stem_lengths (Grob *me) } void -Beam::set_beaming (Grob *me, Beaming_info_list *beaming) +Beam::set_beaming (Grob *me, Beaming_info_list const *beaming) { extract_grob_set (me, "stems", stems); @@ -1173,11 +1175,6 @@ Beam::set_beaming (Grob *me, Beaming_info_list *beaming) do { - /* Don't set beaming for outside of outer stems */ - if ((d == LEFT && i == 0) - || (d == RIGHT && i == stems.size () -1)) - continue; - Grob *stem = stems[i]; SCM beaming_prop = stem->get_property ("beaming"); if (beaming_prop == SCM_EOL diff --git a/lily/beaming-info.cc b/lily/beaming-info.cc index f71ce8cfb2..63f845489b 100644 --- a/lily/beaming-info.cc +++ b/lily/beaming-info.cc @@ -91,6 +91,8 @@ Beaming_info_list::beamify (Moment &beat_length, bool subdivide) infos_ = splits[LEFT].infos_; infos_.concat (splits[RIGHT].infos_); + + clip_edges (); } void @@ -98,3 +100,13 @@ Beaming_info_list::add_stem (Moment m, int b) { infos_.push (Beaming_info (m, b)); } + +void +Beaming_info_list::clip_edges () +{ + if (infos_.size ()) + { + infos_[0].beams_i_drul_[LEFT] = 0; + infos_.top().beams_i_drul_[RIGHT] = 0; + } +} diff --git a/lily/enclosing-bracket.cc b/lily/enclosing-bracket.cc new file mode 100644 index 0000000000..90b9211c63 --- /dev/null +++ b/lily/enclosing-bracket.cc @@ -0,0 +1,71 @@ +/* + enclosing-bracket.cc -- implement Enclosing_bracket + + source file of the GNU LilyPond music typesetter + + (c) 2005 Han-Wen Nienhuys + +*/ + +#include "stencil.hh" +#include "horizontal-bracket.hh" +#include "grob.hh" +#include "axis-group-interface.hh" +#include "pointer-group-interface.hh" + +struct Enclosing_bracket +{ + static bool has_interface (Grob*); + +public: + DECLARE_SCHEME_CALLBACK(print, (SCM)); +}; + + +ADD_INTERFACE(Enclosing_bracket, + "enclosing-bracket-interface", + "Brackets alongside bass figures.", + + /* props */ + "bracket-flare " + "shorten-pair " + "edge-height " + "padding " + "thickness " + "elements " + ); + +/* ugh: should make bracket interface. */ + + +MAKE_SCHEME_CALLBACK (Enclosing_bracket, print, 1); +SCM +Enclosing_bracket::print (SCM grob) +{ + Grob *me = unsmob_grob (grob); + extract_grob_set (me, "elements", elements); + if (elements.is_empty ()) + { + me->suicide (); + return SCM_EOL; + } + + Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS); + Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS); + + + Stencil left_br = Horizontal_bracket::make_bracket (me, me, elements, + Y_AXIS, LEFT); + Stencil right_br = Horizontal_bracket::make_bracket (me, me, elements, + Y_AXIS, RIGHT); + + xext.widen (robust_scm2double (me->get_property ("padding"), 0.25)); + left_br.translate_axis (xext[LEFT], X_AXIS); + right_br.translate_axis (xext[RIGHT], X_AXIS); + + left_br.add_stencil (right_br); + left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS); + + return left_br.smobbed_copy (); +} + diff --git a/lily/include/beam.hh b/lily/include/beam.hh index 120840cff4..3d9aa314bf 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -48,7 +48,7 @@ public: static bool has_interface (Grob *); static void add_stem (Grob *, Grob *); static bool is_knee (Grob *); - static void set_beaming (Grob *, Beaming_info_list *); + static void set_beaming (Grob *, Beaming_info_list const *); static void set_stemlens (Grob *); static int get_beam_count (Grob *me); static void position_beam (Grob *me); diff --git a/lily/include/beaming.hh b/lily/include/beaming.hh index 0200d55a68..b541691087 100644 --- a/lily/include/beaming.hh +++ b/lily/include/beaming.hh @@ -34,6 +34,7 @@ struct Beaming_info_list int best_splitpoint_index (Moment &beat_length, bool subdivide) const; void beamify (Moment &beat_length, bool subdivide); void add_stem (Moment d, int beams); + void clip_edges (); }; #endif /* BEAMING_HH */ diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 23c3322f1a..40ab72ddfa 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -218,7 +218,7 @@ . ((print-function . ,Enclosing_bracket::print) (edge-height . (0.2 . 0.2)) (meta . ((class . Item) - (interfaces . (figured-bass-bracket-interface)) )) + (interfaces . (enclosing-bracket-interface)) )) )) (BassFigureContinuation . (