-#include "staff-symbol-referencer.hh"
-#include "line-interface.hh"
-
-MAKE_SCHEME_CALLBACK (Bar_line, calc_bar_extent, 1)
-SCM
-Bar_line::calc_bar_extent (SCM smob)
-{
- Grob *me = unsmob_grob (smob);
-
- SCM size = me->get_property ("bar-size");
-
- if (!scm_is_number (size)
- || !Staff_symbol_referencer::get_staff_symbol (me))
- return ly_interval2scm (Interval ());
-
- Real h = scm_to_double (size);
- return ly_interval2scm (Interval (-h/2, h/2));
-}
-
-Interval
-Bar_line::bar_y_extent (Grob *me, Grob *refpoint)
-{
- Interval iv = robust_scm2interval (me->get_property ("bar-extent"), Interval ());
-
- iv.translate (me->relative_coordinate (refpoint, Y_AXIS));
- return iv;
-}
-
-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 barsize = me->get_property ("bar-size");
-
- if (scm_is_string (s) && scm_is_number (barsize))
- {
- string str = ly_scm2string (s);
- Real sz = robust_scm2double (barsize, 0);
- if (sz <= 0)
- return SCM_EOL;
-
- return compound_barline (me, str, sz, false).smobbed_copy ();
- }
- return SCM_EOL;
-}
-
-Stencil
-Bar_line::compound_barline (Grob *me, string str, Real h,
- 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, h, rounded);
- Stencil thick = simple_barline (me, fatline, h, 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);
-
- Stencil m;
- Grob *staff = Staff_symbol_referencer::get_staff_symbol (me);
- Real center = 0;
- if (staff)
- {
- Interval staff_extent = staff->extent (staff, Y_AXIS);
- center = staff_extent.center ();
- }
-
- if (str == "||:")
- str = "|:";
-
- if (str == "")
- {
- Stencil empty = Lookup::blank (Box (Interval (0, 0), Interval (-h / 2, h / 2)));
- empty.translate_axis (center, Y_AXIS);
- return empty;
- }
- else if (str == "|")
- {
- thin.translate_axis (center, Y_AXIS);
- return thin;
- }
- 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);