The attached patch fixes the left end alignment of some broken
spanners (crescendo, decrescendo, slurs, ties, volta brackets), as
mentioned in my recent post. I did not succeed in creating a test case
for tuplet spanners, so this hasn't been changed.
What do you think about the patch?
--
michael krause [aka raw style / lego] - www.tu-harburg.de/~semk2104/
diff -urN lilypond-1.2.3/CHANGES lilypond-1.2.3.mk1/CHANGES
--- lilypond-1.2.3/CHANGES Sat Aug 28 14:10:30 1999
+++ lilypond-1.2.3.mk1/CHANGES Sat Aug 28 14:47:05 1999
@@ -1,3 +1,10 @@
+pl 3.mk1
+ - spanner.cc: added get_broken_left_end_align()
+ - crescendo.cc, tie.cc, slur.cc, volta-spanner.cc: align left
+ edge if broken.
+
+*************
+
pl 2.mk1
- bf, tie.cc: handle postbreak left align correctly
pl 2.lec1
diff -urN lilypond-1.2.3/TODO lilypond-1.2.3.mk1/TODO
--- lilypond-1.2.3/TODO Sat Aug 28 14:10:30 1999
+++ lilypond-1.2.3.mk1/TODO Sat Aug 28 15:13:10 1999
@@ -142,7 +142,7 @@
- The stemLength property should affect also beamed stems.
-. * align left edge of broken (de)cresc/slur/tie/tuplet/volta
+. * align left edge of broken tuplet-spanner (have a test case?)
. * fix dynamics decently, ie. use kerning & ligatures.
. * key restorations & repeats
. * paperXX.ly \quartwidth, font setting not up to date. (Should read from AFM?)
diff -urN lilypond-1.2.3/lily/crescendo.cc lilypond-1.2.3.mk1/lily/crescendo.cc
--- lilypond-1.2.3/lily/crescendo.cc Fri Jul 9 12:53:46 1999
+++ lilypond-1.2.3.mk1/lily/crescendo.cc Sat Aug 28 15:32:38 1999
@@ -20,13 +20,10 @@
dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
}
-
-
-
Molecule
Crescendo::get_symbol () const
{
- Real w_dim = extent (X_AXIS).length ();
+ Real w_dim = extent (X_AXIS).length () - get_broken_left_end_align();
Real absdyn_dim = paper_l ()-> get_realvar (ly_symbol ("crescendo_shorten"));
if (dyn_b_drul_[LEFT])
{
@@ -63,7 +60,10 @@
{
Molecule* m_p =0;
Real absdyn_dim = paper_l ()-> get_realvar (ly_symbol ("crescendo_shorten"));
- Real x_off_dim=0.0;
+ Real x_off_dim;
+
+ x_off_dim = get_broken_left_end_align();
+
if (dyn_b_drul_[LEFT])
x_off_dim += absdyn_dim;
@@ -73,5 +73,3 @@
m_p->translate_axis (x_off_dim, X_AXIS);
return m_p;
}
-
-
diff -urN lilypond-1.2.3/lily/graphical-axis-group.cc
lilypond-1.2.3.mk1/lily/graphical-axis-group.cc
--- lilypond-1.2.3/lily/graphical-axis-group.cc Thu Aug 19 18:21:07 1999
+++ lilypond-1.2.3.mk1/lily/graphical-axis-group.cc Sat Aug 28 15:26:53 1999
@@ -124,3 +124,21 @@
axes_[0] = a1 ;
axes_[1] = a2 ;
}
+
+// For debugging purposes...
+void
+Graphical_axis_group::dump_elems (int indent)
+{
+ int j, k;
+ for(j = 0; j < elem_l_arr_.size(); j++)
+ {
+ for(k = 0; k < indent; k++)
+ {
+ putchar(' ');
+ }
+ printf("%d -> %s\n", j, classname(elem_l_arr_[j]));
+ Graphical_axis_group *xx = dynamic_cast<Graphical_axis_group*>(elem_l_arr_[j]);
+ if(xx)
+ xx->dump_elems(indent + 2);
+ }
+}
diff -urN lilypond-1.2.3/lily/include/graphical-axis-group.hh
lilypond-1.2.3.mk1/lily/include/graphical-axis-group.hh
--- lilypond-1.2.3/lily/include/graphical-axis-group.hh Wed Jun 30 18:41:56 1999
+++ lilypond-1.2.3.mk1/lily/include/graphical-axis-group.hh Sat Aug 28 15:26:53
+1999
@@ -26,7 +26,7 @@
bool ordered_b_;
Link_array<Graphical_element> elem_l_arr_;
Axis axes_[2];
-
+
Interval extent (Axis) const;
virtual void do_print() const;
Graphical_axis_group(Graphical_axis_group const&s);
@@ -37,6 +37,7 @@
bool contains_b (Graphical_element const *) const;
void add_element (Graphical_element*);
void remove_element (Graphical_element*);
+ void dump_elems (int indent);
};
#endif // Graphical_axis_group_HH
diff -urN lilypond-1.2.3/lily/include/line-of-score.hh
lilypond-1.2.3.mk1/lily/include/line-of-score.hh
--- lilypond-1.2.3/lily/include/line-of-score.hh Thu Aug 5 12:17:35 1999
+++ lilypond-1.2.3.mk1/lily/include/line-of-score.hh Sat Aug 28 15:03:27 1999
@@ -27,6 +27,7 @@
void output_all (bool last_line);
void add_column (Paper_column*);
+ void dump_columns (void);
protected:
virtual void do_substitute_element_pointer (Score_element*, Score_element*);
diff -urN lilypond-1.2.3/lily/include/paper-score.hh
lilypond-1.2.3.mk1/lily/include/paper-score.hh
--- lilypond-1.2.3/lily/include/paper-score.hh Thu Aug 5 12:17:35 1999
+++ lilypond-1.2.3.mk1/lily/include/paper-score.hh Sat Aug 28 15:27:38 1999
@@ -45,6 +45,7 @@
/// add to bottom of pcols
void add_column (Paper_column*);
+ void dump_columns (void);
/**
@return index of argument.
diff -urN lilypond-1.2.3/lily/include/spanner.hh
lilypond-1.2.3.mk1/lily/include/spanner.hh
--- lilypond-1.2.3/lily/include/spanner.hh Sun Jul 18 23:44:37 1999
+++ lilypond-1.2.3.mk1/lily/include/spanner.hh Fri Aug 27 19:12:15 1999
@@ -68,6 +68,7 @@
this is virtual; for instance, Line_of_score overrides it.
*/
virtual void break_into_pieces ();
+ Real get_broken_left_end_align () const;
friend Axis_group_spanner; // UGH
diff -urN lilypond-1.2.3/lily/line-of-score.cc
lilypond-1.2.3.mk1/lily/line-of-score.cc
--- lilypond-1.2.3/lily/line-of-score.cc Sun Jul 18 23:44:37 1999
+++ lilypond-1.2.3.mk1/lily/line-of-score.cc Sat Aug 28 15:28:02 1999
@@ -60,6 +60,17 @@
cols_.push (p);
}
+// For debugging purposes
+void
+Line_of_score::dump_columns (void)
+{
+ int i;
+ for(i = 0; i < cols_.size(); i++) {
+ printf("%d -> %s\n", i, classname(cols_[i]));
+ cols_[i]->dump_elems(2);
+ }
+}
+
void
Line_of_score::do_print() const
{
diff -urN lilypond-1.2.3/lily/paper-score.cc lilypond-1.2.3.mk1/lily/paper-score.cc
--- lilypond-1.2.3/lily/paper-score.cc Wed Jul 14 01:58:03 1999
+++ lilypond-1.2.3.mk1/lily/paper-score.cc Sat Aug 28 15:28:22 1999
@@ -86,7 +86,16 @@
typeset_element(p);
}
-
+// For debugging purposes
+void
+Paper_score::dump_columns (void)
+{
+ int i;
+ for(i = 0; i < col_l_arr_.size(); i++) {
+ printf("%d -> %s\n", i, classname(col_l_arr_[i]));
+ col_l_arr_[i]->dump_elems(2);
+ }
+}
void
Paper_score::print () const
diff -urN lilypond-1.2.3/lily/slur.cc lilypond-1.2.3.mk1/lily/slur.cc
--- lilypond-1.2.3/lily/slur.cc Thu Aug 5 12:17:28 1999
+++ lilypond-1.2.3.mk1/lily/slur.cc Sat Aug 28 15:32:38 1999
@@ -27,7 +27,6 @@
#include "encompass-info.hh"
#include "main.hh"
-
Slur::Slur ()
{
}
@@ -186,11 +185,7 @@
*/
else
{
- /*
- need break-align too. what about other spanners?
- */
- if (d == LEFT)
- dx_f_drul_[d] = spanned_drul_[LEFT]->extent (X_AXIS).length ();
+ dx_f_drul_[d] = get_broken_left_end_align();
/*
broken: should get y from other piece, so that slur
diff -urN lilypond-1.2.3/lily/spanner.cc lilypond-1.2.3.mk1/lily/spanner.cc
--- lilypond-1.2.3/lily/spanner.cc Thu Aug 5 12:17:40 1999
+++ lilypond-1.2.3.mk1/lily/spanner.cc Sat Aug 28 15:32:36 1999
@@ -12,6 +12,8 @@
#include "paper-score.hh"
#include "molecule.hh"
#include "paper-outputter.hh"
+#include "score-column.hh"
+#include "line-of-score.hh"
void
Spanner::do_print() const
@@ -33,7 +35,7 @@
Item * left = spanned_drul_[LEFT];
Item * right = spanned_drul_[RIGHT];
-
+
if (left == right)
{
warning (_ ("left spanpoint is right spanpoint\n"));
@@ -70,7 +72,7 @@
span_p->set_bounds(LEFT,info.bounds_[LEFT]);
span_p->set_bounds(RIGHT,info.bounds_[RIGHT]);
pscore_l_->typeset_element (span_p);
-
+
info.broken_spanner_l_ = span_p;
span_p->handle_broken_dependencies();
@@ -222,4 +224,34 @@
else
programming_error ("Spanner y -refpoint lost.");
}
+}
+
+// If this is a broken spanner, return the amount the left end is to
+// be shifted horizontally so that the spanner starts after the
+// initial clef and key on the staves. This is necessary for ties,
+// slurs, crescendo and decrescendo signs, for example.
+Real
+Spanner::get_broken_left_end_align () const
+{
+ int i;
+ Score_column *sc;
+ Line_of_score *l;
+
+ sc = dynamic_cast<Score_column*> (spanned_drul_[LEFT]->column_l());
+
+ // Relevant only if left span point is first column in line
+ if(sc != NULL && sc->line_l()->cols_.find_i(sc) == 0)
+ {
+ // We could possibly return the right edge of the whole Score_column here,
+ // but we do a full search for the Break_align_item.
+ for(i = 0; i < sc->elem_l_arr_.size(); i++)
+ {
+ if(0 == strcmp(classname(sc->elem_l_arr_[i]), "Break_align_item"))
+ {
+ return sc->elem_l_arr_[i]->extent (X_AXIS) [RIGHT];
+ }
+ }
+ }
+
+ return 0.0;
}
diff -urN lilypond-1.2.3/lily/staff-side.cc lilypond-1.2.3.mk1/lily/staff-side.cc
--- lilypond-1.2.3/lily/staff-side.cc Thu Aug 5 12:17:40 1999
+++ lilypond-1.2.3.mk1/lily/staff-side.cc Fri Aug 27 19:00:17 1999
@@ -160,7 +160,7 @@
DOUT << "positioning " << to_position_l_->name();
DOUT << "axis == " << axis_name_str (axis_)
- << ", dir == " << to_str (dir_ );
+ << ", dir == " << to_str ((int)dir_ );
#endif
}
diff -urN lilypond-1.2.3/lily/tie.cc lilypond-1.2.3.mk1/lily/tie.cc
--- lilypond-1.2.3/lily/tie.cc Sat Aug 28 14:10:30 1999
+++ lilypond-1.2.3.mk1/lily/tie.cc Sat Aug 28 14:10:35 1999
@@ -130,7 +130,7 @@
if (head_l_drul_[LEFT])
dx_f_drul_[LEFT] = head_l_drul_[LEFT]->extent (X_AXIS).length ();
else
- dx_f_drul_[LEFT] = spanned_drul_[LEFT]->extent (X_AXIS).length ();
+ dx_f_drul_[LEFT] = get_broken_left_end_align();
dx_f_drul_[LEFT] += x_gap_f;
dx_f_drul_[RIGHT] -= x_gap_f;
diff -urN lilypond-1.2.3/lily/volta-spanner.cc
lilypond-1.2.3.mk1/lily/volta-spanner.cc
--- lilypond-1.2.3/lily/volta-spanner.cc Thu Aug 19 18:21:08 1999
+++ lilypond-1.2.3.mk1/lily/volta-spanner.cc Sat Aug 28 15:09:46 1999
@@ -48,7 +48,7 @@
Real t = paper_l ()->get_realvar (volta_thick_scm_sym);
Real dx = internote_f;
- Real w = extent (X_AXIS).length () - dx;
+ Real w = extent (X_AXIS).length () - dx - get_broken_left_end_align();
Real h = paper_l()->get_var ("volta_spanner_height");
Molecule volta (lookup_l ()->volta (h, w, t, no_vertical_start, no_vertical_end));
@@ -98,6 +98,7 @@
{
if (bar_arr_.size())
translate_axis (bar_arr_[0]->extent (Y_AXIS)[UP], Y_AXIS);
+ translate_axis (get_broken_left_end_align(), X_AXIS);
}
void