From: Han-Wen Nienhuys Date: Tue, 23 Jul 2002 17:48:34 +0000 (+0000) Subject: * lily/accidental-placement.cc (split_accidentals): new function X-Git-Tag: release/1.5.70~51 X-Git-Url: https://git.donarmstrong.com/?p=lilypond.git;a=commitdiff_plain;h=ce62ceaa3f635693b541a97de1eced86fab4c0f7 * lily/accidental-placement.cc (split_accidentals): new function (get_relevant_accidental_extent): new function * lily/staff-spacing.cc (next_note_correction): idem * lily/separating-group-spanner.cc (find_rods): use conditional_width(). --- diff --git a/ChangeLog b/ChangeLog index 98b7decd51..089154d867 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2002-07-23 Han-Wen + * lily/accidental-placement.cc (split_accidentals): new function + (get_relevant_accidental_extent): new function + + * lily/staff-spacing.cc (next_note_correction): idem + + * lily/separating-group-spanner.cc (find_rods): use conditional_width(). + * scm/sketch.scm: fix roundfilledbox definition * lily/lily-guile.cc (robust_list_ref): be sensible with negative diff --git a/ROADMAP b/ROADMAP index dba4f013b4..78a3330537 100644 --- a/ROADMAP +++ b/ROADMAP @@ -1,5 +1,5 @@ -LilyPond development is hosted at savannah.gnu.org/projects/lilypond +LilyPond development is hosted at http://savannah.gnu.org/projects/lilypond Here is an attempt at a simple explanation of the directory layout for LilyPond's source files. diff --git a/lily/accidental-placement.cc b/lily/accidental-placement.cc index eae952d0eb..c05932ecee 100644 --- a/lily/accidental-placement.cc +++ b/lily/accidental-placement.cc @@ -20,6 +20,9 @@ source file of the GNU LilyPond music typesetter #include "note-collision.hh" #include "accidental-interface.hh" +/* + Hmm. why not group-extent? + */ MAKE_SCHEME_CALLBACK(Accidental_placement,extent_callback, 2); SCM Accidental_placement::extent_callback(SCM s, SCM axis) @@ -86,6 +89,64 @@ Accidental_placement::add_accidental (Grob* me, Grob* a) me->set_grob_property ("accidentals", accs); } +/* + Split into break reminders. + */ +void +Accidental_placement::split_accidentals (Grob * accs, + Link_array *break_reminder, + Link_array *real_acc) +{ + for (SCM acs =accs->get_grob_property ("accidentals"); gh_pair_p (acs); + acs =gh_cdr (acs)) + for (SCM s = gh_cdar (acs); gh_pair_p (s); s = gh_cdr (s)) + { + Grob *a = unsmob_grob (gh_car (s)); + + if (unsmob_grob (a->get_grob_property ("tie"))) + break_reminder->push (a); + else + real_acc->push (a); + } +} + +/* + Accidentals are special, because they appear and disappear before + and after ties at will. +*/ +Interval +Accidental_placement::get_relevant_accidental_extent (Grob *me, + Item *item_col, + Grob *left_object) +{ + Link_array br, ra; + Link_array *which = 0; + + Accidental_placement::split_accidentals (me, &br, &ra); + br.concat (ra); + + if (dynamic_cast(left_object)->break_status_dir () == RIGHT) + which = & br; + else + which = & ra; + + Interval extent; + for (int i = 0; i < which->size(); i++) + { + extent.unite (which->elem(i)->extent (item_col, X_AXIS)); + } + + if (!extent.empty_b()) + { + Real p = gh_scm2double (me->get_grob_property ("left-padding")); + extent[LEFT] -= p; + } + + return extent; +} + + + struct Accidental_placement_entry { Array left_skyline_; diff --git a/lily/include/accidental-placement.hh b/lily/include/accidental-placement.hh index 5b59783ff0..178075384e 100644 --- a/lily/include/accidental-placement.hh +++ b/lily/include/accidental-placement.hh @@ -19,6 +19,12 @@ public: DECLARE_SCHEME_CALLBACK (extent_callback, (SCM element, SCM axis)); static void add_accidental (Grob *,Grob* ); + static Interval get_relevant_accidental_extent (Grob *me, + Item *item_col, + Grob *acc); + static void split_accidentals (Grob * accs, + Link_array *break_reminder, + Link_array *real_acc); static SCM position_accidentals (Grob* ); static bool has_interface (Grob*); diff --git a/lily/include/separation-item.hh b/lily/include/separation-item.hh index bca937d454..266f8ef8f3 100644 --- a/lily/include/separation-item.hh +++ b/lily/include/separation-item.hh @@ -15,8 +15,11 @@ struct Separation_item { static bool has_interface (Grob*); - static Interval my_width (Grob*) ; + static Interval conditional_width (Grob*,Grob*) ; + static Interval width (Grob*) ; + static void add_item (Grob*,Item*); + static void add_conditional_item (Grob*,Grob*); }; #endif /* SINGLE_MALT_GROUPING_ITEM_HH */ diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index afd1a0962f..8d2ac6e0a7 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -17,7 +17,7 @@ #include "stem.hh" #include "separation-item.hh" #include "staff-spacing.hh" - +#include "accidental-placement.hh" void Note_spacing::get_spacing (Grob *me, Item* right_col, @@ -55,7 +55,7 @@ Note_spacing::get_spacing (Grob *me, Item* right_col, if (Separation_item::has_interface (it)) { - extents[d].unite (Separation_item::my_width (it)); + extents[d].unite (Separation_item::width (it)); continue; } @@ -78,7 +78,12 @@ Note_spacing::get_spacing (Grob *me, Item* right_col, accs = Note_column::accidentals (it->get_parent (X_AXIS)); if (accs) - extents[d].unite (accs->extent (it_col, X_AXIS)); + { + Interval v = + Accidental_placement::get_relevant_accidental_extent (accs, it_col, me); + + extents[d].unite (v); + } } } diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index db22eaa86e..f4471530bf 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -17,9 +17,6 @@ void Separating_group_spanner::find_rods (Item * r, SCM next) { - Interval ri (Separation_item::my_width (r)); - if (ri.empty_b ()) - return; /* This is an inner loop, however, in most cases, the interesting L @@ -32,9 +29,9 @@ Separating_group_spanner::find_rods (Item * r, SCM next) if (lb) { - Interval li (Separation_item::my_width (lb)); - - if (!li.empty_b ()) + Interval li (Separation_item::width (lb)); + Interval ri (Separation_item::conditional_width (r, lb)); + if (!li.empty_b () && !ri.empty_b()) { Rod rod; @@ -48,8 +45,9 @@ Separating_group_spanner::find_rods (Item * r, SCM next) } } - Interval li (Separation_item::my_width (l)); - if (!li.empty_b ()) + Interval li (Separation_item::width (l)); + Interval ri (Separation_item::conditional_width (r, l)); + if (!li.empty_b () && !ri.empty_b()) { Rod rod; diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index b21c434e67..4973fb3bd4 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -15,6 +15,7 @@ #include "axis-group-interface.hh" #include "note-spacing.hh" #include "group-interface.hh" +#include "accidental-placement.hh" struct Spacings { @@ -108,7 +109,6 @@ Separating_line_group_engraver::acknowledge_grob (Grob_info i) ->has_extent_callback_b(Axis_group_interface::group_extent_callback_proc, X_AXIS)) return; - if (to_boolean (it->get_grob_property ("no-spacing-rods"))) return ; @@ -156,7 +156,10 @@ Separating_line_group_engraver::acknowledge_grob (Grob_info i) } } - Separation_item::add_item (p_ref_,it); + if (Accidental_placement::has_interface (it)) + Separation_item::add_conditional_item (p_ref_, it); + else + Separation_item::add_item (p_ref_,it); } void diff --git a/lily/separation-item.cc b/lily/separation-item.cc index 49467607be..f85866f4c8 100644 --- a/lily/separation-item.cc +++ b/lily/separation-item.cc @@ -11,7 +11,7 @@ #include "paper-column.hh" #include "warn.hh" #include "group-interface.hh" - +#include "accidental-placement.hh" void Separation_item::add_item (Grob*s,Item* i) @@ -21,14 +21,65 @@ Separation_item::add_item (Grob*s,Item* i) s->add_dependency (i); } -/* - DOCME: +void +Separation_item::add_conditional_item (Grob* me , Grob *e) +{ + Pointer_group_interface::add_grob (me, ly_symbol2scm ("conditional-elements"), e); +} - why don't we use extent() - */ Interval -Separation_item::my_width (Grob *me) +Separation_item::conditional_width (Grob * me, Grob * left) { + Interval w = width (me); + + Item *item = dynamic_cast (me); + Paper_column * pc = item->column_l (); + + + for (SCM s = me->get_grob_property ("conditional-elements"); gh_pair_p (s); s = ly_cdr (s)) + { + SCM elt = ly_car (s); + if (!unsmob_grob (elt)) + continue; + + Item *il = unsmob_item (elt); + if (pc != il->column_l ()) + { + /* this shouldn't happen, but let's continue anyway. */ + programming_error (_ ("Separation_item: I've been drinking too much")); + continue; /*UGH UGH*/ + } + + if (to_boolean (il->get_grob_property ("no-spacing-rods"))) + { + continue; + } + + if (Accidental_placement::has_interface (il)) + { + w.unite (Accidental_placement::get_relevant_accidental_extent (il, pc, left)); + } + } + + SCM pad = me->get_grob_property ("padding"); + + if (gh_number_p (pad)) + { + w[RIGHT] += gh_scm2double (pad)/2; + w[LEFT] -= gh_scm2double (pad)/2; + } + return w; +} + +Interval +Separation_item::width (Grob *me) +{ + SCM sw = me->get_grob_property ("extent-X"); + if (ly_number_pair_p (sw)) + { + return ly_scm2interval (sw); + } + Item *item = dynamic_cast (me); Paper_column * pc = item->column_l (); Interval w; @@ -66,6 +117,10 @@ Separation_item::my_width (Grob *me) w[RIGHT] += gh_scm2double (pad)/2; w[LEFT] -= gh_scm2double (pad)/2; } + + + me->set_grob_property ("extent-X", ly_interval2scm (w)); + return w; // add this->offset_ ? this-> relative_coordinate ()? @@ -82,4 +137,4 @@ Calc dimensions for the Separating_group_spanner; this has to be an item to get dependencies correct. It can't be an grob_group since these usually are in a different X_group ", - "elements"); + "extent-X conditional-elements elements"); diff --git a/lily/staff-spacing.cc b/lily/staff-spacing.cc index 011c2b228a..81bc06000d 100644 --- a/lily/staff-spacing.cc +++ b/lily/staff-spacing.cc @@ -18,6 +18,7 @@ #include "staff-symbol-referencer.hh" #include "note-column.hh" #include "stem.hh" +#include "accidental-placement.hh" /* Insert some more space for the next note, in case it has a stem in @@ -40,7 +41,10 @@ Staff_spacing::next_note_correction (Grob * me, */ if (Grob * a = Note_column::accidentals (g)) { - max_corr = max_corr >? (- a->extent (col, X_AXIS)[LEFT]); + Interval v= Accidental_placement::get_relevant_accidental_extent + (a, col, me); + + max_corr = max_corr >? (- v[LEFT]); } if (Grob* a = unsmob_grob (g->get_grob_property ("arpeggio"))) { diff --git a/scm/grob-description.scm b/scm/grob-description.scm index 3296cea3b0..3782c13472 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -22,7 +22,7 @@ )) (AccidentalPlacement . ( - (X-extent-callback . ,Accidental_placement::extent_callback) + (X-extent-callback . ,Axis_group_interface::group_extent_callback) (left-padding . 0.3) (right-padding . 0.3) (meta . ((interfaces . (item-interface accidental-placement-interface)))) diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index 27aca00c77..e2e8c83667 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -140,6 +140,7 @@ square of the inner notes involved.") (grob-property-description 'collapse-height number? "Minimum height of system start delimiter. If equal or smaller, the bracket is removed.") (grob-property-description 'columns grob-list? "list of grobs, typically containing paper-columns.") +(grob-property-description 'conditional-elements grob-list? "Internal use only") (grob-property-description 'control-points list? "List of 4 offsets (number-pairs) that form control points for the tie/slur shape.") (grob-property-description 'damping integer? "amount of beam slope damping should beam slope be damped? 0: no, 1: yes, 100000: horizontal beams .") (grob-property-description 'dash-length number? "the length of a dash.") @@ -177,6 +178,7 @@ mean centre distance weighted per note (grob-property-description 'expand-limit integer? "maximum number of measures expanded in church rests.") (grob-property-description 'extra-extent-X number-pair? "enlarge in X dimension by this much, measured in staff space.") (grob-property-description 'extra-extent-Y number-pair? "see @code{extra-extent-Y}.") +(grob-property-description 'extent-X number-pair? "Store extent. internal use only. ") (grob-property-description 'extra-offset number-pair? "pair of reals (a cons) forcing an extra offset before outputting. @code{extra-offset} is added just before `printing' the grob, so the @@ -304,7 +306,7 @@ taking grob as argument, returning a smobbed Molecule. All visible, i.e. non-transparent, grobs have a callback to create a Molecule. The callback should be a Scheme function taking one argument (the grob) and returning a Molecule. Most molecule callbacks are -written in C++, but you can also write them in Scheme. An example is +written in C++, but you can also write them in Scheme. An examlily/lilypond/ple is provided in @code{input/regression/molecule-hacking.ly}. ")