- return has_interface (me) && !me->extent (me, X_AXIS).is_empty ();
-}
-
-MAKE_SCHEME_CALLBACK (Bar_line, print, 1);
-SCM
-Bar_line::print (SCM smob)
-{
- Grob *me = unsmob_grob (smob);
-
- SCM s = me->get_property ("glyph-name");
- SCM extent = me->get_property ("bar-extent");
-
- if (scm_is_string (s) && is_number_pair (extent))
- {
- string str = ly_scm2string (s);
- Interval ex = ly_scm2interval (extent);
- if (ex.length () > 0)
- {
- Stencil result = compound_barline (me, str, ex, false);
-
- return result.smobbed_copy ();
- }
- }
- return SCM_EOL;
-}
-
-Stencil
-Bar_line::compound_barline (Grob *me, string str, Interval const &extent,
- bool rounded)
-{
- Real kern = robust_scm2double (me->get_property ("kern"), 1);
- Real thinkern = robust_scm2double (me->get_property ("thin-kern"), 1);
- Real hair = robust_scm2double (me->get_property ("hair-thickness"), 1);
- Real fatline = robust_scm2double (me->get_property ("thick-thickness"), 1);
-
- Real staffline = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
- Real staff_space = Staff_symbol_referencer::staff_space (me);
-
- kern *= staffline;
- thinkern *= staffline;
- hair *= staffline;
- fatline *= staffline;
-
- Stencil thin = simple_barline (me, hair, extent, rounded);
- Stencil thick = simple_barline (me, fatline, extent, rounded);
- Stencil dot = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
-
- int lines = Staff_symbol_referencer::line_count (me);
- Real dist
- = ((lines & 1 || lines == 0)
- ? 1
- : (staff_space < 2 ? 2 : .5)) * staff_space;
- Stencil colon (dot);
- colon.translate_axis (dist, Y_AXIS);
- colon.add_stencil (dot);
- colon.translate_axis (-dist / 2, Y_AXIS);
-
- Real const h = extent.length ();
- Stencil m;
-
- if (str == "||:")
- str = "|:";
-
- if (str == "|S" || str == "S|")
- str = "S";
-
- if (str == "")
- {
- Stencil empty = Lookup::blank (Box (Interval (0, 0), extent));
- return empty;
- }
- else if (str == "|")
- return thin;
- else if (str == ".")
- return thick;
- else if (str == "|." || (h == 0 && str == ":|"))
- {
- m.add_at_edge (X_AXIS, LEFT, thick, 0);
- m.add_at_edge (X_AXIS, LEFT, thin, kern);
- }
- else if (str == ".|" || (h == 0 && str == "|:"))
- {
- m.add_at_edge (X_AXIS, RIGHT, thick, 0);
- m.add_at_edge (X_AXIS, RIGHT, thin, kern);
- }
- else if (str == ":|")
- {
- m.add_at_edge (X_AXIS, LEFT, thick, 0);
- m.add_at_edge (X_AXIS, LEFT, thin, kern);
- m.add_at_edge (X_AXIS, LEFT, colon, kern);
- }
- else if (str == "|:")
- {
- m.add_at_edge (X_AXIS, RIGHT, thick, 0);
- m.add_at_edge (X_AXIS, RIGHT, thin, kern);
- m.add_at_edge (X_AXIS, RIGHT, colon, kern);
- }
- else if (str == ":|:")
- {
- m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
- m.add_at_edge (X_AXIS, LEFT, colon, kern);
- m.add_at_edge (X_AXIS, RIGHT, thick, kern);
- m.add_at_edge (X_AXIS, RIGHT, colon, kern);
- }
- else if (str == ":|.|:")
- {
- m.add_at_edge (X_AXIS, LEFT, thick, 0);
- m.add_at_edge (X_AXIS, LEFT, thin, kern);
- m.add_at_edge (X_AXIS, LEFT, colon, kern);
- m.add_at_edge (X_AXIS, RIGHT, thin, kern);
- m.add_at_edge (X_AXIS, RIGHT, colon, kern);
- }
- else if (str == ":|.:")
- {
- m.add_at_edge (X_AXIS, LEFT, thick, 0);
- m.add_at_edge (X_AXIS, LEFT, thin, kern);
- m.add_at_edge (X_AXIS, LEFT, colon, kern);
- m.add_at_edge (X_AXIS, RIGHT, colon, kern);
- }
- else if (str == ".|.")
- {
- m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
- m.add_at_edge (X_AXIS, RIGHT, thick, kern);
- }
- else if (str == "|.|")
- {
- m.add_at_edge (X_AXIS, LEFT, thick, 0);
- m.add_at_edge (X_AXIS, LEFT, thin, kern);
- m.add_at_edge (X_AXIS, RIGHT, thin, kern);
- }
- else if (str == "||")
- {
- /*
- should align to other side? this never appears
- on the system-start?
- m.add_at_edge (X_AXIS, RIGHT, thin, 0);
- m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);
- */
- m.add_at_edge (X_AXIS, LEFT, thin, thinkern);
- m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);
- }
- else if (str.find ("S") != NPOS || str == "|._.|")
- {
- // Handle all varsegno stuff
- Stencil segno;
- segno.add_at_edge (X_AXIS, LEFT, thin, thinkern);
- segno.add_at_edge (X_AXIS, RIGHT, thin, thinkern);
- segno.add_stencil (Font_interface::get_default_font (me)->find_by_name ("scripts.varsegno"));
-
- if (str == "S")
- m.add_stencil (segno);
- else if (str == "S|:" || str == ".S|:")
- {
- m.add_at_edge (X_AXIS, RIGHT, thick, 0);
- m.add_at_edge (X_AXIS, RIGHT, thin, kern);
- m.add_at_edge (X_AXIS, RIGHT, colon, kern);
- m.add_at_edge (X_AXIS, LEFT, segno, thinkern);
- }
- else if (str == ":|S" || str == ":|S.")
- {
- m.add_at_edge (X_AXIS, LEFT, thick, 0);
- m.add_at_edge (X_AXIS, LEFT, thin, kern);
- m.add_at_edge (X_AXIS, LEFT, colon, kern);
- m.add_at_edge (X_AXIS, RIGHT, segno, thinkern);
- }
- else if (str == ":|S|:" || str == ":|S.|:")
- {
- m.add_at_edge (X_AXIS, LEFT, thick, 0);
- m.add_at_edge (X_AXIS, LEFT, thin, kern);
- m.add_at_edge (X_AXIS, LEFT, colon, kern);
- m.add_at_edge (X_AXIS, RIGHT, segno, thinkern);
- m.add_at_edge (X_AXIS, RIGHT, thick, thinkern);
- m.add_at_edge (X_AXIS, RIGHT, thin, kern);
- m.add_at_edge (X_AXIS, RIGHT, colon, kern);
- }
- else if (str == "|._.|") // :|S|: or :|S.|: without segno and colon
- {
- // get the width of the segno sign
- Real segno_width = segno.extent (X_AXIS).length ();
- m.add_at_edge (X_AXIS, LEFT, thick, 0);
- m.add_at_edge (X_AXIS, LEFT, thin, kern);
- m.add_at_edge (X_AXIS, RIGHT, thick, segno_width + 2 * thinkern);
- m.add_at_edge (X_AXIS, RIGHT, thin, kern);
- }
- // end varsegno block
- }
- else if (str == ":")
- {
- if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me))
- {
- Interval staff_extent = staff->extent (staff, Y_AXIS);
-
- /*
- assume staff lines are disposed equally at unit space;
- put a dot into each space within extent (may extend staff_extent).
-
- staff_extent is an interval of two integers or two half-integers;
- in the former case dots are to be placed at half-integers,
- in the latter at integers.
-
- these integers are not exact due to staff line thickness.
- */
- int const pos = int (rint (staff_extent.at (UP) * 2));
- Real const correction = pos & 1 ? 0.0 : 0.5;
-
- for (int i = int (rint (extent.at (DOWN) + (0.5 - correction))),
- e = int (rint (extent.at (UP) + (0.5 - correction)));
- i < e;
- ++i)
- {
- Stencil d (dot);
-
- d.translate_axis (i + correction, Y_AXIS);
- m.add_stencil (d);
- }
- }
- }
- else if (str == "dashed")
- m = dashed_bar_line (me, extent, hair);
- else if (str == "'")
- m = tick_bar_line (me, extent.at (UP), rounded);
-
- return m;
-}
-
-Stencil
-Bar_line::simple_barline (Grob *me,
- Real w,
- Interval const &extent,
- bool rounded)
-{
- Real blot
- = rounded
- ? me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"))
- : 0.0;
-
- return Lookup::round_filled_box (Box (Interval (0, w), extent), blot);
-}
-
-Stencil
-Bar_line::tick_bar_line (Grob *me, Real h, bool rounded)
-{
- Real th = Staff_symbol_referencer::staff_space (me) / 2;
- Real line_thick = Staff_symbol_referencer::line_thickness (me);
-
- Real blot
- = rounded
- ? me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"))
- : 0.0;
-
- return Lookup::round_filled_box (Box (Interval (0, line_thick),
- Interval (h - th, h + th)), blot);