Index: lily/cluster-engraver.cc =================================================================== RCS file: /cvsroot/lilypond/lilypond/lily/cluster-engraver.cc,v retrieving revision 1.1 diff -u -r1.1 cluster-engraver.cc --- lily/cluster-engraver.cc 13 Nov 2002 00:53:03 -0000 1.1 +++ lily/cluster-engraver.cc 18 Nov 2002 23:21:53 -0000 @@ -8,6 +8,7 @@ #include "item.hh" #include "spanner.hh" #include "note-head.hh" +#include "protected-scm.hh" #include "warn.hh" class Cluster_engraver : public Engraver @@ -23,9 +24,9 @@ private: Drul_array reqs_drul_; - Pitch pitch_min, pitch_max; - Spanner *cluster; - SCM columns_scm; + Pitch pitch_min_, pitch_max_; + Spanner *cluster_; + SCM columns_scm_; }; void reset_min_max (Pitch *pitch_min, Pitch *pitch_max) @@ -40,8 +41,8 @@ Cluster_engraver::Cluster_engraver () { - cluster = 0; - columns_scm = SCM_EOL; + cluster_ = 0; + columns_scm_ = SCM_EOL; reqs_drul_[LEFT] = reqs_drul_[RIGHT] = 0; } @@ -52,11 +53,11 @@ { reqs_drul_[START] = 0; reqs_drul_[STOP] = 0; - if (cluster) + if (cluster_) { - cluster->suicide (); - cluster = 0; - columns_scm = SCM_EOL; + cluster_->suicide (); + cluster_ = 0; + columns_scm_ = SCM_EOL; } } else if (m->is_mus_type ("cluster-event")) @@ -73,35 +74,30 @@ { if (reqs_drul_[STOP]) { - if (!cluster) + if (!cluster_) { reqs_drul_[STOP]->origin ()->warning ("can't find start of cluster"); } else { Grob *bound = unsmob_grob (get_property ("currentMusicalColumn")); - cluster->set_bound (RIGHT, bound); - cluster->set_grob_property ("segments", columns_scm); - typeset_grob (cluster); - cluster = 0; - columns_scm = SCM_EOL; + cluster_->set_bound (RIGHT, bound); } - reqs_drul_[STOP] = 0; } if (reqs_drul_[START]) { - if (cluster) + if (cluster_) { reqs_drul_[START]->origin ()->warning ("may not nest clusters"); } else { SCM basicProperties = get_property ("Cluster"); - cluster = new Spanner (basicProperties); - columns_scm = SCM_EOL; + cluster_ = new Spanner (basicProperties); + columns_scm_ = SCM_EOL; Grob *bound = unsmob_grob (get_property ("currentMusicalColumn")); - cluster->set_bound (LEFT, bound); - announce_grob (cluster, bound->self_scm ()); + cluster_->set_bound (LEFT, bound); + announce_grob (cluster_, bound->self_scm ()); } reqs_drul_[START] = 0; } @@ -110,40 +106,55 @@ void Cluster_engraver::start_translation_timestep () { - reset_min_max (&pitch_min, &pitch_max); + reset_min_max (&pitch_min_, &pitch_max_); } void Cluster_engraver::stop_translation_timestep () { - if (cluster) + if (cluster_) { SCM column_scm = get_property ("currentMusicalColumn"); if (column_scm == SCM_EOL) { programming_error("failed retrieving current column"); - return; - } - - if (Pitch::compare (pitch_min, pitch_max) <= 0) - { - int staff_position = pitch_min.steps (); - SCM c0 = get_property ("centralCPosition"); - if (gh_number_p (c0)) - staff_position += gh_scm2int (c0); - SCM segment = scm_list_n (column_scm, - gh_int2scm (staff_position), - pitch_min.smobbed_copy (), - pitch_max.smobbed_copy (), - SCM_UNDEFINED); - segment = scm_list_n (segment, SCM_UNDEFINED); - columns_scm = (columns_scm != SCM_EOL) ? - gh_append2 (columns_scm, segment) : segment; } else { - /* This timestep is caused by a different voice of the same - staff and hence should be ignored. */ + if (Pitch::compare (pitch_min_, pitch_max_) <= 0) + { + Real y_bottom = 0.5 * pitch_min_.steps (); + SCM c0 = get_property ("centralCPosition"); + if (gh_number_p (c0)) + y_bottom += 0.5 * gh_scm2int (c0); + else + programming_error ("Cluster_engraver: failed evaluating c0"); + Real y_top = y_bottom + + 0.5 * (pitch_max_.steps () - pitch_min_.steps ()); + column_scm = Protected_scm (column_scm); + SCM segment = scm_list_n (column_scm, + gh_double2scm (y_bottom), + gh_double2scm (y_top), + SCM_UNDEFINED); + segment = scm_list_n (segment, SCM_UNDEFINED); + columns_scm_ = (columns_scm_ != SCM_EOL) ? + gh_append2 (columns_scm_, segment) : segment; + cluster_->set_grob_property ("segments", columns_scm_); // Urrgh! + } + else + { + /* This timestep is caused by a different voice of the + same staff and hence should be ignored. */ + } + } + + if (reqs_drul_[STOP]) + { + reqs_drul_[STOP] = 0; + cluster_->set_grob_property ("segments", columns_scm_); + typeset_grob (cluster_); + cluster_ = 0; + columns_scm_ = SCM_EOL; } } } @@ -160,19 +171,19 @@ if (nr && nr->is_mus_type ("note-event")) { Pitch pitch = *unsmob_pitch (nr->get_mus_property ("pitch")); - if (Pitch::compare (pitch_min, pitch_max) > 0) // already init'd? + if (Pitch::compare (pitch_min_, pitch_max_) > 0) // already init'd? { // not yet init'd; use current pitch to init min/max - pitch_min = pitch; - pitch_max = pitch; + pitch_min_ = pitch; + pitch_max_ = pitch; } - else if (Pitch::compare (pitch, pitch_max) > 0) // new max? + else if (Pitch::compare (pitch, pitch_max_) > 0) // new max? { - pitch_max = pitch; + pitch_max_ = pitch; } - else if (Pitch::compare (pitch, pitch_min) < 0) // new min? + else if (Pitch::compare (pitch, pitch_min_) < 0) // new min? { - pitch_min = pitch; + pitch_min_ = pitch; } } } Index: lily/cluster.cc =================================================================== RCS file: /cvsroot/lilypond/lilypond/lily/cluster.cc,v retrieving revision 1.2 diff -u -r1.2 cluster.cc --- lily/cluster.cc 14 Nov 2002 09:09:07 -0000 1.2 +++ lily/cluster.cc 18 Nov 2002 23:21:53 -0000 @@ -132,10 +132,11 @@ Grob *me = unsmob_grob (smob); Spanner *spanner = dynamic_cast (me); - if (!spanner) { - me->programming_error ("Cluster::brew_molecule(): not a spanner"); - return SCM_EOL; - } + if (!spanner) + { + me->programming_error ("Cluster::brew_molecule(): not a spanner"); + return SCM_EOL; + } Item *left_bound = spanner->get_bound (LEFT); Item *right_bound = spanner->get_bound (RIGHT); @@ -149,7 +150,15 @@ bottom_points.clear (); top_points.clear (); SCM column_scm = SCM_EOL; - for (SCM columns_scm = me->get_grob_property ("segments"); + + SCM columns_scm = me->get_grob_property ("segments"); + if (columns_scm == SCM_EOL) + { + me->warning ("junking empty cluster"); + return SCM_EOL; + } + + for (; columns_scm != SCM_EOL; columns_scm = ly_cdr (columns_scm)) { column_scm = ly_car (columns_scm); @@ -162,31 +171,26 @@ break; // ok, we have seen all columns column = unsmob_grob (col_scm); column_scm = ly_cdr (column_scm); - Real y = 0.5 * gh_scm2double (ly_car (column_scm)); - column_scm = ly_cdr (column_scm); - Pitch *pitch_min = unsmob_pitch (ly_car (column_scm)); + Real y_bottom = gh_scm2double (ly_car (column_scm)); column_scm = ly_cdr (column_scm); - Pitch *pitch_max = unsmob_pitch (ly_car (column_scm)); - Real height = 0.5 * (pitch_max->steps () - pitch_min->steps ()); + Real y_top = gh_scm2double (ly_car (column_scm)); Real x = column->relative_coordinate (common, X_AXIS); if (right_broken) x -= left_bound->relative_coordinate (common, X_AXIS); - bottom_points.push (Offset (x, y)); - top_points.push (Offset (x, y + height)); + bottom_points.push (Offset (x, y_bottom)); + top_points.push (Offset (x, y_top)); } if (right_broken) { - Real y = 0.5 * gh_scm2double (ly_car (column_scm)); + Real y_bottom = gh_scm2double (ly_car (column_scm)); column_scm = ly_cdr (column_scm); - Pitch *pitch_min = unsmob_pitch (ly_car (column_scm)); + Real y_top = gh_scm2double (ly_car (column_scm)); column_scm = ly_cdr (column_scm); - Pitch *pitch_max = unsmob_pitch (ly_car (column_scm)); - Real height = 0.5 * (pitch_max->steps () - pitch_min->steps ()); Real x = right_bound->relative_coordinate (common, X_AXIS) - left_bound->relative_coordinate (common, X_AXIS); - bottom_points.push (Offset (x, y)); - top_points.push (Offset (x, y + height)); + bottom_points.push (Offset (x, y_bottom)); + top_points.push (Offset (x, y_top)); } Molecule out = brew_cluster_piece (me, bottom_points, top_points); return out.smobbed_copy (); Index: lily/grob.cc =================================================================== RCS file: /cvsroot/lilypond/lilypond/lily/grob.cc,v retrieving revision 1.61 diff -u -r1.61 grob.cc --- lily/grob.cc 14 Nov 2002 09:09:07 -0000 1.61 +++ lily/grob.cc 18 Nov 2002 23:21:53 -0000 @@ -700,7 +700,7 @@ Grob::warning (String s)const { SCM cause = self_scm(); - while (cause != SCM_EOL && !unsmob_music (cause)) + while (cause != SCM_EOL && unsmob_music (cause)) { Grob * g = unsmob_grob (cause); cause = g->get_grob_property ("cause"); Index: lily/ligature-bracket-engraver.cc =================================================================== RCS file: /cvsroot/lilypond/lilypond/lily/ligature-bracket-engraver.cc,v retrieving revision 1.6 diff -u -r1.6 ligature-bracket-engraver.cc --- lily/ligature-bracket-engraver.cc 12 Nov 2002 20:47:41 -0000 1.6 +++ lily/ligature-bracket-engraver.cc 18 Nov 2002 23:21:53 -0000 @@ -7,6 +7,8 @@ */ #include "ligature-engraver.hh" +#include "note-column.hh" +#include "tuplet-bracket.hh" #include "spanner.hh" #include "warn.hh" @@ -14,6 +16,7 @@ { protected: virtual Spanner *create_ligature_spanner (); + virtual void acknowledge_grob (Grob_info); public: TRANSLATOR_DECLARATIONS(Ligature_bracket_engraver); @@ -33,10 +36,23 @@ return new Spanner (get_property ("LigatureBracket")); } +void +Ligature_bracket_engraver::acknowledge_grob (Grob_info info) +{ + if (ligature_) + { + if (Note_column::has_interface (info.grob_)) + { + Tuplet_bracket::add_column (ligature_, dynamic_cast (info.grob_)); + } + else Ligature_engraver::acknowledge_grob (info); + } +} + ENTER_DESCRIPTION(Ligature_bracket_engraver, /* descr */ "Handles Ligature_events by engraving Ligature brackets.", -/* creats*/ "LigatureBracket", +/* creats*/ "TupletBracket", /* accepts */ "ligature-event abort-event", -/* acks */ "ligature-head-interface rest-interface", +/* acks */ "ligature-head-interface rest-interface note-column-interface", /* reads */ "", /* write */ ""); Index: scm/grob-description.scm =================================================================== RCS file: /cvsroot/lilypond/lilypond/scm/grob-description.scm,v retrieving revision 1.149 diff -u -r1.149 grob-description.scm --- scm/grob-description.scm 14 Nov 2002 22:05:36 -0000 1.149 +++ scm/grob-description.scm 18 Nov 2002 23:21:53 -0000 @@ -444,11 +444,18 @@ (LigatureBracket . ( - (width . 0.75) - (height . 0.5) (ligature-primitive-callback . ,Note_head::brew_molecule) - (molecule-callback . ,Ligature_bracket::brew_molecule) - (meta . ((interfaces . (ligature-bracket-interface spanner-interface)))) + (direction . 1) + (gap . 0.0) + (padding . 2.0) + (thickness . 1.6) + (edge-widen . (0.0 . 0.0)) + (edge-height . (0.7 . 0.7)) + (shorten-pair . (-0.2 . -0.2)) + (before-line-breaking-callback . ,Tuplet_bracket::before_line_breaking) + (after-line-breaking-callback . ,Tuplet_bracket::after_line_breaking) + (molecule-callback . ,Tuplet_bracket::brew_molecule) + (meta . ((interfaces . (tuplet-bracket-interface spanner-interface)))) )) (LigatureHead