*/
#include "stem.hh"
+#include "spanner.hh"
#include <cmath> // rint
using namespace std;
return exthead;
}
-static int
-integer_compare (int const &a, int const &b)
-{
- return a - b;
-}
-
/* The positions, in ascending order. */
vector<int>
Stem::note_head_positions (Grob *me)
ps.push_back (p);
}
- vector_sort (ps, integer_compare);
+ vector_sort (ps, less<int> ());
return ps;
}
extract_grob_set (me, "note-heads", ro_heads);
vector<Grob*> heads (ro_heads);
- vector_sort (heads, compare_position);
+ vector_sort (heads, position_less);
Direction dir = get_grob_direction (me);
if (dir < 0)
dir = UP;
set_grob_direction (me, dir);
}
-
+
+ bool is_harmonic_centered = false;
+ for (vsize i = 0; i < heads.size (); i++)
+ is_harmonic_centered = is_harmonic_centered
+ || heads[i]->get_property ("style") == ly_symbol2scm ("harmonic");
+ is_harmonic_centered = is_harmonic_centered && is_invisible (me);
+
Real w = hed->extent (hed, X_AXIS)[dir];
for (vsize i = 0; i < heads.size (); i++)
- heads[i]->translate_axis (w - heads[i]->extent (heads[i], X_AXIS)[dir],
- X_AXIS);
+ {
+ Real amount = w - heads[i]->extent (heads[i], X_AXIS)[dir];
+ if (is_harmonic_centered)
+ amount =
+ hed->extent (hed, X_AXIS).linear_combination (CENTER)
+ - heads[i]->extent (heads[i], X_AXIS).linear_combination (CENTER);
+
+ heads[i]->translate_axis (amount, X_AXIS);
+ }
bool parity = true;
Real lastpos = Real (Staff_symbol_referencer::get_position (heads[0]));
for (vsize i = 1; i < heads.size (); i++)
}
/* FIXME: Too many properties */
-ADD_INTERFACE (Stem, "stem-interface",
+ADD_INTERFACE (Stem,
"The stem represent the graphical stem. "
"In addition, it internally connects note heads, beams and"
"tremolos. "