Interval hp = head_positions (me);
Real st = hp[dir] + dir * length_f;
+
+ /*
+ TODO: change name to extend-stems to staff/center/'()
+ */
bool no_extend_b = to_boolean (me->get_grob_property ("no-stem-extend"));
if (!grace_b && !no_extend_b && dir * st < 0) // junkme?
st = 0.0;
bool invisible = invisible_b (me);
- Real thick = 0.0;
- if (invisible)
- thick = gh_scm2double (me->get_grob_property ("thickness"))
- * me->get_paper ()->get_var ("linethickness");
+ Real thick = gh_scm2double (me->get_grob_property ("thickness"))
+ * me->get_paper ()->get_var ("linethickness");
Grob *hed = support_head (me);
Real l = Note_head::head_extent (heads[i], X_AXIS).length ();
Direction d = get_direction (me);
- heads[i]->translate_axis (l * d, X_AXIS);
+ /* reversed head should be shifted l-thickness, but this looks
+ too crowded, so we only shift l-0.5*thickness.
+ Notice that this leads to assymetry: Normal heads overlap
+ the stem 100% whereas reversed heads only overlaps the stem
+ 50% */
+ #define magic 0.5
+ heads[i]->translate_axis ((l-thick*magic) * d, X_AXIS);
if (invisible_b(me))
- heads[i]->translate_axis (-thick *2* d , X_AXIS);
+ heads[i]->translate_axis (-thick*(2-magic) * d , X_AXIS);
/* TODO:
Interval iv;
if (mol != SCM_EOL)
iv = unsmob_molecule (mol)->extent (a);
+ if (Grob *b =get_beam (me))
+ {
+ Direction d = get_direction (me);
+ iv[d] += d * Beam::get_thickness (b) /2.0 ;
+ }
+
return ly_interval2scm (iv);
}
Molecule
Stem::flag (Grob*me)
{
- /* TODO: rename flag-style into something more appropriate,
- e.g. "stroke-style", maybe with values "" (i.e. no stroke),
- "single" and "double". Needs more discussion.
- */
- String style, fstyle, staffline_offs;
- SCM fst = me->get_grob_property ("flag-style");
- if (gh_string_p (fst))
+ /* TODO: maybe property stroke-style should take different values,
+ e.g. "" (i.e. no stroke), "single" and "double" (currently, it's
+ '() or "grace"). */
+ String flag_style;
+
+ SCM flag_style_scm = me->get_grob_property ("flag-style");
+ if (gh_symbol_p (flag_style_scm))
{
- fstyle = ly_scm2string (fst);
+ flag_style = ly_symbol2string (flag_style_scm);
}
- SCM st = me->get_grob_property ("style");
- if (gh_symbol_p (st))
+ if (flag_style == "no-flag")
{
- style = (ly_scm2string (scm_symbol_to_string (st)));
- }
- else
- {
- style = "";
+ return Molecule ();
}
+
bool adjust = to_boolean (me->get_grob_property ("adjust-if-on-staffline"));
- if (String::compare (style, "mensural") == 0)
+ String staffline_offs;
+ if (String::compare (flag_style, "mensural") == 0)
/* Mensural notation: For notes on staff lines, use different
flags than for notes between staff lines. The idea is that
flags are always vertically aligned with the staff lines,
--hwn.
*/
- Grob *first = first_head(me);
- int sz = Staff_symbol_referencer::line_count (me)-1;
- int p = (int)rint (Staff_symbol_referencer::get_position (first));
- staffline_offs = (((p ^ sz) & 0x1) == 0) ? "1" : "0";
+ int p = (int)rint (Staff_symbol_referencer::get_position (first_head (me)));
+ staffline_offs = Staff_symbol_referencer::on_staffline (me, p) ?
+ "1" : "0";
}
else
{
{
staffline_offs = "";
}
- char c = (get_direction (me) == UP) ? 'u' : 'd';
- String index_string
- = String ("flags-") + style + to_string (c) + staffline_offs + to_string (duration_log (me));
- Molecule m
- = Font_interface::get_default_font (me)->find_by_name (index_string);
- if (!fstyle.empty_b ())
- m.add_molecule (Font_interface::get_default_font (me)->find_by_name (String ("flags-") + to_string (c) + fstyle));
- return m;
+
+ char dir = (get_direction (me) == UP) ? 'u' : 'd';
+ String font_char =
+ flag_style + to_string (dir) + staffline_offs + to_string (duration_log (me));
+ Font_metric *fm = Font_interface::get_default_font (me);
+ Molecule flag = fm->find_by_name ("flags-" + font_char);
+ if (flag.empty_b ())
+ {
+ me->warning (_f ("flag `%s' not found", font_char));
+ }
+
+ SCM stroke_style_scm = me->get_grob_property ("stroke-style");
+ if (gh_string_p (stroke_style_scm))
+ {
+ String stroke_style = ly_scm2string (stroke_style_scm);
+ if (!stroke_style.empty_b ())
+ {
+ String font_char = to_string (dir) + stroke_style;
+ Molecule stroke = fm->find_by_name ("flags-" + font_char);
+ if (stroke.empty_b ())
+ {
+ me->warning (_f ("flag stroke `%s' not found", font_char));
+ }
+ else
+ {
+ flag.add_molecule (stroke);
+ }
+ }
+ }
+
+ return flag;
}
MAKE_SCHEME_CALLBACK (Stem,dim_callback,2);
/*
TODO: make the stem start a direction ?
*/
-
-
-
if (to_boolean (me->get_grob_property ("avoid-note-head")))
{
Grob * lh = last_head (me);
me->get_grob_property ("beamed-minimum-free-lengths")))
* staff_space;
- int my_beam_count = Stem::beam_multiplicity (me).length () + 1;
+
+ /* UGH
+ It seems that also for ideal minimum length, we must use
+ the maximum beam count (for this direction):
+
+ \score{ \notes\relative c''{ [a8 a32] }}
+
+ must be horizontal. */
Real height_of_my_beams = beam_thickness
- + (my_beam_count - 1) * beam_translation;
-
+ + (beam_count - 1) * beam_translation;
+
Real ideal_minimum_length = ideal_minimum_free
+ height_of_my_beams
/* stem only extends to center of beam */
ADD_INTERFACE (Stem,"stem-interface",
"A stem",
- "up-to-staff avoid-note-head adjust-if-on-staffline thickness stem-info beamed-lengths beamed-minimum-free-lengths beamed-extreme-minimum-free-lengths lengths beam stem-shorten duration-log beaming neutral-direction stem-end-position support-head note-heads direction length style no-stem-extend flag-style");
+ "up-to-staff avoid-note-head adjust-if-on-staffline thickness stem-info beamed-lengths beamed-minimum-free-lengths beamed-extreme-minimum-free-lengths lengths beam stem-shorten duration-log beaming neutral-direction stem-end-position support-head note-heads direction length flag-style no-stem-extend stroke-style");